我正在尝试安装最新dplyr版本(版本0.4.1).但是,每次尝试install.packages("dplyr")超过几天都会导致安装0.2版本.
> install.packages("dplyr")
Installing package into ‘C:/Users/Ricky/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://mran.revolutionanalytics.com/snapshot/2014-10-01/bin/windows/contrib/3.1/dplyr_0.2.zip'
Content type 'application/zip' length 2235535 bytes (2.1 Mb)
opened URL
downloaded 2.1 Mb
Run Code Online (Sandbox Code Playgroud)
有什么步骤我不见了吗?这是Revolution Analytics用户特有的吗?
使用时下面的会话信息.
> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_Singapore.1252 LC_CTYPE=English_Singapore.1252 LC_MONETARY=English_Singapore.1252
[4] LC_NUMERIC=C LC_TIME=English_Singapore.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_1.6
loaded via a namespace (and not attached):
[1] tools_3.1.1
Run Code Online (Sandbox Code Playgroud)
编辑: .libPaths()添加输出
> …Run Code Online (Sandbox Code Playgroud) 假设我想要一个向量的子集a,我可以将索引的值传递给变量中的子集,例如a[idx].
我应该设置什么值idx来获得相当于获得整体a(即a[])?
基本上我有一个函数idx作为参数,并希望传递一个值来处理整个数据集.我假设应该有更好的东西1:length(a).
我试图在R中使用正则表达式替换字符向量中的一些文本,其中如果括号内有一组字母,则括号内容将替换整个内容.所以给出了输入
tst <- c("85", "86 (TBA)", "87 (LAST)")
Run Code Online (Sandbox Code Playgroud)
我想要的输出相当于 c("85", "TBA", "LAST")
我试过gsub("\\(([[:alpha:]])\\)", "\\1", tst)但它没有取代任何东西.在这里我的正则表达式需要纠正什么?
我想创建一个水平直方图,并使用调整图表的纵横比ggplot2。
例如,假设我的图表是dia <- ggplot(diamonds, aes(x=color)) + geom_bar()。
我可以使用将其翻转为水平dia + coord_flip()。
我也可以调整长宽比,例如dia + coord_fixed(ratio=.001)。
但是当我合并它们时dia + coord_flip()+ coord_fixed(ratio=.001),图表不再是水平的。
有什么方法可以实现我想要的功能ggplot2吗?
如何在ggplot条形图中的每个条形图上添加一条线?
例如,使用内置的ggplot示例:
mm <- ddply(mtcars, "cyl", summarise, mmpg = mean(mpg))
ggplot(mm, aes(x = factor(cyl), y = mmpg)) + geom_bar(stat = "identity")
Run Code Online (Sandbox Code Playgroud)
产生这个
现在我有一个向量y <- c(10, 5, 5),这是我想在每个条上绘制一条线的高度,产生这样的东西
我该怎么做?我尝试过geom_hline,但是会产生横跨整个图表的线条.
我想避免删除停用词,但我发现无论参数设置如何tm,总是删除一些停用词.
library(tm)
documents <- c("This is a list containing the tallest buildings in San Francisco")
corpus <- Corpus(VectorSource(documents))
matrix <- DocumentTermMatrix(corpus,control=list(stopwords=FALSE))
colnames(matrix)
# [1] "buildings" "containing" "francisco" "list" "san"
# [6] "tallest" "the" "this"
Run Code Online (Sandbox Code Playgroud)
DocumentTermMatrix 似乎删除了"是"和"在"中的停用词.
我怎么能避免这个?设置stopwords=TRUE仅阻止删除"the".我怎样才能防止删除"是"和"进入"?
r ×6
ggplot2 ×2
bar-chart ×1
dplyr ×1
installation ×1
regex ×1
revolution-r ×1
stop-words ×1
subset ×1
tm ×1