Hi all, Thanks for the help with my previous post. I have just two more questions for the minute. I think I said in a previous post that I like to use the terminal, i.e. run rterm.exe. On exiting the terminal, I am asked if I want to save the workspace. If I hit y (yes), the workspace is just saved as .rdata in my working directory, does anyone know how I can name it directly from the terminal? More importantly, I can't then open this file from the terminal. Obviously loading the file from windows explorer brings up the GUI. Anyone know the command I need? All I can think of doing is adding rterm.exe to my path and running it from the command prompt (adding the file as an argument to my command), but surely there is an easy way to do this from R? Of course I would like to have the terminal open and open and close various workspaces in one session, without wanting to restart R all the time. Finally, I rather embarrasingly can't get lm to work despite reading the help. I can get it to work with a single explanatory variable, EG model <- lm(data$admissions~data$maxitemp) but how to include a second explanatory variable (minitemp)? I keep getting errors. Surely I don't need to use c(data$maxitemp,data$minitemp) etc? All help greatly appreciated - I am getting there slowly! Robin Williams Met Office summer intern - Health Forecasting robin.williams@metoffice.gov.uk [[alternative HTML version deleted]]
lm(x~y+z) this should work- I think On Thu, Jul 24, 2008 at 7:01 AM, Williams, Robin < robin.williams@metoffice.gov.uk> wrote:> Hi all, > Thanks for the help with my previous post. > I have just two more questions for the minute. > I think I said in a previous post that I like to use the terminal, > i.e. run rterm.exe. On exiting the terminal, I am asked if I want to > save the workspace. If I hit y (yes), the workspace is just saved as > .rdata in my working directory, does anyone know how I can name it > directly from the terminal? > More importantly, I can't then open this file from the terminal. > Obviously loading the file from windows explorer brings up the GUI. > Anyone know the command I need? All I can think of doing is adding > rterm.exe to my path and running it from the command prompt (adding the > file as an argument to my command), but surely there is an easy way to > do this from R? Of course I would like to have the terminal open and > open and close various workspaces in one session, without wanting to > restart R all the time. > > Finally, I rather embarrasingly can't get lm to work despite reading > the help. I can get it to work with a single explanatory variable, EG > model <- lm(data$admissions~data$maxitemp) > but how to include a second explanatory variable (minitemp)? I keep > getting errors. Surely I don't need to use > c(data$maxitemp,data$minitemp) etc? > > All help greatly appreciated - I am getting there slowly! > > > Robin Williams > Met Office summer intern - Health Forecasting > robin.williams@metoffice.gov.uk > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. >-- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]]
Hi Robin,>> I ... can't get lm to work despite reading the help. I can get it to work >> with a single >> explanatory variable, EG model <- lm(data$admissions~data$maxitemp)I'll answer just the second of your questions. Advice: don't just read the help file, look at the examples and run them; look at how the calls are made. lm() and many other programs use (or can use) the ?formula interface, so learn how to use it. For your "example," rather do ## EGModel <- lm(admissions ~ maxitemp, data = data) where data is your data set (to avoid confusion call it something else, e.g. mydata). To add another variable/predictor, which should be in your data frame (for simplicity) called data, simply do EGModel <- lm(admissions ~ maxitemp+another.var, data = data) If your maxitemp(s) occur at different sites, then you might be interested in a nested model EGModel1 <- lm(admissions ~ site/maxitemp - 1, data = data) EGModel2 <- lm(admissions ~ site*maxitemp, data = data) ## alt. parameterization anova(EGModel1, EGModel2) anova(EGModel, EGModel1, EGModel2, test="Chi") This shows part of the power of using the formula interface. HTH, Mark. Williams, Robin wrote:> > Hi all, > Thanks for the help with my previous post. > I have just two more questions for the minute. > I think I said in a previous post that I like to use the terminal, > i.e. run rterm.exe. On exiting the terminal, I am asked if I want to > save the workspace. If I hit y (yes), the workspace is just saved as > .rdata in my working directory, does anyone know how I can name it > directly from the terminal? > More importantly, I can't then open this file from the terminal. > Obviously loading the file from windows explorer brings up the GUI. > Anyone know the command I need? All I can think of doing is adding > rterm.exe to my path and running it from the command prompt (adding the > file as an argument to my command), but surely there is an easy way to > do this from R? Of course I would like to have the terminal open and > open and close various workspaces in one session, without wanting to > restart R all the time. > > Finally, I rather embarrasingly can't get lm to work despite reading > the help. I can get it to work with a single explanatory variable, EG > model <- lm(data$admissions~data$maxitemp) > but how to include a second explanatory variable (minitemp)? I keep > getting errors. Surely I don't need to use > c(data$maxitemp,data$minitemp) etc? > > All help greatly appreciated - I am getting there slowly! > > > Robin Williams > Met Office summer intern - Health Forecasting > robin.williams at metoffice.gov.uk > > > > [[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. > >-- View this message in context: http://www.nabble.com/Just-2-more-questions---for-now%21-tp18629686p18630709.html Sent from the R help mailing list archive at Nabble.com.
On 7/24/2008 7:01 AM, Williams, Robin wrote:> Hi all, > Thanks for the help with my previous post. > I have just two more questions for the minute. > I think I said in a previous post that I like to use the terminal, > i.e. run rterm.exe. On exiting the terminal, I am asked if I want to > save the workspace. If I hit y (yes), the workspace is just saved as > .rdata in my working directory, does anyone know how I can name it > directly from the terminal? > More importantly, I can't then open this file from the terminal. > Obviously loading the file from windows explorer brings up the GUI. > Anyone know the command I need? All I can think of doing is adding > rterm.exe to my path and running it from the command prompt (adding the > file as an argument to my command), but surely there is an easy way to > do this from R? Of course I would like to have the terminal open and > open and close various workspaces in one session, without wanting to > restart R all the time.See save.image() and load(). You can automatically load one of these by listing it on the command line; this is how the shortcuts work, but it is undocumented. Duncan Murdoch> > Finally, I rather embarrasingly can't get lm to work despite reading > the help. I can get it to work with a single explanatory variable, EG > model <- lm(data$admissions~data$maxitemp) > but how to include a second explanatory variable (minitemp)? I keep > getting errors. Surely I don't need to use > c(data$maxitemp,data$minitemp) etc? > > All help greatly appreciated - I am getting there slowly! > > > Robin Williams > Met Office summer intern - Health Forecasting > robin.williams at metoffice.gov.uk > > > > [[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.
Q1: Have a look at: ?save ?save.image ?load Q2: I am not sure this is right: model<-lm(data$admissions~data$maxitemp) Try and code a line that looks more like this with the variables the names of the columns in your data: model<-lm(admissions ~ maxitemp + minitemp, data=data) Have a read of ?formula for more information. (I usually try and avoid using the name "data" for my data because data is a function in R.) Regards JS --- -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Williams, Robin Sent: 24 July 2008 12:02 To: r-help at r-project.org Subject: [R] Just 2 more questions - for now! Hi all, Thanks for the help with my previous post. I have just two more questions for the minute. I think I said in a previous post that I like to use the terminal, i.e. run rterm.exe. On exiting the terminal, I am asked if I want to save the workspace. If I hit y (yes), the workspace is just saved as .rdata in my working directory, does anyone know how I can name it directly from the terminal? More importantly, I can't then open this file from the terminal. Obviously loading the file from windows explorer brings up the GUI. Anyone know the command I need? All I can think of doing is adding rterm.exe to my path and running it from the command prompt (adding the file as an argument to my command), but surely there is an easy way to do this from R? Of course I would like to have the terminal open and open and close various workspaces in one session, without wanting to restart R all the time. Finally, I rather embarrasingly can't get lm to work despite reading the help. I can get it to work with a single explanatory variable, EG model <- lm(data$admissions~data$maxitemp) but how to include a second explanatory variable (minitemp)? I keep getting errors. Surely I don't need to use c(data$maxitemp,data$minitemp) etc? All help greatly appreciated - I am getting there slowly! Robin Williams Met Office summer intern - Health Forecasting robin.williams at metoffice.gov.uk [[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.