Hey list! I have a csv-file with two variables: (Date,CMI) Date,CMI Jan-93,3.24 Feb-93,-2.56 . . . Dec-06, 8.25 When I want to plot this dataset, R is sorting the date in alphabetical order. Is there any way to tell R not to do it? I know it is probably an easy issue but I couldn't find a solution so far. I have seen so many tips already but can't apply it on my own dataset. Thank you very much! Stefan [[alternative HTML version deleted]]
Dear All, I want to extract the original dataset from a lm output. I know that I can get most of it from model.matrix(lm.out) but I need the dependent variable to be in the first column. Any ideas? Thanks, Kyle Roberts
Schreiber, Stefan <Stefan.Schreiber <at> ales.ualberta.ca> writes:> > Hey list! > > I have a csv-file with two variables: (Date,CMI) > > Date,CMI > Jan-93,3.24 > Feb-93,-2.56 > . > . > . > Dec-06, 8.25 > > When I want to plot this dataset, R is sorting the date in alphabetical > order. Is there any way to tell R not to do it? > > I know it is probably an easy issue but I couldn't find a solution so > far. I have seen so many tips already but can't apply it on my own > dataset. >R probably thinks your date column is a factor. try something like x$Date <- as.Date(paste("01",x$Date,sep="-"),fmt="%d-%b-%y") ?
Check out the zoo package: Lines <- "Date,CMI Jan-93,3.24 Feb-93,-2.56 Dec-06, 8.25" library(zoo) z <- read.zoo(textConnection(Lines), FUN = as.yearmon, format = "%b-%y", sep = ",", header = TRUE) plot(z) On Fri, Aug 15, 2008 at 1:12 PM, Schreiber, Stefan <Stefan.Schreiber at ales.ualberta.ca> wrote:> Hey list! > > I have a csv-file with two variables: (Date,CMI) > > Date,CMI > Jan-93,3.24 > Feb-93,-2.56 > . > . > . > Dec-06, 8.25 > > > When I want to plot this dataset, R is sorting the date in alphabetical > order. Is there any way to tell R not to do it? > > I know it is probably an easy issue but I couldn't find a solution so > far. I have seen so many tips already but can't apply it on my own > dataset. > > Thank you very much! > > Stefan > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
try this: x1 <- rnorm(30) x2 <- rnorm(30) x3 <- rnorm(30) y <- 0.5 + x1 - 2*x2 + 3*x3 + rnorm(30) fm <- lm(y ~ x1 + x2 + x3) model.frame(fm) I hope it helps. Best, Dimitris Roberts, Kyle wrote:> Dear All, > > I want to extract the original dataset from a lm output. I know that I > can get most of it from > > model.matrix(lm.out) > > but I need the dependent variable to be in the first column. Any ideas? > > Thanks, > Kyle Roberts > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://perswww.kuleuven.be/dimitris_rizopoulos/ Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
Look at the help page: Value: model: if requested (the default), the model frame used. The model frame is a data frame containing all the variables used to fit the model. On Fri, 15 Aug 2008, Roberts, Kyle wrote:> Dear All, > > I want to extract the original dataset from a lm output. I know that I > can get most of it from > > model.matrix(lm.out) > > but I need the dependent variable to be in the first column. Any ideas? > > Thanks, > Kyle Roberts > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.Please note what it says about doing your own homework. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595