Quotes help make search much faster. Example: "Practice Makes Perfect"

Wednesday, September 4, 2019

Codecademy Learn R Dealing with Duplicates 5/10


#Sample Solution
---
title: "Data Cleaning in R"
output: html_notebook
---

```{r message=FALSE, warning=FALSE}
# load libraries
library(dplyr)
library(tidyr)
```

```{r}
# load students data frame
load("students.Rda")
```

```{r}
# drop id column
students <- students %>% select(-id)
head(students)
```

```{r}
# find and count duplicated rows
duplicates <- students %>% duplicated()
duplicates <- duplicates %>% table()
duplicates
```

```{r}
# remove duplicated rows
students <- students %>% distinct()
```

```{r}
# find and count duplicated rows in updated data frame
updated_duplicates <- students %>% duplicated()
updated_duplicates <- updated_duplicates %>% table()
updated_duplicates
```

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts