Is it possible to create a new column by multiplying two columns together? Such as: Mutate(survey, New_column = column_A *column_B)?
@weecology2 жыл бұрын
Yep. That code should work just fine.
@alansantana18382 жыл бұрын
@@weecology That's great, I am glad that I am getting the hang of this. Unfortunately, the code didn't work. R thinks it's non-numerical. But glad my thought process is in the right place! Thank you!
@weecology2 жыл бұрын
@@alansantana1838 You're welcome! If I had to guess R has stored one of the two columns as something that isn't a number, probably either a string or a factor. You try wrapping that column name in as.numeric, e.g., mutate(survey, New_column = as.numeric(column_A) * column_B). If the column can reasonably be converted to numbers this might fix things for you. The better solution in the long run is to define the type for that column when you import or otherwise create the data.
@aram5704 Жыл бұрын
Can we do that using pipe operator?
@weecology Жыл бұрын
Yes, absolutely. Pretty much anything you can do in dplyr can be done using pipes