Folks, Two simple questions : (1) I have a data set (call it data.xls) in a folder in my hard drive. How do I perform a simple regression between two variables from that data set? After I click on 'R', what exactly do I type in? (2) Where do I get to see the complete library of packages offered by R? In particular, I am interested in quantile regression and logistic regression. Thanks. Sitadri This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender. All incoming and outgoing e-mail messages are stored in the Swiss Re Electronic Message Repository. If you do not wish the retention of potentially private e-mails by Swiss Re, we strongly advise you not to use the Swiss Re e-mail account for any private, non-business related communications. [[alternative HTML version deleted]]
1) there are many ways to read data from excel into R, such as rodbc package. 2) check cran, or do a r search. On Jan 9, 2008 4:35 PM, <Sitadri_Bagchi at swissre.com> wrote:> Folks, Two simple questions : > > (1) I have a data set (call it data.xls) in a folder in my hard drive. How > do I perform a simple regression between two variables from that data set? > After I click on 'R', what exactly do I type in? > > (2) Where do I get to see the complete library of packages offered by R? > In particular, I am interested in quantile regression and logistic > regression. > > Thanks. > > Sitadri > > > > > This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender. > All incoming and outgoing e-mail messages are stored in the Swiss Re Electronic Message Repository. If you do not wish the retention of potentially private e-mails by Swiss Re, we strongly advise you not to use the Swiss Re e-mail account for any private, non-business related communications. > [[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. >-- ==============================WenSui Liu Statistical Project Manager ChoicePoint Precision Marketing (http://spaces.msn.com/statcompute/blog)
Hi, please have a look at the posting guide (link is at the bottom of your message). Most (if not all) of your problems should be solved if you follow the advice given there. Anyway, please have a look below: Sitadri_Bagchi at swissre.com wrote:> Folks, Two simple questions : > > (1) I have a data set (call it data.xls) in a folder in my hard drive. How > do I perform a simple regression between two variables from that data set? > After I click on 'R', what exactly do I type in?1.1 getting excel data into R - please read the manual R Data Import/Export shipped with your R distribution or browse online, for example, at http://cran.r-project.org/doc/manuals/R-data.html in particular http://cran.r-project.org/doc/manuals/R-data.html#Reading-Excel-spreadsheets - I prefer to use rather CSV files which can be easily read by R using read.table() 1.2 simple regression - function lm() is your friend - furthermore have a look at "An Introduction to R", in particular Section 11.2 http://cran.r-project.org/doc/manuals/R-intro.html#Linear-models Maybe this code gets you started (not tested, modify according to your application): mydata <- read.table("C:\\mypath\\tomyfile\\data.csv", header=TRUE, sep=",") mymodel1 <- lm(mydata$Y ~ mydata$X) mymodel1 summary(mymodel1)> > (2) Where do I get to see the complete library of packages offered by R?One possibility is http://stat.ethz.ch/CRAN/src/contrib/PACKAGES.html> In particular, I am interested in quantile regression and logistic > regression.- There is a package called quantreg written by Roger Koenker. - Logistic regression: check the function glm() Hope this helps you to get started, Roland> > ______________________________________________ > 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. >
Sitadri_Bagchi at swissre.com wrote:> Folks, Two simple questions : > > (1) I have a data set (call it data.xls) in a folder in my hard drive. How > do I perform a simple regression between two variables from that data set? > After I click on 'R', what exactly do I type in? > >Ideally, you shouldn't really start from there (because transfer of data between different applications is not for beginners -- it is better to have your data in a text file with a well-defined format), but let's try: a) Open the spreadsheet. Make sure that the 1st element of each column has the name of the variable. Let us assume that the 2 relevant ones are called "x" and "y". Highlight the relevant region and copy to clipboard. b) In R type mydata <- read.delim2("clipboard") names(y) plot(y~x, data=mydata) summary(lm(y~x, data=mydata)) This assumes that you are using a German locale (comma is decimal separator), otherwise use read.delim("clipboard").> (2) Where do I get to see the complete library of packages offered by R? > In particular, I am interested in quantile regression and logistic > regression. > > Thanks. > > Sitadri > >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Sitadri, What operating system are you using? Have you loaded R onto you computer? If not I suggest you do so. You can than enter the command ?lm which will give you information about lm command, the command used to perform linear regresssion. I would also suggest that you go to http://cran.r-project.org/doc/manuals/R-intro.html and do some reading of the introduction document. Once you have done this you should be able to get started using R and will be able to ask a question that we can more easily answer. John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC, University of Maryland School of Medicine Claude D. Pepper OAIC, University of Maryland Clinical Nutrition Research Unit, and Baltimore VA Center Stroke of Excellence University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) jsorkin at grecc.umaryland.edu>>> <Sitadri_Bagchi at swissre.com> 01/09/08 4:35 PM >>>Folks, Two simple questions : (1) I have a data set (call it data.xls) in a folder in my hard drive. How do I perform a simple regression between two variables from that data set? After I click on 'R', what exactly do I type in? (2) Where do I get to see the complete library of packages offered by R? In particular, I am interested in quantile regression and logistic regression. Thanks. Sitadri This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender. All incoming and outgoing e-mail messages are stored in the Swiss Re Electronic Message Repository. If you do not wish the retention of potentially private e-mails by Swiss Re, we strongly advise you not to use the Swiss Re e-mail account for any private, non-business related communications. [[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. Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}}
Sitadri, I would also look at http://www.math.ilstu.edu/dhkim/Rstuff/Rtutor.html a site that was pointed out in a recent posting to the listserve by John Kane. John Sitadri, What operating system are you using? Have you loaded R onto you computer? If not I suggest you do so. You can than enter the command ?lm which will give you information about lm command, the command used to perform linear regresssion. I would also suggest that you go to http://cran.r-project.org/doc/manuals/R-intro.html and do some reading of the introduction document. Once you have done this you should be able to get started using R and will be able to ask a question that we can more easily answer. John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC, University of Maryland School of Medicine Claude D. Pepper OAIC, University of Maryland Clinical Nutrition Research Unit, and Baltimore VA Center Stroke of Excellence University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) jsorkin at grecc.umaryland.edu>>> <Sitadri_Bagchi at swissre.com> 01/09/08 4:35 PM >>>Folks, Two simple questions : (1) I have a data set (call it data.xls) in a folder in my hard drive. How do I perform a simple regression between two variables from that data set? After I click on 'R', what exactly do I type in? (2) Where do I get to see the complete library of packages offered by R? In particular, I am interested in quantile regression and logistic regression. Thanks. Sitadri This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender. All incoming and outgoing e-mail messages are stored in the Swiss Re Electronic Message Repository. If you do not wish the retention of potentially private e-mails by Swiss Re, we strongly advise you not to use the Swiss Re e-mail account for any private, non-business related communications. [[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. Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}}
--- Sitadri_Bagchi at swissre.com wrote:> (2) Where do I get to see the complete library of > packages offered by R? > In particular, I am interested in quantile > regression and logistic > regression.R webpage > CRAN > Packages link. Also have a look at the Task Views on the CRAN page.