I have a data.frame
with variables var1
var2
(both strings) and variables x
, y
, and z
. I would like
It could be a problem with the attributes or grouping variable. We can reset the dataset without external attributes by converting to data.frame
and then do the mutate_at
df_ %>%
as.data.frame %>%
mutate_at(vars(x, y, z), funs(norm = ./.[1]))
Building on @akrun's answer, you can also use the first()
function from dplyr
:
df_ %>%
mutate_at(vars(c("x", "y", "z")), funs(norm = ./first(.)))