1

Possible Duplicate:
Expert R users, what’s in your .Rprofile?

Probably a quiet stupid question, but I cannot manage to change the options in my Rprofile:

.First <- function(){
 options(width=140)
 library(ggplot2)
 library(fPortfolio)
 library(reshape2)
 library(plyr)
 library(plm)
 library(XLConnect)
 library(scales)
 library(lattice)
 library(sos)
 library(car)
 library(fmsb)
 library(reshape)
 library(gridExtra)
 library(rpanel)
 library(psych)
 library(fUnitRoots)
 library(googleVis)
 library(rattle)
 library(gplots)
 library(RODBC)
 library(fGarch)
 library(RcppArmadillo)
 library(fmsb)
 library(forecast)
 library(playwith)
###names 
 n <- function(df) matrix(names(df)) 
##head tail 
 ht <- function(d) rbind(head(d,10),tail(d,10)) 

 ###Missing values 
 propmiss <- function(dataframe) {
    m <- sapply(dataframe, function(x) {
        data.frame(
            nmiss=sum(is.na(x)), 
            n=length(x), 
            propmiss=sum(is.na(x))/length(x)
        )
    })
    d <- data.frame(t(m))
    d <- sapply(d, unlist)
    d <- as.data.frame(d)
    d$variable <- row.names(d)
    row.names(d) <- NULL
    d <- cbind(d[ncol(d)],d[-ncol(d)])
    return(d[order(d$propmiss), ])
}


}

 cat("\nNu kör vi!", date(), "\n") 


.Last <- function(){ 
 cat("\nDags att ta det lite lugnt! ", date(), "\n")
}

In my Rprofile above I want to change options(width=140) but it doesn't work. Also, I can't manage to get the function ht and propmiss to be loaded by the Rprofile. Any suggestions?

Best Regards

Community
  • 1
  • 1
user1665355
  • 3,324
  • 8
  • 44
  • 84
  • 3
    Quiet stupid questions are fine by me – mdsumner Jan 23 '13 at 10:01
  • Hehe...I dont know why the `options(width=140)` is not changed. When I start up Rstudio `options()$width=160` :( – user1665355 Jan 23 '13 at 10:05
  • 3
    I don' think all those calls you made (the call to `options`, the libraries loading or the function definitions) need to be inside a `.First` function. They will be called on startup anyhow as long as they are in your Rprofile (see [this faq question](http://stackoverflow.com/questions/1189759/expert-r-users-whats-in-your-rprofile) for some examples). – plannapus Jan 23 '13 at 10:19
  • 2
    plannapus is correct (as you confirmed), but as a general piece of advice, you can run into conflicts loading that many packages as a routine, especially if you plan to make your own packages. I've found it is better to go lean, and just load the smallest list you can (and load the others as you need them in a given session). Plus, you've got some redundancies: when you load ggplot2 you get 3 or 4 of the others at the same time. – Bryan Hanson Jan 23 '13 at 12:23
  • I consider this to be a duplicate. Search for `[r] profile startup` for more. – Dirk Eddelbuettel Jan 23 '13 at 12:56

0 Answers0