data-edu / data-science-in-education

Repository for the second edition of 'Data Science in Education Using R' by Emily A. Bovee, Ryan A. Estrellado, Joshua M. Rosenberg, and Isabella C. Velásquez
http://www.datascienceineducation.com/
260 stars 78 forks source link

7.9 Process Data #550

Closed jimmyvluong closed 3 years ago

jimmyvluong commented 3 years ago

Hi, I'm new to GitHub and pull requests etc. so sorry if this is the wrong place for this!

I am working through Walkthrough 1 and noticed that the output for the below code does not match the output below it. Should the last line of code be modified so that it is: Proposed code:

# Dataset of students
df <- tibble(
  male = 5, 
  female = 5
)

# Use mutate to create a new column called "total_students" 
  # populate that column with the sum of the "male" and "female" variables

df <- df %>% 
  mutate(total_students = male + female)

Existing code:

# Dataset of students
df <- tibble(
  male = 5, 
  female = 5
)

# Use mutate to create a new column called "total_students" 
  # populate that column with the sum of the "male" and "female" variables
df %>% mutate(total_students = male + female)

Intended output:

## # A tibble: 1 x 3
##    male female total_students
##   <dbl>  <dbl>          <dbl>
## 1     5      5             10

Actual output:

# A tibble: 1 x 2
   male female
  <dbl>  <dbl>
1     5      5