我试图改变所有数据集,以取代特殊符号和字符, 但我想用dplyr来执行 ,我没有找到答案。 当我说“特殊”,我的意思是在国外的语言,如葡萄牙语中的典型符号。
ds <- data.frame(group=c("american", "canadian"),
queçtão.1=rnorm(n=50,mean=100,sd=15),
queçtão.2=rnorm(n=50, mean=1500, sd=300),
queçtão.18=rnorm(n=50, mean=5, sd=2))
喜欢的东西
quectao1
quectao2
quectão18
为什么我的问题:
论坛成员,帮我用dplyr收集变量和总结其成果 ,但它不是在与特殊符号变量工作:
set.see(123)
ds <- data.frame(group=c("american", "canadian"),
queçtão.1=rnorm(n=50,mean=100,sd=15),
queçtão.2=rnorm(n=50, mean=1500, sd=300),
queçtão.18=rnorm(n=50, mean=5, sd=2))
ds %>%
group_by(group) %>%
summarise_at(vars(queçtão.1,queçtão.2,queçtão.18),funs(mean, sd)) %>%
gather(key, val, queçtão.1_mean:queçtão.18_sd) %>%
separate(key, into = c('key1', 'key2')) %>%
unite(group, group, key2) %>%
spread(group, val)
Error: Duplicate identifiers for rows (1, 7), (5, 11), (3, 9), (2, 8), (6, 12), (4, 10)
In addition: Warning message:
Expected 2 pieces. Additional pieces discarded in 12 rows [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].