in R language, how would you use mutate() to make a
new column in the dataset called moisture100 which contains the
moisture score times 100
I wrote
coffee_ratings %>%
mutate(moisture100=moisture*100)
but I get an error?
Error is recieved because that's not how a mutate function is written in R. To make a new column in the dataset you have to write the correct syntax for mutate function which is:
"Name of Dataset" <- mutate("Name of dataset" , "Define the new column here")
In above syntax, Insert name of your dataset. The function has two arguments: first is the name of dataset we want to modify and second is called a name-pair value in which we define a new column name and assign it's value.In our case, column name is moisture100.
So, the correct way to write your code for mutate function is:
"Your Dataset Name" <- mutate("Your Dataset Name", moisture100 = moisture*100)
Note: Remember that syntax does not contain double quotes (" ") in it. It is for explanation purpose.
Get Answers For Free
Most questions answered within 1 hours.