Re: [R] Data frame manipulation
Hi there, I am glad it helped. I used mean as something to use, not because I had an understanding that this is what you need - so if you believe sum is what you where after - go with it :) Regarding loving R, and time spending - everyone on this list probably know how you feel. We all spent time trying to invent a wheel, and then found someone else compiled a better solution then our patch work. So 1 - this is how we learn I guess. And 2 - each of us contribute in his own way so it is all fine :) Best, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Fri, May 28, 2010 at 9:37 PM, LCOG1 jr...@lcog.org wrote: Tal, Wow, i cant believe how many different manipulations i went through trying to coerce it into the format i wanted. The below works nearly perfectly, i had to change the mean call to sum. Im curious why you used mean? Other than that thank you very much, i feel a little foolish about how long i spent trying to do this. Got to love R. From: Tal Galili [via R] [mailto: ml-node+2234184-1067705461-103...@n4.nabble.comml-node%2b2234184-1067705461-103...@n4.nabble.com ] Sent: Friday, May 28, 2010 12:04 AM To: ROLL Josh F Subject: Re: Data frame manipulation Hi there, The tool to learn for this is the cast function using the reshape package. In your example you have more then one value for RTL, which you should think of how to account for. But basically, here is a solution to what you asked for (assuming I understood you correctly) require(reshape) #?cast cast(EmpTotCt.Zn.., Taz ~ ClusterType , value = TotEmp, mean, fill = 0) Best, Tal Contact Details:--- Contact me: [hidden email]/user/SendEmail.jtp?type=nodenode=2234184i=0 | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Fri, May 28, 2010 at 3:14 AM, LCOG1 [hidden email]/user/SendEmail.jtp?type=nodenode=2234184i=1 wrote: Hello All, Please consider the following: TotEmp-c(19,6,1,1,8,44,2,33,48,1) ClusterType-c(AGF,CNS,OSV,RTL,RTL,TRN,REL,ACC_CLUST,RTL,WHL) Taz-c(0,0,0,100,100,100,101,101,102,103) AllCtTypes_-c(AGF,CNS,OSV,RTL,TRN,REL,ACC_CLUST,WHL,ADM_CLUST, HLH,HLH_CLUST,ACC,RTL_CLUST,MFG,ADM,MFG_CLUST,CNS_CLUST,PRF,PUB, FIN,INF_CLUST,INF,EDU_CLUST,REC,EDU, MNG,UTL,MIN) #Build data frame EmpTotCt.Zn..-data.frame(TotEmp,ClusterType,Taz) #Reverse rows to columns EmpTotCt.Zn2..-as.data.frame(t(as.matrix(EmpTotCt.Zn..))) EmpTotCt.Zn.. is a data frame that i would like to alter by adding new columns and input 0s where no values exist. I tried the line below as its the only way i know of switching columns to rows but its far from what i am looking for. So EmpTotCt.Zn.. returns TotEmp ClusterType Taz 1 19 AGF 0 2 6 CNS0 3 1 OSV 0 4 1 RTL 100 5 8 RTL 100 6 44 TRN100 7 2 REL 101 8 33 ACC_CLUST 101 9 48 RTL 102 10 1 RTL 103 But what i want is to return the below: AGF CNS OSV RTL RTL TRN REL ACC_CLUST RTL 0 19 6 1 0 0 0 0 0 0 100 0 0 0 1 8 44 0 0 0 101 0 0 0 0 0 0 2 33 0 102 0 0 0 0 0 0 0 0 48 103 0 0 0 0 0 0 0 0 1 Where the rows represent Taz and the columns represent ALL ClusterType's found in AllCtTypes_, this would mean that the above output example would have many more columns with 0s in all the rows since there are no observations. Its taken me a while to get the data into the above format and im afraid im stuck with how to get it into the final computational format, so hopefully someone can help. Perhaps i have to build a blank data frame with the appropriate dimensions first but i am not sure if this is the most efficient way of accomplishing this. Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/Data-frame-manipulation-tp2233932p2233932.html Sent from the R help mailing list archive at Nabble.com. __ [hidden
Re: [R] Matrix interesting question!
On 05/29/2010 02:30 AM, UM wrote: hi, I have been trying to do this in R (have implemented it in Excel) but I have been using a very inefficent way (loops etc.). I have matrix A (columns are years and ages are rows) and matrix B (columns are birth yrs and rows are ages) I would like to first turn matrix A into matrix B And then I would like to convert matrix B back again to the original matrix A. (I have left out details of steps) but this is the gist of what I want to do. Can anyone please give any insights? Hi UM, The answer is somewhat trivial (see below) but my initial misunderstanding of the question led me to write a function that I have often wanted. When using an apply family function, I sometimes want to apply a different argument to each slice of the object. I'm pretty sure that this has been done before, and I even looked through the plyr package but couldn't find what I wanted. Here's an example for a data frame. dfapply2-function(x,FUN,args) { dimx-dim(x) newx-list() for(column in 1:dimx[2]) newx[[column]]-do.call(FUN,list(x[column],args[column])) names(newx)-names(x) return(as.data.frame(newx)) } Pretty rough, but it does apply the arguments in args to the respective columns. So, thanks for motivating me to program this. Jim digahole-function(x) { dimx-dim(x) years-as.numeric(colnames(x)) ages-as.numeric(rownames(x)) minby-min(years)-max(ages) maxby-max(years)-min(ages) newx-matrix(NA,nrow=dimx[1],ncol=1+maxby-minby) rownames(newx)-rownames(x) colnames(newx)-minby:maxby oldrow-rep(1:dimx[1],each=dimx[2]) oldcol-rep(1:dimx[2],dimx[1]) newcol-oldcol+rep(max(ages)-ages,each=dimx[1]) for(element in 1:length(oldrow)) newx[oldrow[element],newcol[element]]-x[oldrow[element],oldcol[element]] return(newx) } fillitup-function(x) { dimx-dim(x) byears-as.numeric(colnames(x)) ages-as.numeric(rownames(x)) minyr-min(byears)+max(ages) maxyr-max(byears)+min(ages) oldx-matrix(NA,nrow=dimx[1],ncol=1+maxyr-minyr) rownames-rownames(x) colnames-minyr:maxyr for(row in 1:dimx[1]) oldx[row,]-x[row,which(!is.na(x[row,]))] return(oldx) } fillitup(digahole(A)) __ 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.
Re: [R] ICD9 codes
Dear Prof Frank Harrel: I am extremely sorry for having reposted the same question numerous times. Earlier when I had posted I got replies stating that my post had matched a filter rule and hence was being held by the moderator. So I assumed that the question was never posted and I reposted with different subject lines just to make sure that it gets posted. I sincerely apologise for the inconvenience caused. Regards, Vishwanath On Sat, May 29, 2010 at 4:10 AM, Frank E Harrell Jr f.harr...@vanderbilt.edu wrote: Your notes are bordering on harassment. Do you expect that everyone who reads this list will reply I do not have anything that will help you if they don't? By my count this is your 4th note asking for this help. That being said I hope that you do find help somewhere or implement it yourself and share the result, as your question is an important one. Also, please be sure to state your affiliation on your notes. Frank On 05/28/2010 02:19 PM, Vishwanath Sindagi wrote: Hello: I am working on getting some statistics related to clinical trials and stuff. I have to work with ICD9 codes. Is anyone aware of any R method that deals with ICD9 codes verification and manipulation. Thanks Vishwanath -- Frank E Harrell Jr Professor and Chairman School of Medicine Department of Biostatistics Vanderbilt University __ 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.
[R] adding statistical output to a plot
I have written a function to emulate minitab's QQ plotting output (with SW test and AD test results on the graph): mtab.norm-function(x) { library(nortest) library(lattice) x-as.numeric(x) x-as.vector(x) plot.ht-4.6 plot.wd-4.6 pt.ht=plot.ht/5 txt.sz-(plot.ht/7.5) X11(width=plot.wd, height=plot.ht, bg='gray96') qqplot(x, pch=16, cex=pt.ht, col=palette()[c(1,2)], xlab=paste(colnames(x)), ylab='Normal Quantile-Quantile Plot', main='') grid(grid(col = darkgray)) st.x-shapiro.test(x) mtext(paste(st.x$method, \np=,st.x$p.value,\n W=,st.x$statistic, line=1, cex=txt.sz, adj=0)) adt.x-ad.test(x) mtext(paste(adt.x$method, \np=,adt.x$p.value, \n W=, adt.x$statistic, line=1, cex=txt.sz, adj=1))} mtab.matrix-function(z){apply(z, 2, mtab.norm)} However, I get the following message when I try to apply it: ab-rnorm(1:100, 2) aa-log(ab) Warning message: In log(ab) : NaNs produced ac-(ab^2) df-data.frame(aa,ab,ac) mtab.matrix(df) Error in sort(y) : argument y is missing, with no default mtab.norm(aa) Error in sort(y) : argument y is missing, with no default I'm doing something syntactically stupid. I can't figure out what. Thanks for your help -- View this message in context: http://r.789695.n4.nabble.com/adding-statistical-output-to-a-plot-tp2235565p2235565.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] adding statistical output to a plot
Two things: 1) doing log on rnorm, will get you NaN's because you are doing log on a negative number (some of the time). 2) Running traceback() 5: sort(y) 4: qqplot(x, pch = 16, cex = pt.ht, col = palette()[c(1, 2)], xlab = paste(colnames(x)), ylab = Normal Quantile-Quantile Plot, main = ) 3: FUN(newX[, i], ...) 2: apply(z, 2, mtab.norm) 1: mtab.matrix(df) Shows that you are using qqplot wrongly somehow. Using ?qqplot Shows that you should either use qqnorm (not qqplot) Or have another argument for another distribution. Let me know if it works :) Best, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Sat, May 29, 2010 at 12:39 PM, dunner ross.du...@tcd.ie wrote: I have written a function to emulate minitab's QQ plotting output (with SW test and AD test results on the graph): mtab.norm-function(x) { library(nortest) library(lattice) x-as.numeric(x) x-as.vector(x) plot.ht-4.6 plot.wd-4.6 pt.ht=plot.ht/5 txt.sz-(plot.ht/7.5) X11(width=plot.wd, height=plot.ht, bg='gray96') qqplot(x, pch=16, cex=pt.ht, col=palette()[c(1,2)], xlab=paste(colnames(x)), ylab='Normal Quantile-Quantile Plot', main='') grid(grid(col = darkgray)) st.x-shapiro.test(x) mtext(paste(st.x$method, \np=,st.x$p.value,\n W=,st.x$statistic, line=1, cex=txt.sz, adj=0)) adt.x-ad.test(x) mtext(paste(adt.x$method, \np=,adt.x$p.value, \n W=, adt.x$statistic, line=1, cex=txt.sz, adj=1))} mtab.matrix-function(z){apply(z, 2, mtab.norm)} However, I get the following message when I try to apply it: ab-rnorm(1:100, 2) aa-log(ab) Warning message: In log(ab) : NaNs produced ac-(ab^2) df-data.frame(aa,ab,ac) mtab.matrix(df) Error in sort(y) : argument y is missing, with no default mtab.norm(aa) Error in sort(y) : argument y is missing, with no default I'm doing something syntactically stupid. I can't figure out what. Thanks for your help -- View this message in context: http://r.789695.n4.nabble.com/adding-statistical-output-to-a-plot-tp2235565p2235565.html Sent from the R help mailing list archive at Nabble.com. __ 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. [[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.
Re: [R] ICD9 codes
It is perhaps time to bring to people's general attention that there is an issue with postings from gmail.com addresses being held for moderation because The headers matched a filter rule. It is not only gmail.com, but there is a marked excess of these. Vishwanath (@gmail.com) is one of many victims. There is a group of about a dozen people who act as moderators, approving or discarding messages which have been held. Reasons for holding are almost always either Posting from Non-Member or Matched a Filter Rule. We do this somewhat non-systematically, looking at the list of held messages on a convenience basis. However, it would be unlikely that any valid message would be held for more than an hour or so; usually it would be less. The situation has been discussed recently amongst the moderators, including the list manager Martin Maechler. We are undecided about the best action (if any) -- while the excessive false trapping of gmail.com postings is at least an inconvenience for the trapped, and sometimes leads to visible distress or embarrassment, the presence of the filter rules does prevent spam from reaching the list. Vishwanath's reaction in repeatedly re-posting is perhaps understandable on the part of someone who is not familiar with how the moderation system operates. In fact he posted the same message 4 times (morning evening on 27 May, and again on 28 May) as can be seen from the archives. He is subscribed to the list, so would normally receive copies of his own postings via the list (and therefore know that it had got through) unless he has opted to not receive his own postings. In that case, having received the held for moderation message, not receiving his posting via the list, and not thinking of looking in the archives, he could form the impression that it/they had vanished into a black hole, and try again. Since we began to discuss this about a fortnight ago, I have been keeping a count of those held messages which I have seen myself. Not counting true spam, only genuine messages, the results are as follows. NM denote a posting from a non-member, FR denotes a posting that matched a filter rule, GM denotes a posting from a gmail.com address, NGM one not from gmail.com. FR NM +-+- GM | 45 | 4 +-+- NGM | 19 | 24 Fisher test: P=7.3e-07, OR=13.7, CI=(4.0, 62.0) About 30% of R-help subscribers have gmail.com addresses, so they are clearly over-represented in the FR group (70%)! It is suspected that the gmail.com filter rule may perhaps be triggered by HTML, though the reason is not yet clear. Meanwhile, a reminder to people who receive notification that their posting has been held for moderation: Please check the archives to see whether your message has reached the list within a reasonable time (say 2 hours -- there can be a delay before a message is placed in the archives) beforetrying to do anything about it: https://stat.ethz.ch/pipermail/r-help Hoping this helps to clarify an issue which can lead to unwanted consequences. Ted. On 29-May-10 05:42:27, Vishwanath Sindagi wrote: Dear Prof Frank Harrel: I am extremely sorry for having reposted the same question numerous times. Earlier when I had posted I got replies stating that my post had matched a filter rule and hence was being held by the moderator. So I assumed that the question was never posted and I reposted with different subject lines just to make sure that it gets posted. I sincerely apologise for the inconvenience caused. Regards, Vishwanath On Sat, May 29, 2010 at 4:10 AM, Frank E Harrell Jr f.harr...@vanderbilt.edu wrote: Your notes are bordering on harassment. _Do you expect that everyone who reads this list will reply I do not have anything that will help you if they don't? _By my count this is your 4th note asking for this help. That being said I hope that you do find help somewhere or implement it yourself and share the result, as your question is an important one. Also, please be sure to state your affiliation on your notes. Frank On 05/28/2010 02:19 PM, Vishwanath Sindagi wrote: Hello: I am working on getting some statistics related to clinical trials and stuff. I have to work with ICD9 codes. Is anyone aware of any R method that deals with ICD9 codes verification and manipulation. Thanks Vishwanath -- Frank E Harrell Jr _ Professor and Chairman _ _ _ _School of Medicine _ _ _ _ _ _ _ _ _ _ Department of Biostatistics _ Vanderbilt University __ 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. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 29-May-10 Time:
Re: [R] ICD9 codes
I have received the Matched a Filter Rule message a number of times. I have some control over what the headers of my messages look like, so if I was told what the filter rule is, I could perhaps modify the messages to avoid it. You probably don't want to post that information to the list, but it might be worthwhile to send it privately to authors of false positive messages. Duncan Murdoch On 29/05/2010 6:43 AM, (Ted Harding) wrote: It is perhaps time to bring to people's general attention that there is an issue with postings from gmail.com addresses being held for moderation because The headers matched a filter rule. It is not only gmail.com, but there is a marked excess of these. Vishwanath (@gmail.com) is one of many victims. There is a group of about a dozen people who act as moderators, approving or discarding messages which have been held. Reasons for holding are almost always either Posting from Non-Member or Matched a Filter Rule. We do this somewhat non-systematically, looking at the list of held messages on a convenience basis. However, it would be unlikely that any valid message would be held for more than an hour or so; usually it would be less. The situation has been discussed recently amongst the moderators, including the list manager Martin Maechler. We are undecided about the best action (if any) -- while the excessive false trapping of gmail.com postings is at least an inconvenience for the trapped, and sometimes leads to visible distress or embarrassment, the presence of the filter rules does prevent spam from reaching the list. Vishwanath's reaction in repeatedly re-posting is perhaps understandable on the part of someone who is not familiar with how the moderation system operates. In fact he posted the same message 4 times (morning evening on 27 May, and again on 28 May) as can be seen from the archives. He is subscribed to the list, so would normally receive copies of his own postings via the list (and therefore know that it had got through) unless he has opted to not receive his own postings. In that case, having received the held for moderation message, not receiving his posting via the list, and not thinking of looking in the archives, he could form the impression that it/they had vanished into a black hole, and try again. Since we began to discuss this about a fortnight ago, I have been keeping a count of those held messages which I have seen myself. Not counting true spam, only genuine messages, the results are as follows. NM denote a posting from a non-member, FR denotes a posting that matched a filter rule, GM denotes a posting from a gmail.com address, NGM one not from gmail.com. FR NM +-+- GM | 45 | 4 +-+- NGM | 19 | 24 Fisher test: P=7.3e-07, OR=13.7, CI=(4.0, 62.0) About 30% of R-help subscribers have gmail.com addresses, so they are clearly over-represented in the FR group (70%)! It is suspected that the gmail.com filter rule may perhaps be triggered by HTML, though the reason is not yet clear. Meanwhile, a reminder to people who receive notification that their posting has been held for moderation: Please check the archives to see whether your message has reached the list within a reasonable time (say 2 hours -- there can be a delay before a message is placed in the archives) beforetrying to do anything about it: https://stat.ethz.ch/pipermail/r-help Hoping this helps to clarify an issue which can lead to unwanted consequences. Ted. On 29-May-10 05:42:27, Vishwanath Sindagi wrote: Dear Prof Frank Harrel: I am extremely sorry for having reposted the same question numerous times. Earlier when I had posted I got replies stating that my post had matched a filter rule and hence was being held by the moderator. So I assumed that the question was never posted and I reposted with different subject lines just to make sure that it gets posted. I sincerely apologise for the inconvenience caused. Regards, Vishwanath On Sat, May 29, 2010 at 4:10 AM, Frank E Harrell Jr f.harr...@vanderbilt.edu wrote: Your notes are bordering on harassment. _Do you expect that everyone who reads this list will reply I do not have anything that will help you if they don't? _By my count this is your 4th note asking for this help. That being said I hope that you do find help somewhere or implement it yourself and share the result, as your question is an important one. Also, please be sure to state your affiliation on your notes. Frank On 05/28/2010 02:19 PM, Vishwanath Sindagi wrote: Hello: I am working on getting some statistics related to clinical trials and stuff. I have to work with ICD9 codes. Is anyone aware of any R method that deals with ICD9 codes verification and manipulation. Thanks Vishwanath -- Frank E Harrell Jr _ Professor and Chairman _ _ _ _School of Medicine _ _ _ _ _ _ _ _ _ _ Department of Biostatistics _ Vanderbilt University __
Re: [R] adding statistical output to a plot
On 05/29/2010 07:39 PM, dunner wrote: I have written a function to emulate minitab's QQ plotting output (with SW test and AD test results on the graph): ... However, I get the following message when I try to apply it: ab-rnorm(1:100, 2) aa-log(ab) Warning message: In log(ab) : NaNs produced Almost certainly negative numbers in ab - try: ab-abs(ab) to flip these to positive or use a larger mean ac-(ab^2) df-data.frame(aa,ab,ac) mtab.matrix(df) Error in sort(y) : argument y is missing, with no default mtab.norm(aa) Error in sort(y) : argument y is missing, with no default These errors look like they are happening in qqplot Jim __ 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.
Re: [R] adding statistical output to a plot
Thanks to both of you, I used the below code instead, which has been cleaned and pruned a little. It produces a trellis of qq plots with the proper annotations as per Minitab from a dataframe passed to mtab.matrix(). However, I can't get individual variable names (these are column names in the passed dataframe) to annotate the plots. Perhaps apply simply doesn't deal with the colname and I have to try a completely different method? Or will apply pass enough information to the included function (mtab.norm) to allow me to annotate the plot? Again, I'm probably missing something banal and wholly obvious. mtab.norm-function(x){ library(nortest) library(lattice) x-as.numeric(x) x-as.vector(x) plot.ht-4.6 plot.wd-4.6 pt.ht=plot.ht/7 txt.sz-(plot.ht/5) qqnorm(x, pch=16, cex=pt.ht, col=darkorange, xlab=paste(colnames(x)), ylab='', main='') qqline(x, col=black, lty=2) grid(col = darkgrey, lty=2) st.x-shapiro.test(x) mtext(paste(Shapiro-Wilks, \n p =,signif(st.x$p.value,digits=4),\n W =,signif(st.x$statistic,digits=4)), line=1, cex=txt.sz, adj=0) adt.x-ad.test(x) mtext(paste(Anderson-Darling, \n p =,signif(adt.x$p.value,digits=4), \n W =, signif(adt.x$statistic,digits=4)), line=1, cex=txt.sz, adj=1)} mtab.matrix-function(z){ pdf(file=paste(colnames(z)[1],.pdf), paper=a4r, width=0, height=0) par(mfcol=c(3,3), mar=c(5.1,4.1,5.1,2.1)) par(bg=white) apply(z, 2, mtab.norm) dev.off()} Thanks again for all your help. I am obviously a relative beginner, but an enthusiast! Dr. Ross Dunne, HRB Clinical Research Fellow, Dept. of Psychiatry, Trinity College Dublin. -- View this message in context: http://r.789695.n4.nabble.com/adding-statistical-output-to-a-plot-tp2235565p2235629.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] adding statistical output to a plot
On May 29, 2010, at 8:11 AM, dunner wrote: Thanks to both of you, I used the below code instead, which has been cleaned and pruned a little. It produces a trellis of qq plots with the proper annotations as per Minitab from a dataframe passed to mtab.matrix(). However, I can't get individual variable names (these are column names in the passed dataframe) to annotate the plots. Perhaps apply simply doesn't deal with the colname and I have to try a completely different method? apply takes a column and passes it as a vector. I think it still has a name but perhaps not a colname. Getting the name of a passed object sometimes requires working with substitute(deparse(x)). Not sure what paste() would be doing when you are only processing one vector at a time. Or will apply pass enough information to the included function (mtab.norm) to allow me to annotate the plot? Again, I'm probably missing something banal and wholly obvious. mtab.norm-function(x){ library(nortest) library(lattice) x-as.numeric(x) x-as.vector(x) plot.ht-4.6 plot.wd-4.6 pt.ht=plot.ht/7 txt.sz-(plot.ht/5) qqnorm(x, pch=16, cex=pt.ht, col=darkorange, xlab=paste(colnames(x)), ylab='', main='') qqline(x, col=black, lty=2) grid(col = darkgrey, lty=2) st.x-shapiro.test(x) mtext(paste(Shapiro-Wilks, \n p =,signif(st.x $p.value,digits=4),\n W =,signif(st.x$statistic,digits=4)), line=1, cex=txt.sz, adj=0) adt.x-ad.test(x) mtext(paste(Anderson-Darling, \n p =,signif(adt.x $p.value,digits=4), \n W =, signif(adt.x$statistic,digits=4)), line=1, cex=txt.sz, adj=1)} mtab.matrix-function(z){ pdf(file=paste(colnames(z)[1],.pdf), paper=a4r, width=0, height=0) par(mfcol=c(3,3), mar=c(5.1,4.1,5.1,2.1)) par(bg=white) apply(z, 2, mtab.norm) dev.off()} Thanks again for all your help. I am obviously a relative beginner, but an enthusiast! Dr. Ross Dunne, HRB Clinical Research Fellow, Dept. of Psychiatry, Trinity College Dublin. -- View this message in context: http://r.789695.n4.nabble.com/adding-statistical-output-to-a-plot-tp2235565p2235629.html Sent from the R help mailing list archive at Nabble.com. __ 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. David Winsemius, MD West Hartford, CT __ 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.
[R] plotting density in same plot in loop iteration
Hi R-mailing list I would have the following set-up below with a simplified data-frame. Through a loop which includes certain criteria for the densities I would like to plot the different density-distributions in the same plot. Of course I hope I don't do any mistakes with all the indexes of the dataframe. All I would like to have is the different densities in the same plot with a general background density d. In a second step there might be also the need to combine all the different densities within the loop to one single distribution. I would be grateful for any help on this. Cheers a [1] 1 4 7 11 16 21 23 b [1] 15 17 13 23 14 11 12 c [1] 0 15 0 0 0 0 0 d [1] 0 0 7 0 16 0 0 e [1] 0 0 0 11 0 21 0 f [1] 0 0 123 124 122 121 0 q- data.frame(a,b,c,d,e,f) a b c d e f 1 1 15 0 0 0 0 2 4 17 15 0 0 0 3 7 13 0 7 0 123 4 11 23 0 0 11 124 5 16 14 0 16 0 122 6 21 11 0 0 21 121 7 23 12 0 0 0 0 indx-which(q[,a]==q[,d]) indy-which(q[,a]==q[,e]) s-[c(indx,indy),] std-sd(S[,f]) t-round(max(q[,a]),0) u-round(min(q[,a]),0) colnames(v)-c(a) D-q[,a] d-density(D) pdf('L') for (h in length(s[[a]])) { for (i in length(S[[a]])) { inda-which(q[h,a]==q[h,d]) indb-which(q[i,a]==q[i,e]) R-(s[c(inda),f]+s[c(indb),f])/2 indh-which(abs(q[,b]-R)=(2*std)) indi-which(abs(q[,c]-R)=(2*std)) A-q[indh,c(a,b)] colnames(A)- c(a,g) B-q[indy,c(a,c)] colnames(B)- c(a,g) C-rbind(A,B) c-density(C[,a]) plot(d, col=blue,xlim=c(u,t),ylim=c(0,0.5)) polygon(d, col=blue,border=blue) lines(c, col=red) } } dev.off() -- Niklaus Hürlimann Université de Lausanne Institut de Minéralogie et Géochimie L'Anthropole CH-1015 Lausanne Suisse E-mail: niklaus.hurlim...@unil.ch Tel:+41(0)21 692 4452 [[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.
Re: [R] adding statistical output to a plot
Hi Dunner, The way I usually resolve this is by extracting the names with colnames and then reinsert them to the new object. BTW, why are you trying to reproduce the image from minitab? what features in it do you find useful ? Best, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Sat, May 29, 2010 at 3:11 PM, dunner ross.du...@tcd.ie wrote: d the below code instead, which has been cleaned and pruned a little. It produces a trellis of qq plots with the proper annotations as per Minitab from a dataframe passed to mtab.matrix(). However, I can't get individual variable names (these are column names in the passed dataframe) to annotate the plots. Perh [[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.
Re: [R] ICD9 codes
Thanks for both your note Ted and Vishwanath. I had no idea this was going on. Sincerely, Frank On 05/29/2010 05:43 AM, (Ted Harding) wrote: It is perhaps time to bring to people's general attention that there is an issue with postings from gmail.com addresses being held for moderation because The headers matched a filter rule. It is not only gmail.com, but there is a marked excess of these. Vishwanath (@gmail.com) is one of many victims. There is a group of about a dozen people who act as moderators, approving or discarding messages which have been held. Reasons for holding are almost always either Posting from Non-Member or Matched a Filter Rule. We do this somewhat non-systematically, looking at the list of held messages on a convenience basis. However, it would be unlikely that any valid message would be held for more than an hour or so; usually it would be less. The situation has been discussed recently amongst the moderators, including the list manager Martin Maechler. We are undecided about the best action (if any) -- while the excessive false trapping of gmail.com postings is at least an inconvenience for the trapped, and sometimes leads to visible distress or embarrassment, the presence of the filter rules does prevent spam from reaching the list. Vishwanath's reaction in repeatedly re-posting is perhaps understandable on the part of someone who is not familiar with how the moderation system operates. In fact he posted the same message 4 times (morning evening on 27 May, and again on 28 May) as can be seen from the archives. He is subscribed to the list, so would normally receive copies of his own postings via the list (and therefore know that it had got through) unless he has opted to not receive his own postings. In that case, having received the held for moderation message, not receiving his posting via the list, and not thinking of looking in the archives, he could form the impression that it/they had vanished into a black hole, and try again. Since we began to discuss this about a fortnight ago, I have been keeping a count of those held messages which I have seen myself. Not counting true spam, only genuine messages, the results are as follows. NM denote a posting from a non-member, FR denotes a posting that matched a filter rule, GM denotes a posting from a gmail.com address, NGM one not from gmail.com. FR NM +-+- GM | 45 | 4 +-+- NGM | 19 | 24 Fisher test: P=7.3e-07, OR=13.7, CI=(4.0, 62.0) About 30% of R-help subscribers have gmail.com addresses, so they are clearly over-represented in the FR group (70%)! It is suspected that the gmail.com filter rule may perhaps be triggered by HTML, though the reason is not yet clear. Meanwhile, a reminder to people who receive notification that their posting has been held for moderation: Please check the archives to see whether your message has reached the list within a reasonable time (say 2 hours -- there can be a delay before a message is placed in the archives) beforetrying to do anything about it: https://stat.ethz.ch/pipermail/r-help Hoping this helps to clarify an issue which can lead to unwanted consequences. Ted. On 29-May-10 05:42:27, Vishwanath Sindagi wrote: Dear Prof Frank Harrel: I am extremely sorry for having reposted the same question numerous times. Earlier when I had posted I got replies stating that my post had matched a filter rule and hence was being held by the moderator. So I assumed that the question was never posted and I reposted with different subject lines just to make sure that it gets posted. I sincerely apologise for the inconvenience caused. Regards, Vishwanath On Sat, May 29, 2010 at 4:10 AM, Frank E Harrell Jr f.harr...@vanderbilt.edu wrote: Your notes are bordering on harassment. _Do you expect that everyone who reads this list will reply I do not have anything that will help you if they don't? _By my count this is your 4th note asking for this help. That being said I hope that you do find help somewhere or implement it yourself and share the result, as your question is an important one. Also, please be sure to state your affiliation on your notes. Frank On 05/28/2010 02:19 PM, Vishwanath Sindagi wrote: Hello: I am working on getting some statistics related to clinical trials and stuff. I have to work with ICD9 codes. Is anyone aware of any R method that deals with ICD9 codes verification and manipulation. Thanks Vishwanath -- Frank E Harrell Jr _ Professor and Chairman _ _ _ _School of Medicine _ _ _ _ _ _ _ _ _ _ Department of Biostatistics _ Vanderbilt University __ 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.
[R] warning In fun(...) : no DISPLAY variable so Tk is not available
I am getting the above warning following loading of Geneland 3.1.5 on unix , while a simple plot sends output to the pdf file ( see attached code) no output results from Geneland functions, resulting in empty pdf files library (Geneland) Loading required package: RandomFields Loading required package: fields Loading required package: spam Package 'spam' is loaded. Spam version 0.21-0 (2010-03-13). Type demo( spam) for some demos, help( Spam) for an overview of this package. Help for individual functions is optained by adding the suffix '.spam' to the function name, e.g. 'help(chol.spam)'. Attaching package: 'spam' The following object(s) are masked from 'package:base': backsolve, forwardsolve, norm Try help(fields) for an overview of this library fields web: http://www.image.ucar.edu/Software/Fields Loading required package: mapproj Loading required package: maps Loading required package: snow Loading required package: tcltk Loading Tcl/Tk interface ... done ooo oGeneland is loaded o o o o* Please * o o o oRegister on o ohttp://folk.uio.no/gillesg/Geneland/register.php o o o oSee manual ono ohttp://folk.uio.no/gillesg/Geneland/Geneland.htmlo o o oThis is Geneland-3.1.5 o o o ooo Warning message: In fun(...) : no DISPLAY variable so Tk is not available pdf(test.pdf) plot(1:10,1:10) dev.off() null device __ 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.
Re: [R] ICD9 codes
I'm not sure we know exactly what the filters are griping about. One other aspect the Ted didn't mention is that posts from the Nabble interface also seem to get trapped, especially with a gmail address, but that doesn't apply in Duncan's case. Duncan Murdoch wrote: I have received the Matched a Filter Rule message a number of times. I have some control over what the headers of my messages look like, so if I was told what the filter rule is, I could perhaps modify the messages to avoid it. You probably don't want to post that information to the list, but it might be worthwhile to send it privately to authors of false positive messages. Duncan Murdoch On 29/05/2010 6:43 AM, (Ted Harding) wrote: It is perhaps time to bring to people's general attention that there is an issue with postings from gmail.com addresses being held for moderation because The headers matched a filter rule. It is not only gmail.com, but there is a marked excess of these. Vishwanath (@gmail.com) is one of many victims. There is a group of about a dozen people who act as moderators, approving or discarding messages which have been held. Reasons for holding are almost always either Posting from Non-Member or Matched a Filter Rule. We do this somewhat non-systematically, looking at the list of held messages on a convenience basis. However, it would be unlikely that any valid message would be held for more than an hour or so; usually it would be less. The situation has been discussed recently amongst the moderators, including the list manager Martin Maechler. We are undecided about the best action (if any) -- while the excessive false trapping of gmail.com postings is at least an inconvenience for the trapped, and sometimes leads to visible distress or embarrassment, the presence of the filter rules does prevent spam from reaching the list. Vishwanath's reaction in repeatedly re-posting is perhaps understandable on the part of someone who is not familiar with how the moderation system operates. In fact he posted the same message 4 times (morning evening on 27 May, and again on 28 May) as can be seen from the archives. He is subscribed to the list, so would normally receive copies of his own postings via the list (and therefore know that it had got through) unless he has opted to not receive his own postings. In that case, having received the held for moderation message, not receiving his posting via the list, and not thinking of looking in the archives, he could form the impression that it/they had vanished into a black hole, and try again. Since we began to discuss this about a fortnight ago, I have been keeping a count of those held messages which I have seen myself. Not counting true spam, only genuine messages, the results are as follows. NM denote a posting from a non-member, FR denotes a posting that matched a filter rule, GM denotes a posting from a gmail.com address, NGM one not from gmail.com. FR NM +-+- GM | 45 | 4 +-+- NGM | 19 | 24 Fisher test: P=7.3e-07, OR=13.7, CI=(4.0, 62.0) About 30% of R-help subscribers have gmail.com addresses, so they are clearly over-represented in the FR group (70%)! It is suspected that the gmail.com filter rule may perhaps be triggered by HTML, though the reason is not yet clear. Meanwhile, a reminder to people who receive notification that their posting has been held for moderation: Please check the archives to see whether your message has reached the list within a reasonable time (say 2 hours -- there can be a delay before a message is placed in the archives) beforetrying to do anything about it: https://stat.ethz.ch/pipermail/r-help Hoping this helps to clarify an issue which can lead to unwanted consequences. Ted. On 29-May-10 05:42:27, Vishwanath Sindagi wrote: Dear Prof Frank Harrel: I am extremely sorry for having reposted the same question numerous times. Earlier when I had posted I got replies stating that my post had matched a filter rule and hence was being held by the moderator. So I assumed that the question was never posted and I reposted with different subject lines just to make sure that it gets posted. I sincerely apologise for the inconvenience caused. Regards, Vishwanath On Sat, May 29, 2010 at 4:10 AM, Frank E Harrell Jr f.harr...@vanderbilt.edu wrote: Your notes are bordering on harassment. _Do you expect that everyone who reads this list will reply I do not have anything that will help you if they don't? _By my count this is your 4th note asking for this help. That being said I hope that you do find help somewhere or implement it yourself and share the result, as your question is an important one. Also, please be sure to state your affiliation on your notes. Frank On 05/28/2010 02:19 PM, Vishwanath Sindagi wrote: Hello: I am working on getting some statistics related to clinical trials and stuff. I have to work with ICD9 codes. Is anyone aware of any R method that deals with ICD9
Re: [R] logarithmic integrals in R?
Oliver Kullmann O.Kullmann at swansea.ac.uk writes: Hello, I couldn't find information on whether the logarithmic integrals Li_m(x) = integral_0^x log(t)^(-m) dt for x = 0 are available in R? I saw your request only this weekend. The first logarithmic integral can be computed using the exponential integral Ei(x) per li(x) = Ei(log(x)) and elliptic integrals are part of the 'gsl' package, so library('gsl') x - seq(2, 10, by=0.5) y - expint_Ei(log(x)) y See e.g. the Handbook of Mathematical Functions for how to reduce higher logarithmic integrals. Another possibility is to use the Web API of 'keisan', the calculation library of Casio. Regards Hans Werner Best wishes Oliver __ 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.
[R] how to run the R script in windows in background mode or script mode?
Hello,everyone . Now I write some R scripts to calculate some variables and I run them in C shell script command in linux.. Now my some new R scripts had to be moved in someother's computer with windows system. How to run these R scripts easily without installing many soft package? -- TANG Jie Email: totang...@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[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.
[R] R on the iPhone/iPad? Not so much....a GPL violation
Hi all, There have been posts in the past about R being made available for the iPhone and perhaps more logically now, on the iPad. My recollection is that the hurdle discussed in the past was primarily a lack of access to a CLI on the iPhone's variant of OSX, compelling the development of a GUI interface for R specifically for these devices. R itself, can be successfully compiled with the iPhone development tools. Well, now there is another, clearly more profound reason. The FSF has recently communicated with Apple on the presence of a GPL application (GNU Go) in the iTunes store because the iTunes TOS infringes upon the GPL. Apple, given a choice, elected to remove the application, rather than amending their TOS. The FSF also informed the developers of the iPhone port of GNU Go that their distribution is in violation of the GPL. R Core and any others considering an iPhone/iPad port of R, if you are not already aware, take note... More information is here: http://www.fsf.org/news/2010-05-app-store-compliance/ with an update here: http://www.fsf.org/news/blogs/licensing/more-about-the-app-store-gpl-enforcement So, until Apple amends their TOS agreement, it looks like there will be no GPL apps available for the iPhone/iPad, since the only way to make applications available for these platforms is via the iTunes store (unless you unlock the device). Hence, no R for these devices in the foreseeable future. BTW, I am posting this as an FYI, not as a catalyst for a discussion on the political aspects of this situation. So please, let's not go there... :-) Regards, Marc Schwartz __ 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.
[R] Help with R graphics
I need to make a plot illustrating main characterisitig of river drainage data. For this I have 2 questions: how can I rotate a histogram -90° (or 270°) (like the horizontal=TRUE with plot)? how can I use split.screen to produce 3 plot with uneuqal size (1/5, 2/5, 2/5 of the screen width)? thank you very much in advance for your help fabian __ 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.
Re: [R] Help with R graphics
On May 29, 2010, at 9:54 AM, Fabian wrote: I need to make a plot illustrating main characterisitig of river drainage data. For this I have 2 questions: how can I rotate a histogram -90° (or 270°) (like the horizontal=TRUE with plot)? how can I use split.screen to produce 3 plot with uneuqal size (1/5, 2/5, 2/5 of the screen width)? thank you very much in advance for your help fabian I don't see an obvious way to do this with either hist() or MASS::truehist(). There may be another function in a CRAN package that will automatically do this. Rotating a plot is not a basic R graphics transformation and there are some graphic functions that support this with specific code internally. Paul posted a generalized way to do this with lattice/grid graphics back in 2003: https://stat.ethz.ch/pipermail/r-help/2003-October/040356.html If you are plotting frequencies (counts), you can use barplot() which supports a 'horiz' argument. If you need to replicate the breakpoints used in hist() with a continuous variable, see ?cut and ?nclass, which is what hist() uses internally. For splitting the overall plot into unevenly sized regions, you are better off using ?layout: # Create a plot with 3 columns with uneven widths defined layout(matrix(1:3, ncol = 3), widths = c(1/5, 2/5, 2/5)) # show the 3 regions layout.show(3) HTH, Marc Schwartz __ 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.
Re: [R] warning In fun(...) : no DISPLAY variable so Tk is not available
Nevil Amos wrote: I am getting the above warning following loading of Geneland 3.1.5 on unix , while a simple plot sends output to the pdf file ( see attached code) no output results from Geneland functions, resulting in empty pdf files That message is saying it can't find an X11 server for Tcltk to use. If you do have X11 available, then just set the DISPLAY environment variable in the normal way; if you don't, then you're not going to be able to use that package on Unix. (The Windows implementation is self-contained, so it should work there.) Duncan Murdoch library (Geneland) Loading required package: RandomFields Loading required package: fields Loading required package: spam Package 'spam' is loaded. Spam version 0.21-0 (2010-03-13). Type demo( spam) for some demos, help( Spam) for an overview of this package. Help for individual functions is optained by adding the suffix '.spam' to the function name, e.g. 'help(chol.spam)'. Attaching package: 'spam' The following object(s) are masked from 'package:base': backsolve, forwardsolve, norm Try help(fields) for an overview of this library fields web: http://www.image.ucar.edu/Software/Fields Loading required package: mapproj Loading required package: maps Loading required package: snow Loading required package: tcltk Loading Tcl/Tk interface ... done ooo oGeneland is loaded o o o o* Please * o o o oRegister on o ohttp://folk.uio.no/gillesg/Geneland/register.php o o o oSee manual ono ohttp://folk.uio.no/gillesg/Geneland/Geneland.htmlo o o oThis is Geneland-3.1.5 o o o ooo Warning message: In fun(...) : no DISPLAY variable so Tk is not available pdf(test.pdf) plot(1:10,1:10) dev.off() null device __ 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. __ 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.
[R] simpleError in storage.mode(y)
bonjour en travaillant avec un logiciel Multiple source methode, j'ai eu ce message d'erreur : simpleError in storage.mode(y) - double: invalid to change the storage mode of a factor en recherchant sur le net , c'est un message universel svp, que signifiera ce message ? merci pour votre intérêt anzid -- View this message in context: http://r.789695.n4.nabble.com/simpleError-in-storage-mode-y-tp2235745p2235745.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Linear Discriminant Analysis in R
Thanks for being patient with me. I guess my problem is with understand how grouping in this particular case is used: one of the sample codes I found online (http://www.statmethods.net/advstats/discriminant.html) library(MASS) fit - lda(G ~ x1 + x2 + x3, data=mydata, na.action=na.omit, CV=TRUE) the mydata file in my case is the 3dmaskdump file with 52 columns and 671 rows (all values range between 0 and 1 after they're scaled) the other file, what I assumed was the grouping file (or the vowel_feature) is the file that defines features for the vowels (i.e. column 1 of the file is vowel name (a, i, u) and every other column in a distinct combination of 0's and 1's defining the vowel (so this file has 26 columns and 254 rows). Therefore, every column that follows represents a particular feature of that vowel.. (hope this makes sense!!) So, the reason I wanted to return G - vowel_feature[15] in my previous post is because I need to extract a column that represents backness of the vowel (while other columns represent roundedness, nasalization features, etc). So what (in my mind) G - vowel_feature[15] would return is 1 column which is 254 rows long with 0's and 1's in it. i.e. 1 0 2 1 3 1 4 0 ... .. . 2541 I am a novice with R (so I know my questions are pretty dumb!), but I really hope I clarified my confusion a bit better. I very much appreciate your help. Looking forward to your replies. Thank you again, Cobbler -- View this message in context: http://r.789695.n4.nabble.com/Linear-Discriminant-Analysis-in-R-tp2231922p2235777.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] R on the iPhone/iPad? Not so much....a GPL violation
Android FTW? On Sat, May 29, 2010 at 11:12 AM, Marc Schwartz marc_schwa...@me.com wrote: Hi all, There have been posts in the past about R being made available for the iPhone and perhaps more logically now, on the iPad. My recollection is that the hurdle discussed in the past was primarily a lack of access to a CLI on the iPhone's variant of OSX, compelling the development of a GUI interface for R specifically for these devices. R itself, can be successfully compiled with the iPhone development tools. Well, now there is another, clearly more profound reason. The FSF has recently communicated with Apple on the presence of a GPL application (GNU Go) in the iTunes store because the iTunes TOS infringes upon the GPL. Apple, given a choice, elected to remove the application, rather than amending their TOS. The FSF also informed the developers of the iPhone port of GNU Go that their distribution is in violation of the GPL. R Core and any others considering an iPhone/iPad port of R, if you are not already aware, take note... More information is here: http://www.fsf.org/news/2010-05-app-store-compliance/ with an update here: http://www.fsf.org/news/blogs/licensing/more-about-the-app-store-gpl-enforcement So, until Apple amends their TOS agreement, it looks like there will be no GPL apps available for the iPhone/iPad, since the only way to make applications available for these platforms is via the iTunes store (unless you unlock the device). Hence, no R for these devices in the foreseeable future. BTW, I am posting this as an FYI, not as a catalyst for a discussion on the political aspects of this situation. So please, let's not go there... :-) Regards, Marc Schwartz __ 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. __ 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.
Re: [R] logarithmic integrals in R?
Thanks for the information. On Sat, May 29, 2010 at 01:15:29PM +, Hans W. Borchers wrote: Oliver Kullmann O.Kullmann at swansea.ac.uk writes: Hello, I couldn't find information on whether the logarithmic integrals Li_m(x) = integral_0^x log(t)^(-m) dt for x = 0 are available in R? I saw your request only this weekend. The first logarithmic integral can be computed using the exponential integral Ei(x) per li(x) = Ei(log(x)) I found gsl at http://cran.r-project.org/web/packages/gsl/index.html. and elliptic integrals are part of the 'gsl' package, so library('gsl') x - seq(2, 10, by=0.5) y - expint_Ei(log(x)) y See e.g. the Handbook of Mathematical Functions for how to reduce higher logarithmic integrals. However here I wasn't succesful: Going through the chapter http://www.math.ucla.edu/~cbm/aands/page_228.htm I didn't find any mentioning of the higher logarithmic integrals. Another possibility is to use the Web API of 'keisan', the calculation library of Casio. Interesting; but again only li(x). Also a google search on higher logarithmic integrals, logarithmic integrals or li_n(x) doesn't reveal anything, so I would be thankful for a hint. Thanks again! Oliver __ 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.
Re: [R] simpleError in storage.mode(y)
hello, I am working with multiple source software method, I got this error message: simpleError in storage.mode (y) - double: invalid to change the mode of a storage factor searching the net is a universal message please, what does mean this message? thank you for your interest anzid -- View this message in context: http://r.789695.n4.nabble.com/simpleError-in-storage-mode-y-tp2235745p2235908.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Linear Discriminant Analysis in R
It's not your questions, Cobbler, but could you PLEASE just do what we asked for? Copy-paste the following in R and copy-paste ALL output you get in your next mail. test.vowel - vowel_features[,1:10] test.mask - mask_features[,1:10] dput(test.vowel) dput(test.mask) I don't know whether your vowel_features is a list or a data-frame (which is technically also a list). But I know for sure that vowel_features[15] is NOT giving you a column. Probably it has to be vowel_features[,15]. So start with that one, and I'll take a look at the rest to get your lda running. Cheers Joris On Sat, May 29, 2010 at 6:53 PM, cobbler_squad la.f...@gmail.com wrote: Thanks for being patient with me. I guess my problem is with understand how grouping in this particular case is used: one of the sample codes I found online (http://www.statmethods.net/advstats/discriminant.html) library(MASS) fit - lda(G ~ x1 + x2 + x3, data=mydata, na.action=na.omit, CV=TRUE) the mydata file in my case is the 3dmaskdump file with 52 columns and 671 rows (all values range between 0 and 1 after they're scaled) the other file, what I assumed was the grouping file (or the vowel_feature) is the file that defines features for the vowels (i.e. column 1 of the file is vowel name (a, i, u) and every other column in a distinct combination of 0's and 1's defining the vowel (so this file has 26 columns and 254 rows). Therefore, every column that follows represents a particular feature of that vowel.. (hope this makes sense!!) So, the reason I wanted to return G - vowel_feature[15] in my previous post is because I need to extract a column that represents backness of the vowel (while other columns represent roundedness, nasalization features, etc). So what (in my mind) G - vowel_feature[15] would return is 1 column which is 254 rows long with 0's and 1's in it. i.e. 1 0 2 1 3 1 4 0 ... .. . 2541 I am a novice with R (so I know my questions are pretty dumb!), but I really hope I clarified my confusion a bit better. I very much appreciate your help. Looking forward to your replies. Thank you again, Cobbler -- View this message in context: http://r.789695.n4.nabble.com/Linear-Discriminant-Analysis-in-R-tp2231922p2235777.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be --- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[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.
[R] modifying only certain rows in a data-frame
Hi, I have a data-frame r (shown below is a subset) with the following column names: datetimesamplevctnormhctdeltact $time has 8 levels: 0h, 0.5h, .24h. $deltact holds real numbers. I want to subset this dataframe by the levels of $time. For all the rows which have r$time == 0h I would like to convert the present value of r$deltact to 0. Any pointers to a simple method to accomplish would be greatly appreciated. TIA, Anjan -- === anjan purkayastha, phd. research associate fas center for systems biology, harvard university 52 oxford street cambridge ma phone-703.740.6939 === [[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.
Re: [R] modifying only certain rows in a data-frame
try something like: r$deltact[r$time == '0h'] - 0 On Sat, May 29, 2010 at 7:50 PM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com wrote: Hi, I have a data-frame r (shown below is a subset) with the following column names: date time sample vct norm hct deltact $time has 8 levels: 0h, 0.5h, .24h. $deltact holds real numbers. I want to subset this dataframe by the levels of $time. For all the rows which have r$time == 0h I would like to convert the present value of r$deltact to 0. Any pointers to a simple method to accomplish would be greatly appreciated. TIA, Anjan -- === anjan purkayastha, phd. research associate fas center for systems biology, harvard university 52 oxford street cambridge ma phone-703.740.6939 === [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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.
[R] Count the number of consecutive 1's
Hi All, We have a raw dataset that, on the sampling time column, for example: t - c(0,1,2,5,0,5,0,2,5) And we need to create a second column that indicates the day of the sampling, so the end result of what we want is a vector: 1,1,1,1,2,2,3,3,3 Additional information that might simplify the matter is that, for each day, the time starts with zero and ends with 5. I am a beginner with R. So far I have: t - c(0,1,2,5,0,5,0,2,5) rownum = length(t) y - NULL y0 - NULL y1 - NULL x - ifelse (t!=5,x-1,x-0) for (i in 1:rownum){ if (x==1) { y - y+x } else {y+1 then y0-sum(y) then y=0 } y1 - c(y1,y0) } y2 - y1 y2 - y2[y2!=0] y2 Day - NULL for (i in 1:length(y2)){ z - rep(i,y2[i]) Day - c(Day,z)} Day # want 1,1,1,1,2,2,3,3,3 here I think my if else statement has syntax error and that's what is causing the problem. What I am trying to do with the loop is, to start counting the number in x, and whenever it reaches a x=zero (same as t=5), then sum up how many 1's it has so far and store it into new variable y0 and then reset y to zero to start counting again. Suggestions about alternative ways to do this is also welcome. Thanks in advance for your yelp. Phyllis Chan. _ Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. N:WL:en-US:WM_HMP:042010_1 __ 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.
Re: [R] Count the number of consecutive 1's
Assuming that each day does start with 0, this should do it: t - c(0,1,2,5,0,5,0,2,5) cumsum(t==0) [1] 1 1 1 1 2 2 3 3 3 On Sat, May 29, 2010 at 8:33 PM, Phyllis Hui-Min Chan h-mc...@hotmail.com wrote: Hi All, We have a raw dataset that, on the sampling time column, for example: t - c(0,1,2,5,0,5,0,2,5) And we need to create a second column that indicates the day of the sampling, so the end result of what we want is a vector: 1,1,1,1,2,2,3,3,3 Additional information that might simplify the matter is that, for each day, the time starts with zero and ends with 5. I am a beginner with R. So far I have: t - c(0,1,2,5,0,5,0,2,5) rownum = length(t) y - NULL y0 - NULL y1 - NULL x - ifelse (t!=5,x-1,x-0) for (i in 1:rownum){ if (x==1) { y - y+x } else {y+1 then y0-sum(y) then y=0 } y1 - c(y1,y0) } y2 - y1 y2 - y2[y2!=0] y2 Day - NULL for (i in 1:length(y2)){ z - rep(i,y2[i]) Day - c(Day,z)} Day # want 1,1,1,1,2,2,3,3,3 here I think my if else statement has syntax error and that's what is causing the problem. What I am trying to do with the loop is, to start counting the number in x, and whenever it reaches a x=zero (same as t=5), then sum up how many 1's it has so far and store it into new variable y0 and then reset y to zero to start counting again. Suggestions about alternative ways to do this is also welcome. Thanks in advance for your yelp. Phyllis Chan. _ Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. N:WL:en-US:WM_HMP:042010_1 __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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.
[R] Question about package coin
Anyone know if coin can run a permutation test based on a (user-defined) statistic other than the mean difference? The function independence_test does the permutation t-test via difference in means. I'm wondering if it's possible to use independence_test to run a permutation test for some other statistic than the difference in means. For example, I'd like to run a permutation test using Welch's t instead of the difference in means. The help for independence_test reveals that teststat is an argument which allows for specification of standardized scalar test statistic, a maximum type statistic, or a quadratic form. I cannot, however, figure out if it is possible to specify how the statistic should be calculated by, for example, supplying a function. There are other mentions of test statistic in the help file but they all seem to have to do with the names of classes or objects which can be retrieved from coin output. Bryan --- Bryan Keller, Doctoral Student/Project Assistant Educational Psychology - Quantitative Methods The University of Wisconsin - Madison __ 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.
Re: [R] Selecting first 7 elements
What if I want to select the 8th to 14th element of the list? I tried to use [ again, but it doesn't work. [ is a function, and you want to use it on each element of the list, so... lapply(x, [, c(1:7)) and the call to c() is of course not necessary, since : will generate a vector. __ r-h...@r-project.org mailing listhttps://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. -- You received this message because you are subscribed to the Google Groups R-help-archive group. To post to this group, send email to r-help-arch...@googlegroups.com. To unsubscribe from this group, send email to r-help-archive+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/r-help-archive?hl=en. __ r-h...@r-project.org mailing listhttps://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. -- You received this message because you are subscribed to the Google Groups R-help-archive group. To post to this group, send email to r-help-arch...@googlegroups.com. To unsubscribe from this group, send email to r-help-archive+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/r-help-archive?hl=en. __ 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.
[R] Using RODBC to read CSV
Hi all, When I use ODBC to manage my datasets, I have a question about sqlFetch below. It seems that my datasets have successfully been identified but the function sqlFetch get an error when I want to read the table. And below is the questionable code. Thanks for your help! library(RODBC) stock-odbcConnect(stock) sqlTables(stock) TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS 1 F:\\DOWNLOAD\\STOCKNA 1990.csv TABLENA 2 F:\\DOWNLOAD\\STOCKNA 1996.csv TABLENA 3 F:\\DOWNLOAD\\STOCKNA 1998.csv TABLENA 4 F:\\DOWNLOAD\\STOCKNA 1999.csv TABLENA 5 F:\\DOWNLOAD\\STOCKNA 2000.csv TABLENA 6 F:\\DOWNLOAD\\STOCKNA 2001.csv TABLENA 7 F:\\DOWNLOAD\\STOCKNA 2002.csv TABLENA 8 F:\\DOWNLOAD\\STOCKNA 2003.csv TABLENA 9 F:\\DOWNLOAD\\STOCKNA 2004.csv TABLENA 10 F:\\DOWNLOAD\\STOCKNA 2005.csv TABLENA 11 F:\\DOWNLOAD\\STOCKNA 2006.csv TABLENA 12 F:\\DOWNLOAD\\STOCKNA 2007.csv TABLENA 13 F:\\DOWNLOAD\\STOCKNA 2008.csv TABLENA 14 F:\\DOWNLOAD\\STOCKNA 2009.csv TABLENA 15 F:\\DOWNLOAD\\STOCKNA 2010.csv TABLENA 16 F:\\DOWNLOAD\\STOCKNA test.csv TABLENA 17 F:\\DOWNLOAD\\STOCKNA test1.csv TABLENA sqlFetch(stock,test.csv) ´íÎóÓÚodbcTableExists(channel, sqtable) : ¡®test.csv¡¯: table not found on channel [[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.
[R] How to interpret a result based on wmtsa
Dear R family I have a question as to how to get an answer I want to derive with the outcome from R-package, wmtsa. My concern is that I want to decide equivalent degrees of freedom (EDOF) based on the following outcome. library(wmtsa) W - wavMODWT(X, wavelet=s8) z1 - wavEDOF(W) print(z1) #Intentionally, I do not assign n.levels and specify SDF. The following is the outcome R gave out: ## $EDOF1 d1 d2 d3 d4 d5 d6 272462.52504 189076.44195 95736.37691 47830.40918 23593.41513 12409.42279 d7 d8 d9 d10 d11 d12 5977.28418 2887.81182 1408.06198629.46550368.87030197.00823 d13 d14 d15 106.22607 29.75633 14.29115 $EDOF2 [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA $EDOF3 d1 d2 d3 d4 d5 d6 2.079385e+05 1.039658e+05 5.197938e+04 2.598619e+04 1.298959e+04 6.491297e+03 d7 d8 d9 d10 d11 d12 3.242148e+03 1.617574e+03 8.052871e+02 3.991436e+02 1.960718e+02 9.453589e+01 d13 d14 d15 4.376794e+01 1.838397e+01 5.691986e+00 $variance.unbiased d1 d2 d3 d4 d5 d6 1.940001e+03 9.671358e+02 4.815657e+02 2.402054e+02 1.206654e+02 6.019255e+01 d7 d8 d9 d10 d11 d12 3.021483e+01 1.518668e+01 7.709990e+00 3.859226e+00 1.850228e+00 9.825597e-01 d13 d14 d15 4.609490e-01 6.416134e-02 1.513369e-02 $n.coeff d1 d2 d3 d4 d5 d6 d7 d8 d9d10d11 415877 415863 415835 415779 415667 415443 414995 414099 412307 408723 401555 d12d13d14d15 387219 358547 301203 186515 # How could I determine the equivalent degrees of freedom? It would be great if you give me any suggestion. best moohwan [[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.
[R] what command to use for standization
what command to use to standardize my data to mean = 0, and SD=1. the data I want to standardize/centroid is in column format. So I'm thinking of using: col.mean.stdised=apply(data.df,2,function(z){z-mean(z)}) but, what command should I use to put my SD =1? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/what-command-to-use-for-standization-tp2236074p2236074.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] what command to use for standization
?scale HTH, Jorge On Sun, May 30, 2010 at 12:20 AM, Philip Wong wrote: what command to use to standardize my data to mean = 0, and SD=1. the data I want to standardize/centroid is in column format. So I'm thinking of using: col.mean.stdised=apply(data.df,2,function(z){z-mean(z)}) but, what command should I use to put my SD =1? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/what-command-to-use-for-standization-tp2236074p2236074.html Sent from the R help mailing list archive at Nabble.com. __ 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. [[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.
[R] Vector docs
Hi The docs for R are very practical, which is quite refreshing compared to other languages, however I can't find any details about all the things I can do with a vector. I'm expecting methods like vector.contains('foo') and vector.remove('foo'), maybe those methods don't exist but I'd love to find a page that details the ones that do. I'd also like to find some docs about foreach loops (unless there's a better way to iterate through a vector), I've only found mailing list posts. Thanks __ 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.