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

Wednesday, September 4, 2019

Codecademy Learn R Reshaping your Data 4/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}
# original column names
students
original_col_names <- colnames(students)
original_col_names
```

```{r}
# gather columns
students <- students %>% gather('fractions','probability',key='exam',value='score')
head(students)
```

```{r}
# updated column names
gathered_col_names <- colnames(students)
gathered_col_names
```

```{r}
# unique value counts of exam
exam_counts <- students %>% count(exam)
exam_counts
```

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts