2
1
The following is my code for the function I want to utilise group by in. 1, 2, and 3 all work well, however function 4 doesn't. I need help because I don't know how to solve this issue.
Number 1: create variables and a dataframe
df - data.frame(y, x) #2 group by y x - rnorm(100) y - rep(c("A", "B"), 50
group by(y) percent > percent df percent > percent
summarising with (n = n(), mean = mean(x), sd = sd(x))
# 3 make a function
function for a group (df, var1, var2)
group by(var1) percent > percent df percent > percent
summarising with (n = n(), mean = mean(var2), sd = sd(var2))
Test function #4
the issue is group(df = df, var1 = y, var2 = x) #
"Grounded df impl(data, unname(vars), drop) error:
Unknown column 'var1'
Called from: data, unname(vars), drop, grouped df impl ",