Most of you should know Gnu R, but only a few might heard about it’s .rc !
Just create the file .R.rc in your home directory, and R will parse it if you run it.
Some useful annotations:
There are to variables: `.First` and `.Last` . Assign a function to it and they are run at any start respectively quit of R.
On most screens R utilizes the width not effectively, either there is to much space left blank on the right side or the terminal breaks lines such that the output isn't readable anymore:
# too much white space right:>1:50[1]12345678910[11]11121314151617181920[21]21222324252627282930[31]31323334353637383940[41]41424344454647484950# to long lines so the terminal breaks them:>1:50[1]1234567891011121314151617181920212223242526272829303132333435363738394041424344[45]454647484950
So define the number of characters that can be presented in one line of your terminal at the start of R.:
options(width=236)
It's of course possible to define functions that you often need. I've two screens with different width, so I created two functions that readjust the line width if I move the terminal from one screen to the other:
So here is a part of my .R.rc to give you an example:
##################################### R.rc by Martin Scharm# copy to $HOME/.R.rc## for more informations visit:# http://binfalse.de####################################options(width=236,digits=7,show.error.messages="TRUE",warn=1)# freq used libslibrary(ggplot2)library(plyr)# aliasess<-base::summary;h<-utils::head;n<-base::names;# executed at startup and quit.First<-function()cat("\n Hey nice Guy! Have Fun!\n\n").Last<-function()cat("\n Goodbye!\n\n")# adjust line length depending on screen widthbigScreen<-function()options(width=236)smallScreen<-function()options(width=180)# shorten quit ("yes")bye<-function()quit("yes")################################### some frequently used functions #################################### calc faculty with f() and faculty()f=faculty=function(x)gamma(x+1)# find nth biggest element of a vectorbiggest=function(data,x=1)which(data==sort(data)[length(data)-x+1])# find nth smallest element of a vectorsmallest=function(data,x=1)which(data==sort(data)[x])
Leave a comment
There are multiple options to leave a comment: