相关疑难解决方法(0)

专家R用户,你的.Rprofile中有什么?

我总是发现其他人的启动配置文件对该语言既有用又有启发性.此外,虽然我有一些Bash和Vim的定制,但我没有R.

例如,我一直想要的一件事是窗口终端中输入和输出文本的不同颜色,甚至可能是语法高亮.

terminal customization r rprofile

266
推荐指数
24
解决办法
6万
查看次数

R中有用的小功能?

你写的功能是什么,不值得一个包,但你想分享?

我会投入一些我的:

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

34
推荐指数
5
解决办法
1万
查看次数

Sweave无法加载R包

我将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完成后会做出不同的事情.

有任何想法吗?

textmate r sweave

7
推荐指数
1
解决办法
423
查看次数

标签 统计

r ×3

customization ×1

rprofile ×1

sweave ×1

terminal ×1

textmate ×1