【发布时间】:2021-05-31 14:29:57
【问题描述】:
如何重新排序甲虫的数量,从 0 到 15 以上?我尝试将“甲壳虫的数量”转换为一个因子,但它不起作用。
data<-g
#> Error in eval(expr, envir, enclos): object 'g' not found
#############################################original basic code
ggplot(data,aes(x=Locality.Division))+
geom_bar(aes(fill=Number.of.Beetle,),position="dodge")+
facet_wrap(~Building.Age)
#> Error in ggplot(data, aes(x = Locality.Division)): could not find function "ggplot"
############################################wanted to change the order of building age, so convert it to a factor
data.new<-g
#> Error in eval(expr, envir, enclos): object 'g' not found
g$Building.Age<-factor(g$Building.Age,
levels = c("Under 5 Years","5-10 Years","Above 10 Years"))
#> Error in factor(g$Building.Age, levels = c("Under 5 Years", "5-10 Years", : object 'g' not found
########################################## run same code by modifying the new name of the data
ggplot(g,aes(x=Locality.Division))+
geom_bar(aes(fill=Number.of.Beetle,),position="dodge")+
facet_wrap(~Building.Age)
#> Error in ggplot(g, aes(x = Locality.Division)): could not find function "ggplot"
由reprex package (v2.0.0) 于 2021 年 5 月 31 日创建
【问题讨论】:
-
您可以发布示例数据吗?请使用
dput(data)的输出编辑问题。或者,如果dput(head(data, 20))的输出太大。 -
这是数据样本的链接。请检查