Natalie O'Toole
2008-Oct-21 17:20 UTC
[R] code works in R desktop but not iin RWeb - How do I modify to get it working in RWeb, please?
Hi, How are you? I have a quick question.... I have code that works perfectly with R desktop, but does not work with RWeb. Could you please tell me how to modify the code below so it will work with RWeb? #Read in txt file happyguys<-read.table("c:/test8.txt", header=TRUE, row.names=1) #Subset the txt file to only include certain values test<-subset(happyguys, GRADE == 7 & Y_Q10A < 9) #print the subset file print(test) mydata<-test #Sort the data by province, and then by Y_Q10A mydataSorted<-mydata[ order(mydata$PROV,mydata$Y_Q10A), ] print(mydataSorted) #Weight the data and aggregate the value by province. There are 2 values for each province (1 & 2) and the results show the number of people for each province who responded with value 1 or value 2 myag<-aggregate(mydataSorted$WTPP, by=list(mydataSorted$PROV,mydataSorted$Y_Q10A), FUN=sum, na.rm=TRUE) #print the aggregated results print(myag) #Results below Group.1 Group.2 x 1 10 1 466.2879 2 11 1 104.7425 3 12 1 1200.9314 4 13 1 888.4311 5 24 1 29040.8215 6 35 1 8876.2489 7 46 1 1381.7473 8 47 1 1508.7270 9 48 1 3293.6757 10 59 1 4247.5155 11 10 2 6623.7504 12 11 2 1954.9129 13 12 2 11399.5767 14 13 2 8811.8096 15 24 2 77222.4561 16 35 2 145528.7134 17 46 2 14010.4974 18 47 2 12335.5400 19 48 2 41137.2036 20 59 2 46261.5873 Thanks, Nat ------------------------------------------------------------------------------------------------------------------------ This communication is intended for the use of the recipi...{{dropped:24}}
Yihui Xie
2008-Oct-22 05:11 UTC
[R] code works in R desktop but not iin RWeb - How do I modify to get it working in RWeb, please?
"c:/test8.txt" is in *your* local disk, so Rweb cannot read the data file! You should submit your data to Rweb using the button "Browse" which will "Select a local file to submit". Note the name of the data variable will be 'X' (instead of your 'happyguys'). Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China On Wed, Oct 22, 2008 at 1:20 AM, Natalie O'Toole <notoole at mtroyal.ca> wrote:> Hi, > > How are you? I have a quick question.... I have code that works perfectly > with R desktop, but does not work with RWeb. Could you please tell me how > to modify the code below so it will work with RWeb? > > > #Read in txt file > > happyguys<-read.table("c:/test8.txt", header=TRUE, row.names=1) > > #Subset the txt file to only include certain values > > test<-subset(happyguys, GRADE == 7 & Y_Q10A < 9) > > #print the subset file > > print(test) > > mydata<-test > > #Sort the data by province, and then by Y_Q10A > > mydataSorted<-mydata[ order(mydata$PROV,mydata$Y_Q10A), ] > print(mydataSorted) > > #Weight the data and aggregate the value by province. There are 2 values > for each province (1 & 2) and the results show the number of people for > each province who responded with value 1 or value 2 > > myag<-aggregate(mydataSorted$WTPP, > by=list(mydataSorted$PROV,mydataSorted$Y_Q10A), FUN=sum, na.rm=TRUE) > > #print the aggregated results > > print(myag) > > #Results below > > Group.1 Group.2 x > 1 10 1 466.2879 > 2 11 1 104.7425 > 3 12 1 1200.9314 > 4 13 1 888.4311 > 5 24 1 29040.8215 > 6 35 1 8876.2489 > 7 46 1 1381.7473 > 8 47 1 1508.7270 > 9 48 1 3293.6757 > 10 59 1 4247.5155 > 11 10 2 6623.7504 > 12 11 2 1954.9129 > 13 12 2 11399.5767 > 14 13 2 8811.8096 > 15 24 2 77222.4561 > 16 35 2 145528.7134 > 17 46 2 14010.4974 > 18 47 2 12335.5400 > 19 48 2 41137.2036 > 20 59 2 46261.5873 > > > > Thanks, > > Nat > > > ------------------------------------------------------------------------------------------------------------------------ > > This communication is intended for the use of the recipi...{{dropped:24}} > > ______________________________________________ > 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. >
Natalie O'Toole
2008-Oct-22 15:15 UTC
[R] code works in R desktop but not iin RWeb - How do I modify to get it working in RWeb, please?
Hi Yihui, Thank-you for this information. This is the code I am entering into RWeb after loading my data file: #subset the file to only include certain values: test<-subset(X, GRADE == 7 & Y_Q10A < 9) #sort the data by province and the variable Y_Q10A mydata<-test mydataSorted<-mydata[ order(mydata$PROV,mydata$Y_Q10A), ] #Weight the data and aggregate it by province and Y_Q10A myag<-aggregate(mydataSorted$WTPP, by=list(mydataSorted$PROV,mydataSorted$Y_Q10A), FUN=sum, na.rm=TRUE) #print the aggregated data print(myag) _ This does not work. RWeb does not show any results. Here is the response I am getting from RWeb: Rweb:> postscript(file= "/tmp/Rout.11012.%03d.ps", onefile=FALSE) Rweb:> X <- read.table("/tmp/Rdata.11012.data", header=T) Rweb:> attach(X) Rweb:> names(X) [1] "PUMFID" "PROV" "REGION" "GRADE" "Y.Q10A" "WTPP" Rweb:> Rweb:> Rweb:> test<-subset(X, PROV==48 & GRADE == 7 & Y_Q10A < 9) How can I modify my code above to get it to work in RWeb, please? Thanks, Nat _________________ "c:/test8.txt" is in *your* local disk, so Rweb cannot read the data file! You should submit your data to Rweb using the button "Browse" which will "Select a local file to submit". Note the name of the data variable will be 'X' (instead of your 'happyguys'). Regards, Yihui -- Yihui Xie <xieyihui@gmail.com> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China On Wed, Oct 22, 2008 at 1:20 AM, Natalie O'Toole <notoole@mtroyal.ca> wrote:> Hi, > > How are you? I have a quick question.... I have code that worksperfectly> with R desktop, but does not work with RWeb. Could you please tell mehow> to modify the code below so it will work with RWeb? > > > #Read in txt file > > happyguys<-read.table("c:/test8.txt", header=TRUE, row.names=1) > > #Subset the txt file to only include certain values > > test<-subset(happyguys, GRADE == 7 & Y_Q10A < 9) > > #print the subset file > > print(test) > > mydata<-test > > #Sort the data by province, and then by Y_Q10A > > mydataSorted<-mydata[ order(mydata$PROV,mydata$Y_Q10A), ] > print(mydataSorted) > > #Weight the data and aggregate the value by province. There are 2 values > for each province (1 & 2) and the results show the number of people for > each province who responded with value 1 or value 2 > > myag<-aggregate(mydataSorted$WTPP, > by=list(mydataSorted$PROV,mydataSorted$Y_Q10A), FUN=sum, na.rm=TRUE) > > #print the aggregated results > > print(myag) > > #Results below > > Group.1 Group.2 x > 1 10 1 466.2879 > 2 11 1 104.7425 > 3 12 1 1200.9314 > 4 13 1 888.4311 > 5 24 1 29040.8215 > 6 35 1 8876.2489 > 7 46 1 1381.7473 > 8 47 1 1508.7270 > 9 48 1 3293.6757 > 10 59 1 4247.5155 > 11 10 2 6623.7504 > 12 11 2 1954.9129 > 13 12 2 11399.5767 > 14 13 2 8811.8096 > 15 24 2 77222.4561 > 16 35 2 145528.7134 > 17 46 2 14010.4974 > 18 47 2 12335.5400 > 19 48 2 41137.2036 > 20 59 2 46261.5873 > > > > Thanks, > > Nat > > >------------------------------------------------------------------------------------------------------------------------> > This communication is intended for the use of therecipi...{{dropped:24}}> > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. >------------------------------------------------------------------------------------------------------------------------ This communication is intended for the use of the recipient to which it is addressed, and may contain confidential, personal, and or privileged information. Please contact the sender immediately if you are not the intended recipient of this communication, and do not copy, distribute, or take action relying on it. Any communication received in error, or subsequent reply, should be deleted or destroyed. ------------------------------------------------------------------------------------------------------------------------ This communication is intended for the use of the recipient to which it is addressed, and may contain confidential, personal, and or privileged information. Please contact the sender immediately if you are not the intended recipient of this communication, and do not copy, distribute, or take action relying on it. Any communication received in error, or subsequent reply, should be deleted or destroyed. ------------------------------------------------------------------------------------------------------------------------ This communication is intended for the use of the recipient to which it is addressed, and may contain confidential, personal, and or privileged information. Please contact the sender immediately if you are not the intended recipient of this communication, and do not copy, distribute, or take action relying on it. Any communication received in error, or subsequent reply, should be deleted or destroyed. [[alternative HTML version deleted]]
Natalie O'Toole
2008-Oct-23 14:36 UTC
[R] code works in R desktop but not iin RWeb - How do I modify to get it working in RWeb, please?
Hi, The code I submitted to RWeb and R is below. The only difference with R is that I added a read.table line of code, and in RWeb I opened the data file from the submit button. It does not matter how I subset the data file, it still doesn't work in RWeb either way. I am attaching my file that I am using to extract this data from so it is easier to reproduce the result. #subset the file to only include certain values:> > test<-subset(X, GRADE == 7 & Y_Q10A < 9) > > #sort the data by province and the variable Y_Q10A > > mydata<-test > > mydataSorted<-mydata[ order(mydata$PROV,mydata$Y_Q10A), ] > > #Weight the data and aggregate it by province and Y_Q10A > > myag<-aggregate(mydataSorted$WTPP, > by=list(mydataSorted$PROV,mydataSorted$Y_Q10A), FUN=sum, na.rm=TRUE) > > #print the aggregated data > > print(myag) >Thank-you, Nat __________________ I think you have to be either honest or careful, since the code you submitted to Rweb is different with your former code! Why the condition was changed from "test<-subset(X, GRADE == 7 & Y_Q10A < 9)" to "test<-subset(X, PROV==48 & GRADE == 7 & Y_Q10A < 9)"? By the way, please read the post guide -- I have no way to reproduce your result. Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China On Wed, Oct 22, 2008 at 11:15 PM, Natalie O'Toole <notoole at mtroyal.ca> wrote:> > Hi Yihui, > > Thank-you for this information. This is the code I am entering into RWeb > after loading my data file: > > #subset the file to only include certain values: > > test<-subset(X, GRADE == 7 & Y_Q10A < 9) > > #sort the data by province and the variable Y_Q10A > > mydata<-test > > mydataSorted<-mydata[ order(mydata$PROV,mydata$Y_Q10A), ] > > #Weight the data and aggregate it by province and Y_Q10A > > myag<-aggregate(mydataSorted$WTPP, > by=list(mydataSorted$PROV,mydataSorted$Y_Q10A), FUN=sum, na.rm=TRUE) > > #print the aggregated data > > print(myag) > > _ > This does not work. RWeb does not show any results. Here is the responseI> am getting from RWeb: > > Rweb:> postscript(file= "/tmp/Rout.11012.%03d.ps", onefile=FALSE) > Rweb:> X <- read.table("/tmp/Rdata.11012.data", header=T) > Rweb:> attach(X) > Rweb:> names(X) > [1] "PUMFID" "PROV" "REGION" "GRADE" "Y.Q10A" "WTPP" > Rweb:> > Rweb:> > Rweb:> test<-subset(X, PROV==48 & GRADE == 7 & Y_Q10A < 9) > > How can I modify my code above to get it to work in RWeb, please? > > Thanks, > > Nat >------------------------------------------------------------------------------------------------------------------------ This communication is intended for the use of the recipient to which it is addressed, and may contain confidential, personal, and or privileged information. Please contact the sender immediately if you are not the intended recipient of this communication, and do not copy, distribute, or take action relying on it. Any communication received in error, or subsequent reply, should be deleted or destroyed. ------------------------------------------------------------------------------------------------------------------------ This communication is intended for the use of the recipient to which it is addressed, and may contain confidential, personal, and or privileged information. Please contact the sender immediately if you are not the intended recipient of this communication, and do not copy, distribute, or take action relying on it. Any communication received in error, or subsequent reply, should be deleted or destroyed. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: test8.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081023/0e6b6635/attachment.txt>