Skip to content

Instantly share code, notes, and snippets.

@joranE
Created December 3, 2017 18:11
Show Gist options
  • Save joranE/324f7d486f407cea499e54b3c032541a to your computer and use it in GitHub Desktop.
Save joranE/324f7d486f407cea499e54b3c032541a to your computer and use it in GitHub Desktop.
dat <- structure(list(rank = c("1 ", "1 ", "1 "), bib = c("1 ", "1 ",
"1 "), `fis code` = c("3422819 ", "3422819 ", "3422819 "), name = c("KLAEBO Johannes Hoesflot ",
"KLAEBO Johannes Hoesflot ", "KLAEBO Johannes Hoesflot "), nsa = c("NOR ",
"NOR ", "NOR "), `7.35km` = c("3 ", "18:30.8 ", "10 "), `11.1km` = c("18 ",
"28:39.5 ", ""), `22.3 km` = c("2 ", "57:36.8 ", "12 "), `26.1km` = c("7",
"1:07:08.1 ", "4"), finish = c("1:16:47.1 ", "1:16:47.1 ", "1:16:47.1 "
), fis = c("0.00", "0.00", "0.00"), grp = c(1L, 1L, 1L), val = c("split_rank",
"split_time", "split_bonus")), .Names = c("rank", "bib", "fis code",
"name", "nsa", "7.35km", "11.1km", "22.3 km", "26.1km", "finish",
"fis", "grp", "val"), row.names = c(NA, -3L), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), vars = "grp", drop = TRUE, indices = list(
0:2), group_sizes = 3L, biggest_group_size = 3L, labels = structure(list(
grp = 1L), row.names = c(NA, -1L), class = "data.frame", vars = "grp", drop = TRUE, .Names = "grp"))
library(dplyr)
dat %>%
rename_at(.vars = vars(contains("nsa")),.funs = function(x) "nation")
# Error: All arguments must be named
@nxskok
Copy link

nxskok commented Dec 3, 2017

your function isn't named. Try defining

f=function(x) "nation"

and then funs=f inside rename_at.

@joranE
Copy link
Author

joranE commented Dec 4, 2017

@nxskok That didn't seem to help, sadly. But removing the grouping did, and I don't know why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment