我总是发现其他人的创业简介文件对这门语言既有用又有指导意义。此外,虽然我对Bash和Vim进行了一些定制,但对R没有任何定制。
例如,我一直想要的一件事是在窗口终端中输入和输出文本的颜色不同,甚至可能是语法高亮显示。
我总是发现其他人的创业简介文件对这门语言既有用又有指导意义。此外,虽然我对Bash和Vim进行了一些定制,但对R没有任何定制。
例如,我一直想要的一件事是在窗口终端中输入和输出文本的颜色不同,甚至可能是语法高亮显示。
当前回答
这是我的。没什么太创新的。为什么要选择特定的选项:
I went with setting a default for stringsAsFactors because I find it extremely draining to pass it as an argument each time I read a CSV in. That said, it has already caused me some minor vexation when using code written on my usual computer on a computer which did not have my .Rprofile. I'm keeping it, though, as the troubles it has caused pale in comparison to the troubles not having it set everyday used to cause. If you don't load the utils package before options(error=recover), it cannot find recover when placed inside an interactive() block. I used .db for my dropbox setting rather than options(dropbox=...) because I use it all the time inside file.path and it saves much typing. The leading . keeps it from appearing with ls().
话不多说:
if(interactive()) {
options(stringsAsFactors=FALSE)
options(max.print=50)
options(repos="http://cran.mirrors.hoobly.com")
}
.db <- "~/Dropbox"
# `=` <- function(...) stop("Assignment by = disabled, use <- instead")
options(BingMapsKey="blahblahblah") # Used by taRifx.geo::geocode()
.First <- function() {
if(interactive()) {
require(functional)
require(taRifx)
require(taRifx.geo)
require(ggplot2)
require(foreign)
require(R.utils)
require(stringr)
require(reshape2)
require(devtools)
require(codetools)
require(testthat)
require(utils)
options(error=recover)
}
}
其他回答
我有这个,更动态的技巧来使用全终端宽度,它试图从COLUMNS环境变量中读取(在Linux上):
tryCatch(
{options(
width = as.integer(Sys.getenv("COLUMNS")))},
error = function(err) {
write("Can't get your terminal width. Put ``export COLUMNS'' in your \
.bashrc. Or something. Setting width to 120 chars",
stderr());
options(width=120)}
)
这样,即使您调整终端窗口的大小,R也将使用全宽度。
我发现两个函数是非常必要的:首先,当我在几个函数上设置debug()并且我已经解决了错误,所以我想要undebug()所有函数-而不是一个接一个。在这里添加的undebug_all()函数作为接受的答案是最好的。
其次,当我定义了许多函数并正在寻找一个特定的变量名时,很难在ls()的所有结果中找到它,包括函数名。这里发布的lsnofun()函数真的很好。
这是我的。它不会帮助你着色,但我从ESS和Emacs…
options("width"=160) # wide display with multiple monitors
options("digits.secs"=3) # show sub-second time stamps
r <- getOption("repos") # hard code the US repo for CRAN
r["CRAN"] <- "http://cran.us.r-project.org"
options(repos = r)
rm(r)
## put something this is your .Rprofile to customize the defaults
setHook(packageEvent("grDevices", "onLoad"),
function(...) grDevices::X11.options(width=8, height=8,
xpos=0, pointsize=10,
#type="nbcairo")) # Cairo device
#type="cairo")) # other Cairo dev
type="xlib")) # old default
## from the AER book by Zeileis and Kleiber
options(prompt="R> ", digits=4, show.signif.stars=FALSE)
options("pdfviewer"="okular") # on Linux, use okular as the pdf viewer
我的包括选项(menu.graphics=FALSE),因为我喜欢禁用/抑制tcltk弹出的CRAN镜像在R中选择。
我的大部分个人函数和加载的库都在rfunction中。r脚本
source("c:\\data\\rprojects\\functions\\Rfunctions.r")
.First <- function(){
cat("\n Rrrr! The statistics program for Pirates !\n\n")
}
.Last <- function(){
cat("\n Rrrr! Avast Ye, YO HO!\n\n")
}
#===============================================================
# Tinn-R: necessary packages
#===============================================================
library(utils)
necessary = c('svIDE', 'svIO', 'svSocket', 'R2HTML')
if(!all(necessary %in% installed.packages()[, 'Package']))
install.packages(c('SciViews', 'R2HTML'), dep = T)
options(IDE = 'C:/Tinn-R/bin/Tinn-R.exe')
options(use.DDE = T)
library(svIDE)
library(svIO)
library(svSocket)
library(R2HTML)
guiDDEInstall()
shell(paste("mkdir C:\\data\\rplots\\plottemp", gsub('-','',Sys.Date()), sep=""))
pldir <- paste("C:\\data\\rplots\\plottemp", gsub('-','',Sys.Date()), sep="")
plot.str <-c('savePlot(paste(pldir,script,"\\BeachSurveyFreq.pdf",sep=""),type="pdf")')