Re: [R] R question
On Fri, 2007-05-04 at 12:05 -0500, Bill Vorias wrote: I had a question about Random Forests. I have a text file with 10 dichotomous variables and a bivariate response vector. I read this file into R as a data frame, and then used the command randomForest(Response ~., dataset, etc.. where Response is the column header of the response variable and dataset is the name of the data frame. I get an error that says Response not found. I was looking at the Iris data example in the R help files, and it seems like this is exactly what they did. Do you have any suggestions? Thanks. R you sure that you have correctly specified the column and data frame names in the call to randomForest()? Be sure to check for typos, including capitalization. You can use: ls() to check for the current objects in your working environment and you can then use: str(YourDataFrame) or names(YourDataFrame) to display information about the detailed structure and/or column names, respectively, in the data frame that you created from the imported data. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch 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.
Re: [R] R question [Broadcast]
Bill, A couple more points: 1. Please use an informative subject line. I'd deleted the original post w/o reading if I didn't catch Marc's reply. 2. Are you sure you have bivariate response? To me bivariate means two variables, and randomForest surely does not handle that (at least for now). Andy From: Marc Schwartz On Fri, 2007-05-04 at 12:05 -0500, Bill Vorias wrote: I had a question about Random Forests. I have a text file with 10 dichotomous variables and a bivariate response vector. I read this file into R as a data frame, and then used the command randomForest(Response ~., dataset, etc.. where Response is the column header of the response variable and dataset is the name of the data frame. I get an error that says Response not found. I was looking at the Iris data example in the R help files, and it seems like this is exactly what they did. Do you have any suggestions? Thanks. R you sure that you have correctly specified the column and data frame names in the call to randomForest()? Be sure to check for typos, including capitalization. You can use: ls() to check for the current objects in your working environment and you can then use: str(YourDataFrame) or names(YourDataFrame) to display information about the detailed structure and/or column names, respectively, in the data frame that you created from the imported data. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch 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. -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ R-help@stat.math.ethz.ch 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.
Re: [R] R-question
Thorsten Muehge wrote: Hello Colleagues, I programmed in SAS for 3 years and would like to switch to a not so costly software product. Hence I started to evaluate R, and my first test look promising. However I have some question: 1. Is it possible to query R files by SQL internally on data frames (not on a database) and how is the syntax (I have the RODBC package installed). I would like to extract year, Quarter, week, from a date column in a data frame (see attachment). After this I want to attach the column to the original data frame. How do I do this in R? Hi Thorsten, You may just want to convert the dates as follows, adding them to the data frame on the fly: test.df-data.frame(dates=as.POSIXlt(c(2004-05-13,2005-07-23,2006-09-13)), nums=rnorm(3)) test.df$years-format(test.df$dates,%Y) test.df$quarters-floor((as.numeric(format(test.df$dates,%m))-1)/3)+1 test.df$week-format(test.df$dates,%U) test.df Jim __ R-help@stat.math.ethz.ch 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.
Re: [R] R-question
Thorsten Muehge MUEHGE at de.ibm.com writes: 1. Is it possible to query R files by SQL internally on data frames (not on a database) and how is the syntax (I have the RODBC package installed). It is possible to do similar things conceptually in R as in SQL---at least the basic SQL queries (I have not tried others). Unlike SQL, R retains the sort order. So far as I know you can not use SQL code to query R data-frames. But you can put SQL code in a .R file and use RODBC or ODBC (I have used this) to send SQL queries to database; you can also get the results from SQL queries back to R as R objects. __ R-help@stat.math.ethz.ch 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.
Re: [R] R-question
For your 1st question, you can write query against the tables in DB using RODBC. Being a SAS programmer, I have to say that reporting function of R is not as good as that of SAS. On 9/13/06, Thorsten Muehge [EMAIL PROTECTED] wrote: Hello Colleagues, I programmed in SAS for 3 years and would like to switch to a not so costly software product. Hence I started to evaluate R, and my first test look promising. However I have some question: 1. Is it possible to query R files by SQL internally on data frames (not on a database) and how is the syntax (I have the RODBC package installed). I would like to extract year, Quarter, week, from a date column in a data frame (see attachment). After this I want to attach the column to the original data frame. How do I do this in R? Dr .Th.Mühge, PMP(r) Procurement Technology Center IBM Deutschland GmbH, Hechtsheimer Str.2, D-55131 Mainz Phone: xx49-(0)6131-84-2416 Mobile: xx49-(0)15117457978 e-mail: [EMAIL PROTECTED] (See attached file: Debug1.csv) __ R-help@stat.math.ethz.ch 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 (http://spaces.msn.com/statcompute/blog) Senior Decision Support Analyst Health Policy and Clinical Effectiveness Cincinnati Children Hospital Medical Center __ R-help@stat.math.ethz.ch 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.
Re: [R] R-question
Wensui Liu wrote: For your 1st question, you can write query against the tables in DB using RODBC. Being a SAS programmer, I have to say that reporting function of R is not as good as that of SAS. I beg to differ. See for example http://biostat.mc.vanderbilt.edu/StatReport Frank Harrell On 9/13/06, Thorsten Muehge [EMAIL PROTECTED] wrote: Hello Colleagues, I programmed in SAS for 3 years and would like to switch to a not so costly software product. Hence I started to evaluate R, and my first test look promising. However I have some question: 1. Is it possible to query R files by SQL internally on data frames (not on a database) and how is the syntax (I have the RODBC package installed). I would like to extract year, Quarter, week, from a date column in a data frame (see attachment). After this I want to attach the column to the original data frame. How do I do this in R? Dr .Th.Mühge, PMP(r) Procurement Technology Center IBM Deutschland GmbH, Hechtsheimer Str.2, D-55131 Mainz Phone: xx49-(0)6131-84-2416 Mobile: xx49-(0)15117457978 e-mail: [EMAIL PROTECTED] (See attached file: Debug1.csv) __ R-help@stat.math.ethz.ch 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. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch 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.
Re: [R] R-question
well, Harrell, I understand sweave or R2html could be a solution. but please show me their applications in a large business setting. On the contrary, I can give you many such cases using SAS. On 9/13/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote: Wensui Liu wrote: For your 1st question, you can write query against the tables in DB using RODBC. Being a SAS programmer, I have to say that reporting function of R is not as good as that of SAS. I beg to differ. See for example http://biostat.mc.vanderbilt.edu/StatReport Frank Harrell On 9/13/06, Thorsten Muehge [EMAIL PROTECTED] wrote: Hello Colleagues, I programmed in SAS for 3 years and would like to switch to a not so costly software product. Hence I started to evaluate R, and my first test look promising. However I have some question: 1. Is it possible to query R files by SQL internally on data frames (not on a database) and how is the syntax (I have the RODBC package installed). I would like to extract year, Quarter, week, from a date column in a data frame (see attachment). After this I want to attach the column to the original data frame. How do I do this in R? Dr .Th.Mühge, PMP(r) Procurement Technology Center IBM Deutschland GmbH, Hechtsheimer Str.2, D-55131 Mainz Phone: xx49-(0)6131-84-2416 Mobile: xx49-(0)15117457978 e-mail: [EMAIL PROTECTED] (See attached file: Debug1.csv) __ R-help@stat.math.ethz.ch 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. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University -- WenSui Liu (http://spaces.msn.com/statcompute/blog) Senior Decision Support Analyst Health Policy and Clinical Effectiveness Cincinnati Children Hospital Medical Center __ R-help@stat.math.ethz.ch 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.
Re: [R] R-question
Wensui Liu wrote: well, Harrell, I understand sweave or R2html could be a solution. but please show me their applications in a large business setting. On the contrary, I can give you many such cases using SAS. SAS requires much more coding than R/S-Plus to produce reports that are not nearly as beautiful or informative. Please define 'large business setting'. R is being used routinely in many large businesses. Frank On 9/13/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote: Wensui Liu wrote: For your 1st question, you can write query against the tables in DB using RODBC. Being a SAS programmer, I have to say that reporting function of R is not as good as that of SAS. I beg to differ. See for example http://biostat.mc.vanderbilt.edu/StatReport Frank Harrell On 9/13/06, Thorsten Muehge [EMAIL PROTECTED] wrote: Hello Colleagues, I programmed in SAS for 3 years and would like to switch to a not so costly software product. Hence I started to evaluate R, and my first test look promising. However I have some question: 1. Is it possible to query R files by SQL internally on data frames (not on a database) and how is the syntax (I have the RODBC package installed). I would like to extract year, Quarter, week, from a date column in a data frame (see attachment). After this I want to attach the column to the original data frame. How do I do this in R? Dr .Th.Mühge, PMP(r) Procurement Technology Center IBM Deutschland GmbH, Hechtsheimer Str.2, D-55131 Mainz Phone: xx49-(0)6131-84-2416 Mobile: xx49-(0)15117457978 e-mail: [EMAIL PROTECTED] (See attached file: Debug1.csv) -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch 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.
Re: [R] R-question
I don't believe that doing a direct SQL query on a native R object is currently possible, others have pointed out ways to do some of the things you would want SQL for using built-in R commands. If you really want to use SQL you could transfer the data frames you want to use to database tables, then query those and return the result. You may want to look at the RSQLite and SQLiteDF packages that would help with these steps without requiring any database setup outside of R. It probably not be too much work to write a function that would take an SQL query as a string and a list of data frames as arguments, copy the data frames to SQLite tables (SQLiteDF function sql.data.frame does this), then submit the query on those data frames (using RSQLite package) and return the result. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thorsten Muehge Sent: Wednesday, September 13, 2006 4:18 AM To: r-help@stat.math.ethz.ch Subject: [R] R-question Hello Colleagues, I programmed in SAS for 3 years and would like to switch to a not so costly software product. Hence I started to evaluate R, and my first test look promising. However I have some question: 1. Is it possible to query R files by SQL internally on data frames (not on a database) and how is the syntax (I have the RODBC package installed). I would like to extract year, Quarter, week, from a date column in a data frame (see attachment). After this I want to attach the column to the original data frame. How do I do this in R? Dr .Th.Mühge, PMP® Procurement Technology Center IBM Deutschland GmbH, Hechtsheimer Str.2, D-55131 Mainz Phone: xx49-(0)6131-84-2416 Mobile: xx49-(0)15117457978 e-mail: [EMAIL PROTECTED] (See attached file: Debug1.csv) __ R-help@stat.math.ethz.ch 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.
Re: [R] r question
Please, 1. read the posting guide 2. use a sensible subject line 3. this is NOT an r question 4. ask your teacher to explain your homeworks, but not this list Uwe Ligges yuying shi wrote: If there are two random variable X1 and X2 which have a bivariate normal distribution with mean vector (10, 10)and variance covariance matrix [21.95 1.953] How to calculate the mean and variance of the function Y=X1/X2? Thanks a lot! xingyu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] r question
Uwe Ligges [EMAIL PROTECTED] writes: Please, 1. read the posting guide 2. use a sensible subject line 3. this is NOT an r question 4. ask your teacher to explain your homeworks, but not this list Uwe Ligges And, btw, neither the mean nor the variance exists, so the question is incomplete, and any answer approximate. yuying shi wrote: If there are two random variable X1 and X2 which have a bivariate normal distribution with mean vector (10, 10)and variance covariance matrix [21.95 1.953] How to calculate the mean and variance of the function Y=X1/X2? Thanks a lot! xingyu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 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 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R question
house-ball wrote: Why do you repeat an unclear question fou times? Please read the posting guide. It is not clear what is your problem. Kjetil halvorsen Hi, Would you help me solve the following question? Thanks. my program is as follows: library(mvtnorm) value-pmvnorm(lower=-Inf, upper=-2.178, mean=0, sigma=1)+ pmvnorm(lower=2.178, upper=Inf, mean=0, sigma=1)+ pmvnorm(lower=c(-2.178,-Inf),upper=c(2.178,-2.178),mean=0,corr=diag(2)*sqrt(0.5))+ pmvnorm(lower=c(-2.178,2.178),upper=c(2.178,Inf),mean=0,corr=diag(2)*sqrt(0.5)) value [1] 0.05794736 Now if I try to set the probability=0.05 and find the approximate critical value. (The answer should be somewhere between 2.1782 and 2.1783.) I write about this R program as follows but I don¡¦t know how to get the value of x which is between 2.1782 and 2.1783. Would you check out what¡¦s a problem with my program ? Thanks. library(mvtnorm) value-array(1000) a-array(1000) a-seq(2,3,by=0.001) for(i in 1000) { x-a[i] value[i]-2*(pmvnorm(lower=-Inf, upper=-x, mean=0, sigma=1)+ pmvnorm(lower=c(-x,-Inf),upper=c(x,-x),mean=0,corr=diag(2)*sqrt(0.5))) if(value[i]-0.050.001) print(x) } Chia-Yi - Yahoo!©_¼¯Messenger6.0 [EMAIL PROTECTED] ¥ß§Y¤U¸ü§ó·s³Ì·sª©¡I [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Kjetil Halvorsen. Peace is the most effective weapon of mass construction. -- Mahdi Elmandjra __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R question
house-ball wrote: Hi, Would you help me solve the following question? Thanks. Question: If I try to set the probability=0.05 and find the approximate x. (The answer should be somewhere between 2.1782 and 2.1783.) I write about this R program as follows but I don¡¦t know how to get the value of x which is between 2.1782 and 2.1783. First, you should probably read An Introduction to R which comes with your R-installation. As posed your question is ambiguous, but assuming you mean to say normal distribution, you need something like qnorm(0.05) or if you mean probability in the upper tail qnorm(0.05, lower.tail=FALSE) Then read ?qnorm Kjetil halvorsen library(mvtnorm) value-array(1000) a-array(1000) a-seq(2,3,by=0.001) for(i in 1000) { x-a[i] value[i]-2*(pmvnorm(lower=-Inf, upper=-x, mean=0, sigma=1)+ pmvnorm(lower=c(-x,-Inf),upper=c(x,-x),mean=0,corr=diag(2)*sqrt(0.5))) if(value[i]-0.050.001) print(x) } - Yahoo!©_¼¯Messenger6.0 [EMAIL PROTECTED] ¥ß§Y¤U¸ü§ó·s³Ì·sª©¡I [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Kjetil Halvorsen. Peace is the most effective weapon of mass construction. -- Mahdi Elmandjra __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: Data Frame (was: Re: [R] r-question
Have you read ?data? hope this helps. spencer graves Ko-Kang Kevin Wang wrote: (Please use a more meaningful subject) Can you be more specific with your question? Do you want to access an example data set and if so, which one? Or do you want to create a data frame within R? Or do you want to read in a data set as a data frame from an external package? On Sat, 12 Jul 2003, dg gdf wrote: Date: Sat, 12 Jul 2003 22:09:59 -0700 (PDT) From: dg gdf [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [R] r-question I am student in Iran(IUT) that work on R software as my project. I need to some data frames in version 1.7.0, but these are not available. please help me. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] r-question
At 10:09 PM 7/12/2003, dg gdf wrote: I am student in Iran(IUT) that work on R software as my project. I need to some data frames in version 1.7.0, but these are not available. please help me. __ It isn't clear exactly what help you need. We are most apt to be able to help if you can formulate a precise question. Unfortunately, you haven't asked a question that anyone here can answer. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help