geom_lollipop(包 Ggalt)不工作
geom_lollipop (package Ggalt) not working
我正在按照以下 link.
包 ggalt
中有关如何使用 geom_lollipop
的教程进行操作
我正在尝试 运行 的代码如下:
df <- read.csv(text="category,pct
Other,0.09
South Asian/South Asian Americans,0.12
Interngenerational/Generational,0.21
S Asian/Asian Americans,0.25
Muslim Observance,0.29
Africa/Pan Africa/African Americans,0.34
Gender Equity,0.34
Disability Advocacy,0.49
European/European Americans,0.52
Veteran,0.54
Pacific Islander/Pacific Islander Americans,0.59
Non-Traditional Students,0.61
Religious Equity,0.64
Caribbean/Caribbean Americans,0.67
Latino/Latina,0.69
Middle Eastern Heritages and Traditions,0.73
Trans-racial Adoptee/Parent,0.76
LBGTQ/Ally,0.79
Mixed Race,0.80
Jewish Heritage/Observance,0.85
International Students,0.87", stringsAsFactors=FALSE, sep=",", header=TRUE)
library(ggplot2)
library(scales)
library(ggalt)
gg <- ggplot(df, aes(y=reorder(category, pct), x=pct))
gg <- gg + geom_lollipop(point.colour="steelblue", point.size=3, horizontal=TRUE)
gg <- gg + scale_x_continuous(expand=c(0,0), labels=percent,
breaks=seq(0, 1, by=0.2), limits=c(0, 1))
gg <- gg + labs(x=NULL, y=NULL,
title="SUNY Cortland Multicultural Alumni survey results")
gg <- gg + theme_minimal(base_family="Arial Narrow")
gg <- gg + theme(panel.grid.major.y=element_blank())
gg <- gg + theme(panel.grid.minor=element_blank())
gg <- gg + theme(axis.line.y=element_line(color="#2b2b2b", size=0.15))
gg <- gg + theme(axis.text.y=element_text(margin=margin(r=-5, l=0)))
gg <- gg + theme(plot.margin=unit(rep(30, 4), "pt"))
gg <- gg + theme(plot.title=element_text(face="bold"))
gg
我的输出不是创建棒棒糖图,而是如下:
geom_lollipop
似乎不起作用。此外,当我尝试数字 geom_lollipop 时,Rstudio 似乎没有在可用函数中找到它。
我以为是包版本的问题,但我已经更新了R并重新安装了上面所有的包。以下是正在使用的 R 和库的版本:
> packageVersion("ggalt")
[1] ‘0.1.1’
> packageVersion("ggplot2")
[1] ‘2.1.0’
> packageVersion("scales")
[1] ‘0.4.0’
> R.version
_
platform x86_64-apple-darwin13.4.0
arch x86_64
os darwin13.4.0
system x86_64, darwin13.4.0
status
major 3
minor 3.1
year 2016
month 06
day 21
svn rev 70800
language R
version.string R version 3.3.1 (2016-06-21)
nickname Bug in Your Hair
知道为什么这不起作用吗?
(根据评论更新)
适合我 ggalt_0.3.0.9000 scales_0.4.0 ggplot2_2.1.0
。
也许您需要 Github/devel 版本?尝试重新启动 session/unloading ggalt
,然后
devtools::install_github("hrbrmstr/ggalt")
并重新加载包。
我正在按照以下 link.
包ggalt
中有关如何使用 geom_lollipop
的教程进行操作
我正在尝试 运行 的代码如下:
df <- read.csv(text="category,pct
Other,0.09
South Asian/South Asian Americans,0.12
Interngenerational/Generational,0.21
S Asian/Asian Americans,0.25
Muslim Observance,0.29
Africa/Pan Africa/African Americans,0.34
Gender Equity,0.34
Disability Advocacy,0.49
European/European Americans,0.52
Veteran,0.54
Pacific Islander/Pacific Islander Americans,0.59
Non-Traditional Students,0.61
Religious Equity,0.64
Caribbean/Caribbean Americans,0.67
Latino/Latina,0.69
Middle Eastern Heritages and Traditions,0.73
Trans-racial Adoptee/Parent,0.76
LBGTQ/Ally,0.79
Mixed Race,0.80
Jewish Heritage/Observance,0.85
International Students,0.87", stringsAsFactors=FALSE, sep=",", header=TRUE)
library(ggplot2)
library(scales)
library(ggalt)
gg <- ggplot(df, aes(y=reorder(category, pct), x=pct))
gg <- gg + geom_lollipop(point.colour="steelblue", point.size=3, horizontal=TRUE)
gg <- gg + scale_x_continuous(expand=c(0,0), labels=percent,
breaks=seq(0, 1, by=0.2), limits=c(0, 1))
gg <- gg + labs(x=NULL, y=NULL,
title="SUNY Cortland Multicultural Alumni survey results")
gg <- gg + theme_minimal(base_family="Arial Narrow")
gg <- gg + theme(panel.grid.major.y=element_blank())
gg <- gg + theme(panel.grid.minor=element_blank())
gg <- gg + theme(axis.line.y=element_line(color="#2b2b2b", size=0.15))
gg <- gg + theme(axis.text.y=element_text(margin=margin(r=-5, l=0)))
gg <- gg + theme(plot.margin=unit(rep(30, 4), "pt"))
gg <- gg + theme(plot.title=element_text(face="bold"))
gg
我的输出不是创建棒棒糖图,而是如下:
geom_lollipop
似乎不起作用。此外,当我尝试数字 geom_lollipop 时,Rstudio 似乎没有在可用函数中找到它。
我以为是包版本的问题,但我已经更新了R并重新安装了上面所有的包。以下是正在使用的 R 和库的版本:
> packageVersion("ggalt")
[1] ‘0.1.1’
> packageVersion("ggplot2")
[1] ‘2.1.0’
> packageVersion("scales")
[1] ‘0.4.0’
> R.version
_
platform x86_64-apple-darwin13.4.0
arch x86_64
os darwin13.4.0
system x86_64, darwin13.4.0
status
major 3
minor 3.1
year 2016
month 06
day 21
svn rev 70800
language R
version.string R version 3.3.1 (2016-06-21)
nickname Bug in Your Hair
知道为什么这不起作用吗?
(根据评论更新)
适合我 ggalt_0.3.0.9000 scales_0.4.0 ggplot2_2.1.0
。
也许您需要 Github/devel 版本?尝试重新启动 session/unloading ggalt
,然后
devtools::install_github("hrbrmstr/ggalt")
并重新加载包。