I am confused about how the paste () function works. I have a dplyr table with the following columns:
Year Month DayofMonth
2001 May 21
2001 May 22
2001 June 9
2001 March 4
What I would like to combine in one column called "Date". I realized that I used the command:
df2 = mutate(df, Date = paste(c(Year, Month, DayofMonth), sep = "-",))
Unfortunately, this seems to combine every element in the year, then every element in the month, then every element in DayofMonth, so the result looks something like this:
2001-2001-2001-2001 ... May-May-June-March ... 21-22-9-4
How can I change my command so that the insert function repeats on each line separately?
PS This is part of the Data Camp course , and so I run the commands through any version of R that they received on their server.
source
share