我得到了以下错误:
UseMethod("rescale")中的错误:没有适用于“c(‘haven_标签’,'vctrs_vctr',‘double’)类对象的”rescale“方法
下面是我的情节代码:
ggplot(data_q_agg3, aes(x = 'qmrcms', y = 'count', fill = 'qbncap')) + geom_col(position = "dodge")
data_q_agg3是通过这样创建的(参见图):
data_q_agg3 <- group_by(na.omit(data_jointest), qbncap, qmrcms) %>%
summarise(count=n())

data_jointest是通过这样做创建的(只是将两个数据帧相加在一起):
data_jointest <- rbind(data_q_clean2, data_q_clean4, deparse.level = 0)最后,当我试图生成这个情节时,我会得到以下消息/错误:
Don't know how to automatically pick scale for object of type haven_labelled/vctrs_vctr/double. Defaulting to continuous.
Don't know how to automatically pick scale for object of type haven_labelled/vctrs_vctr/double. Defaulting to continuous.
Error in UseMethod("rescale") :
no applicable method for 'rescale' applied to an object of class "c('haven_labelled', 'vctrs_vctr', 'double')"`帮助修复这个错误将是非常感谢的!
发布于 2021-08-06 19:49:34
我也经历过同样的问题并解决了它。此错误是由创建不兼容类类型的haven包造成的。解决方案是将变量类从c('haven_labelled', 'vctrs_vctr', 'double')更改为factor或numeric,例如:
data_q_agg3$qbncap <- as.numeric(data_q_agg3$qbncap)或作为因素:
data_q_agg3$qbncap <- as.factor(data_q_agg3$qbncap)如果您不确定哪个变量是有问题的,可以使用以下方法同时查看每个变量的类:
sapply(data_q_agg3, class)例如,应用于mtcar数据集:
sapply(mtcars, class)
mpg cyl disp hp drat wt qsec vs
"numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "numeric"
am gear carb
"numeric" "numeric" "numeric" 发布于 2021-06-14 12:19:45
不容易复制..。但我认为您应该首先检查df是否缺少值(类似于: df!is.na(df$n) )。
发布于 2022-05-18 16:56:33
我遇到了同样的错误..。我们只需要删除''
aes(x = qmrcms, y = count, fill = qbncap) 在我删除''之后,错误就消失了,并且成功地创建了绘图。
https://stackoverflow.com/questions/67333840
复制相似问题