I have used this string of code in R for months and months. Just now running it it came up with an error where I haven't before. Here is the code: dat <- dat %>% mutate(row = row_number()) Here is the error: Error: row_number() should only be called in a data context The data frame "dat" is a normal data frame of 8 columns and 400,000 rows.
Asked
Active
Viewed 234 times
0
-
1Try `dat <- dat %>% dplyr::mutate(row = row_number())` – Ronak Shah Dec 02 '20 at 02:18
-
1Almost certainly you loaded `plyr` (or loaded another package that loaded `plyr`) and the old `plyr::mutate` function is masking `dplyr::mutate`. To solve the problem in the moment you can restart R, or [unload `plyr`](https://stackoverflow.com/a/6979989/903061), or specify `dplyr::mutate`, or use the `conflicted` package to handle name conflicts. In the future be careful to not load `plyr` after `dplyr`. (A fairly big warning prints if you do - look out for it.) – Gregor Thomas Dec 02 '20 at 02:44
-
Thank you so much!! – Rachelo Dec 02 '20 at 15:57