你写的功能是什么,不值得一个包,但你想分享?
我会投入一些我的:
destring <- function(x) {
## convert factor to strings
if (is.character(x)) {
as.numeric(x)
} else if (is.factor(x)) {
as.numeric(levels(x))[x]
} else if (is.numeric(x)) {
x
} else {
stop("could not convert to numeric")
}
}
pad0 <- function(x,mx=NULL,fill=0) {
## pad numeric vars to strings of specified size
lx <- nchar(as.character(x))
mx.calc <- max(lx,na.rm=TRUE)
if (!is.null(mx)) {
if (mx<mx.calc) {
stop("number of maxchar is too small")
}
} else {
mx <- mx.calc
}
px <- mx-lx
paste(sapply(px,function(x) …Run Code Online (Sandbox Code Playgroud) 我将R升级到v2.14.0,随着升级,我决定将标准软件包存储库移至Dropbox,因此笔记本电脑和台式机始终处于同步状态.我设置我R_LIBS=/Dropbox/ToolBox/R/packages的.Renviron,当打开Rstudio或R.app(mac)时,我得到以下命令:
> Sys.getenv("R_LIBS")
[1] "/Dropbox/Toolbox/R/packages"
> .libPaths()
[1] "/Dropbox/Toolbox/R/packages"
[2] "/Library/Frameworks/R.framework/Versions/2.14/Resources/library"
[3] "/Applications/RStudio.app/Contents/Resources/R/library
Run Code Online (Sandbox Code Playgroud)
但是当我在.Snw(Textmate + Sweave)中运行相同的命令时,我得到:
> Sys.getenv("R_LIBS")
[1] ""
> .libPaths()
[1] "/Library/Frameworks/R.framework/Versions/2.14/Resources/library"
Run Code Online (Sandbox Code Playgroud)
正如你可以在上面看到,当我从Sweave调用R使得只挑选了标准repository.I创建Renviron.site,Rprofile.site阅读help(Startup)下面类似的问题Q1和Q2没有成功.
有人可以解释一下如何解决这个问题吗?
更新:当我从R中扫描我的.Snw时,它会选择所有正确的文件夹.我不确定为什么从textmate完成后会做出不同的事情.
有任何想法吗?