如何使用 geom_area 作图?
how to graph using geom_area?
有谁知道为什么我的数据没有图形化?
data_frame
univ_apps
----------------------------
timeappreceived chr May_12_2002, March_4_2002
bs_ms_phd factor 1 for bs 2 for ms 3 for phd
appid int rn89 qw23 et43
sample data
--------------
timeappreceived bs_ms_phd appid
Sept_2_1989 1 rn89
Sept_2_1989 2 dq11
Oct_1_2011 1 bg32
等等
univdata = ggplot(univ_apps,
aes(x= yearappreceived, y= appid, fill=as.factor(bs_ms_phd))) +
geom_area(position="stack")
我是否遗漏了图表命令中的某些内容?
如您所示的数据框,"timeappreceived" 是 chr。我猜 "yearappreceived" 的数据类型与 "timeappreceived" 相同。您应该将其转换为数字。试试下面的代码。
univdata = ggplot(univ_apps, aes(x= as.integer(yearappreceived),
y= appid, fill=as.factor(bs_ms_phd))) + geom_area(position="stack"); univdata
顺便说一句,如果appid不是数字,你也应该转换它们。但是appid是整数,不是吗?
有谁知道为什么我的数据没有图形化?
data_frame
univ_apps
----------------------------
timeappreceived chr May_12_2002, March_4_2002
bs_ms_phd factor 1 for bs 2 for ms 3 for phd
appid int rn89 qw23 et43
sample data
--------------
timeappreceived bs_ms_phd appid
Sept_2_1989 1 rn89
Sept_2_1989 2 dq11
Oct_1_2011 1 bg32
等等
univdata = ggplot(univ_apps,
aes(x= yearappreceived, y= appid, fill=as.factor(bs_ms_phd))) +
geom_area(position="stack")
我是否遗漏了图表命令中的某些内容?
如您所示的数据框,"timeappreceived" 是 chr。我猜 "yearappreceived" 的数据类型与 "timeappreceived" 相同。您应该将其转换为数字。试试下面的代码。
univdata = ggplot(univ_apps, aes(x= as.integer(yearappreceived),
y= appid, fill=as.factor(bs_ms_phd))) + geom_area(position="stack"); univdata
顺便说一句,如果appid不是数字,你也应该转换它们。但是appid是整数,不是吗?