Re: [R] merge matrix row data
Hello arun Thanks for the answers. I understand the answer to question 2. However, about question 1, sorry I did not clarify the question. 1. If the row names are 1, 2, and 4 etc (numbers) instead of GID 1, GID 2, and GID 3, is there any modification in need for the code ? The original data looks like below. Original matrix GID D0989 D9820 D5629 D4327 D2134 1 100 1 0 2 011 0 0 4 001 0 0 5 110 0 0 7 010 0 1 Resulting matrix D0989 D9820 D5629 D4327 D2134 Island A 11 0 1 0 Island B 01 1 0 1 Elaine On Thu, Aug 1, 2013 at 7:15 AM, arun smartpink...@yahoo.com wrote: Hi Elaine, In that case: Do you have GID in the IslandA and IslandBs? IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7) If there is no change in the two Islands, then using the same dataset: mat1- as.matrix(read.table(text= D0989 D9820 D5629 D4327 D2134 GID_1100 1 0 GID_2011 0 0 GID_4001 0 0 GID_5110 0 0 GID_7010 0 1 ,sep=,header=TRUE)) row.names(mat1)- gsub(.*\\_,,row.names(mat1)) #to replace the GID_ from the row.names() mat1 # D0989 D9820 D5629 D4327 D2134 #1 1 0 0 1 0 #2 0 1 1 0 0 #4 0 0 1 0 0 #5 1 1 0 0 0 #7 0 1 0 0 1 IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7) res-t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];(!!colSums(x1))*1})) res # D0989 D9820 D5629 D4327 D2134 #IslandA 1 1 0 1 0 #IslandB 0 1 1 0 1 Regarding the use of !!colSums() You can check these: t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];!colSums(x1)})) #D0989 D9820 D5629 D4327 D2134 #IslandA FALSE FALSE TRUE FALSE TRUE #IslandB TRUE FALSE FALSE TRUE FALSE t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];!!colSums(x1)})) #D0989 D9820 D5629 D4327 D2134 #IslandA TRUE TRUE FALSE TRUE FALSE #IslandB FALSE TRUE TRUE FALSE TRUE # *1 will replace TRUE with 1 and FALSE with 0. A.K. From: Elaine Kuo elaine.kuo...@gmail.com To: arun smartpink...@yahoo.com Sent: Wednesday, July 31, 2013 6:58 PM Subject: Re: [R] merge matrix row data Dear Arun, Thank you for the clear explanation. The row.names question is a mistyping, for I do not have enough sleep last night. Two more questions 1. If the row names are 1, 2, and 4 etc (numbers) instead of GID 1, GID 2, and GID 3, is there any modification in need for the code ? 2. Please kindly explain the code (!!colSums(x1))*1} It is the critical part to merge the row data. Thanks again. Elaine On Thu, Aug 1, 2013 at 6:45 AM, arun smartpink...@yahoo.com wrote: Dear Elaine, I used that line only because you didn't provide the data using dput(). So, I need to either use delimiter , or just leave a space by first joining the GID and the numbers using _. I chose the latter as I didn't had that much time to spent by putting , between each entries. After that, I removed _ using the ?gsub(). As Bert pointed out, there are many online resources for understanding regular expression. In this particular case, what I did was to single out the _ in the first pair of quotes, and replace with space in the second pair of quotes . Therefore, GID_1, would become GID 1, which is what your original dataset looks like. If you type row.names(mat1) on the R console and enter, you will be able to get the output. Hope it helps. Arun From: Elaine Kuo elaine.kuo...@gmail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Wednesday, July 31, 2013 5:07 PM Subject: Re: [R] merge matrix row data Dear Arun Thank you for the very useful help. However, please kindly explain the code below. row.names(mat1)- gsub([_], ,row.names(mat1)) 1. what does [_] mean? 2. what doesmean? 3. what does row.names(mat1) mean? I checked ?gsub but still did not get the idea. Thank you again Elaine On Wed, Jul 31, 2013 at 9:35 PM, arun smartpink...@yahoo.com wrote: HI, Please use ?dput() mat1- as.matrix(read.table(text= D0989 D9820 D5629 D4327 D2134 GID_1100 1 0 GID_2011 0 0 GID_4001 0 0 GID_5110 0
Re: [R] merge matrix row data
Hello Arun Thank for comments. You are right. GID is the first column in the matrix this time. In the second row of the first column, it used to be GID 1 in the first e-mail. But you are also right. You answered it already, and this time In the second row of the first column is 1. Below is part of dput()(too many columns) .. .Names = c(GID, D5291, D5293, D7414, D7415, D7416, D7417, D7418, D7419, D7420, D7421, D7422, D7423, D7424, D7425, D7426, D7427, D7428, D7429, D7430, D7431, D7432, D7433, D7434, D7435, D7436, D7437, D7438, D7439, D7440, D7441, D7442, D7443, D7444, D7445, D7446, Elaine On Thu, Aug 1, 2013 at 12:35 PM, arun smartpink...@yahoo.com wrote: Hi Elaine, I am not sure how your original matrix keeps on changing from the original post. Here, your statement about rownames are 1, 2, 4 (the answer I already provided in the last post) and the matrix you showed looks different. It seems like GID is the first column in the matrix. I requested you to dput() the data to reduce these confusions. mat1-as.matrix(read.table(text= GID D0989 D9820 D5629 D4327 D2134 1 100 1 0 2 011 0 0 4 001 0 0 5 110 0 0 7 010 0 1 ,sep=,header=TRUE)) IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7)t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),mat1[,1]),-1];(!!colSums(x1))*1})) #D0989 D9820 D5629 D4327 D2134 #IslandA 1 1 0 1 0 #IslandB 0 1 1 0 1 A.K. From: Elaine Kuo elaine.kuo...@gmail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Thursday, August 1, 2013 12:00 AM Subject: Re: [R] merge matrix row data Hello arun Thanks for the answers. I understand the answer to question 2. However, about question 1, sorry I did not clarify the question. 1. If the row names are 1, 2, and 4 etc (numbers) instead of GID 1, GID 2, and GID 3, is there any modification in need for the code ? The original data looks like below. Original matrix GID D0989 D9820 D5629 D4327 D2134 1 100 1 0 2 011 0 0 4 001 0 0 5 110 0 0 7 010 0 1 Resulting matrix D0989 D9820 D5629 D4327 D2134 Island A 11 0 1 0 Island B 01 1 0 1 Elaine On Thu, Aug 1, 2013 at 7:15 AM, arun smartpink...@yahoo.com wrote: Hi Elaine, In that case: Do you have GID in the IslandA and IslandBs? IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7) If there is no change in the two Islands, then using the same dataset: mat1- as.matrix(read.table(text= D0989 D9820 D5629 D4327 D2134 GID_1100 1 0 GID_2011 0 0 GID_4001 0 0 GID_5110 0 0 GID_7010 0 1 ,sep=,header=TRUE)) row.names(mat1)- gsub(.*\\_,,row.names(mat1)) #to replace the GID_ from the row.names() mat1 # D0989 D9820 D5629 D4327 D2134 #1 1 0 0 1 0 #2 0 1 1 0 0 #4 0 0 1 0 0 #5 1 1 0 0 0 #7 0 1 0 0 1 IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7) res-t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];(!!colSums(x1))*1})) res # D0989 D9820 D5629 D4327 D2134 #IslandA 1 1 0 1 0 #IslandB 0 1 1 0 1 Regarding the use of !!colSums() You can check these: t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];!colSums(x1)})) #D0989 D9820 D5629 D4327 D2134 #IslandA FALSE FALSE TRUE FALSE TRUE #IslandB TRUE FALSE FALSE TRUE FALSE t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];!!colSums(x1)})) #D0989 D9820 D5629 D4327 D2134 #IslandA TRUE TRUE FALSE TRUE FALSE #IslandB FALSE TRUE TRUE FALSE TRUE # *1 will replace TRUE with 1 and FALSE with 0. A.K. From: Elaine Kuo elaine.kuo...@gmail.com To: arun smartpink...@yahoo.com Sent: Wednesday, July 31, 2013 6:58 PM Subject: Re: [R] merge matrix row data Dear Arun, Thank you for the clear explanation. The row.names question is a mistyping, for I do not have enough sleep last night. Two more questions 1. If the row names are 1, 2, and 4 etc (numbers) instead
Re: [R] merge matrix row data
Hi Elaine, I am not sure how your original matrix keeps on changing from the original post. Here, your statement about rownames are 1, 2, 4 (the answer I already provided in the last post) and the matrix you showed looks different. It seems like GID is the first column in the matrix. I requested you to dput() the data to reduce these confusions. mat1-as.matrix(read.table(text= GID D0989 D9820 D5629 D4327 D2134 1 1 0 0 1 0 2 0 1 1 0 0 4 0 0 1 0 0 5 1 1 0 0 0 7 0 1 0 0 1 ,sep=,header=TRUE)) IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7)t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),mat1[,1]),-1];(!!colSums(x1))*1})) # D0989 D9820 D5629 D4327 D2134 #IslandA 1 1 0 1 0 #IslandB 0 1 1 0 1 A.K. From: Elaine Kuo elaine.kuo...@gmail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Thursday, August 1, 2013 12:00 AM Subject: Re: [R] merge matrix row data Hello arun Thanks for the answers. I understand the answer to question 2. However, about question 1, sorry I did not clarify the question. 1. If the row names are 1, 2, and 4 etc (numbers) instead of GID 1, GID 2, and GID 3, is there any modification in need for the code ? The original data looks like below. Original matrix GID D0989 D9820 D5629 D4327 D2134 1 1 0 0 1 0 2 0 1 1 0 0 4 0 0 1 0 0 5 1 1 0 0 0 7 0 1 0 0 1 Resulting matrix D0989 D9820 D5629 D4327 D2134 Island A 1 1 0 1 0 Island B 0 1 1 0 1 Elaine On Thu, Aug 1, 2013 at 7:15 AM, arun smartpink...@yahoo.com wrote: Hi Elaine, In that case: Do you have GID in the IslandA and IslandBs? IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7) If there is no change in the two Islands, then using the same dataset: mat1- as.matrix(read.table(text= D0989 D9820 D5629 D4327 D2134 GID_1 1 0 0 1 0 GID_2 0 1 1 0 0 GID_4 0 0 1 0 0 GID_5 1 1 0 0 0 GID_7 0 1 0 0 1 ,sep=,header=TRUE)) row.names(mat1)- gsub(.*\\_,,row.names(mat1)) #to replace the GID_ from the row.names() mat1 # D0989 D9820 D5629 D4327 D2134 #1 1 0 0 1 0 #2 0 1 1 0 0 #4 0 0 1 0 0 #5 1 1 0 0 0 #7 0 1 0 0 1 IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7) res-t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];(!!colSums(x1))*1})) res # D0989 D9820 D5629 D4327 D2134 #IslandA 1 1 0 1 0 #IslandB 0 1 1 0 1 Regarding the use of !!colSums() You can check these: t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];!colSums(x1)})) # D0989 D9820 D5629 D4327 D2134 #IslandA FALSE FALSE TRUE FALSE TRUE #IslandB TRUE FALSE FALSE TRUE FALSE t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];!!colSums(x1)})) # D0989 D9820 D5629 D4327 D2134 #IslandA TRUE TRUE FALSE TRUE FALSE #IslandB FALSE TRUE TRUE FALSE TRUE # *1 will replace TRUE with 1 and FALSE with 0. A.K. From: Elaine Kuo elaine.kuo...@gmail.com To: arun smartpink...@yahoo.com Sent: Wednesday, July 31, 2013 6:58 PM Subject: Re: [R] merge matrix row data Dear Arun, Thank you for the clear explanation. The row.names question is a mistyping, for I do not have enough sleep last night. Two more questions 1. If the row names are 1, 2, and 4 etc (numbers) instead of GID 1, GID 2, and GID 3, is there any modification in need for the code ? 2. Please kindly explain the code (!!colSums(x1))*1} It is the critical part to merge the row data. Thanks again. Elaine On Thu, Aug 1, 2013 at 6:45 AM, arun smartpink...@yahoo.com wrote: Dear Elaine, I used that line only because you didn't provide the data using dput(). So, I need to either use delimiter , or just leave a space by first joining the GID and the numbers using _. I chose the latter as I didn't had that much time to spent by putting , between each entries. After that, I removed _ using the ?gsub(). As Bert pointed out, there are many online resources for understanding regular expression. In this particular case, what I did was to single out the _ in the first pair of
[R] EMMIX
Is the R package EMMIX available ? I tried installing it and it keeps saying the package is not available for R verseion 3.0.1 teotjunk [[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] EMMIX
Hello, According to the list of available packages, there is no EMMIX package. You probably should use a web search engine to find where you can download a EMMIX version for R. Regards, Pascal 2013/8/1 Tjun Kiat Teo teotj...@gmail.com Is the R package EMMIX available ? I tried installing it and it keeps saying the package is not available for R verseion 3.0.1 teotjunk [[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. [[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 Help.
Hello R Project, I am having a little trouble with interpreting my GLM results and I wonder if you may be able to help. I am doing a generalised linear model in R studio by outcome variable is binary either effected or not effected. I have my final model structure which has been validated and fits well. But, I am having some trouble understanding how to produce graphs and show the results visually. I have one significant main effect variable which is continuos and I have one 3 way interaction which is highly significant. My problem is I dont have any idea what to do next Please can you help? Help with either advise on how to preform these visual interpretations or introduce someone to me who might be willing to do the analysis for me if i sent them my data and script. For this I would offer payment for there time- Have a great day, Kindest regards, Darren [[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] Issue when using a coxph + summary function in R while using a pspline-transformed covariate
Hello I have an issue with obtaining a confidence interval from a coxph object in R while using a spline-transformed covariate. This is a time to event analysis using coxph() from the survival package. In the model below, COVA is a continuous covariate. COVA is time-dependent hence the counting process notation. COVA is transformed via pspline, COVB (FALSE or TRUE) is a fixed covariate. My goal is to get the confidence interval for COVB. With this purpose, I use the summary(…,conf.int=.95) function. I have pasted the code and the console below. The estimation works well. The summary function returns the desired confidence interval in the console, but it returns a NULL object (psp.sum is returned NULL, see below the code and the console) Note that if I do not use pspline, it works ! So it seems that the use of pspline is not compatible with the summary function. This is a problem because I would like to do some simulation and need to retrieve the confidence interval from psp.sum. Can you kindly help? Rgds Tom CODE psp-coxph(Surv(DAY2,DAY2P1,EVTF)~COVB+pspline(COVA, df = 0, caic = T),data=dsn4,method='breslow') psp psp.sum-summary(psp,conf.int=.95) psp.sum CONSOLE 1 psp-coxph(Surv(DAY2,DAY2P1,EVTF)~COVB+pspline(COVA, df = 0, caic = T),data=dsn4,method='breslow') 1 psp Call: coxph(formula = Surv(DAY2, DAY2P1, EVTF) ~ COVB + pspline(COVA, df = 0, caic = T), data = dsn4, method = breslow) coef se(coef) se2 Chisq DF p COVBTRUE -1.625 0.4223 0.4198 14.80 1.00 1.2e-04 pspline(COVA, df = 0, caic -0.341 0.0761 0.0761 20.04 1.00 7.6e-06 pspline(COVA, df = 0, caic 1.95 0.83 1.3e-01 Iterations: 10 outer, 29 Newton-Raphson Theta= 0.98 Degrees of freedom for terms= 1.0 1.8 Likelihood ratio test=22.3 on 2.81 df, p=4.52e-05 n= 16933 1 psp.sum-summary(psp,conf.int=.95) Call: coxph(formula = Surv(DAY2, DAY2P1, EVTF) ~ COVB + pspline(COVA, df = 0, caic = T), data = dsn4, method = breslow) n= 16933, number of events= 35 coef se(coef) se2 Chisq DF p COVBTRUE -1.625 0.4223 0.4198 14.80 1.00 1.2e-04 pspline(COVA, df = 0, caic -0.341 0.0761 0.0761 20.04 1.00 7.6e-06 pspline(COVA, df = 0, caic 1.95 0.83 1.3e-01 exp(coef) exp(-coef) lower .95 upper .95 COVBTRUE 0.19690 5.08 8.61e-02 0.4506 ps(COVA)3 0.59903 1.67 3.48e-01 1.0301 ps(COVA)4 0.35872 2.79 1.36e-01 0.9470 ps(COVA)5 0.21394 4.67 5.82e-02 0.7857 ps(COVA)6 0.12594 7.94 2.69e-02 0.5898 ps(COVA)7 0.07290 13.72 1.31e-02 0.4051 ps(COVA)8 0.04275 23.39 6.84e-03 0.2673 ps(COVA)9 0.02647 37.78 3.89e-03 0.1802 ps(COVA)10 0.01785 56.04 2.45e-03 0.1301 ps(COVA)11 0.01310 76.32 1.68e-03 0.1024 ps(COVA)12 0.01019 98.11 1.19e-03 0.0870 ps(COVA)13 0.00810 123.39 8.32e-04 0.0790 ps(COVA)14 0.00645 154.95 5.43e-04 0.0767 ps(COVA)15 0.00512 195.45 3.26e-04 0.0803 ps(COVA)16 0.00405 246.92 1.80e-04 0.0913 ps(COVA)17 0.00320 312.04 9.11e-05 0.1127 ps(COVA)18 0.00254 394.32 4.29e-05 0.1499 ps(COVA)19 0.00201 498.30 1.89e-05 0.2133 Iterations: 10 outer, 29 Newton-Raphson Theta= 0.98 Degrees of freedom for terms= 1.0 1.8 Concordance= 0.673 (se = 0.05 ) Rsquare= 0.001 (max possible= 0.026 ) Likelihood ratio test= 22.3 on 2.81 df, p=4.52e-05 Wald test = 24.6 on 2.81 df, p=1.48e-05 1 psp.sum NULL 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] List of lists
Hi, The solution that works now is closeAllConnections() But even if I replace the 'list' with the 'array' I get a similar error. Exception is Error in UseMethod(\close\): no applicable method for 'close' applied to an object of class \c('double', 'numeric')\\n #Write each CPU's utilization data into a #separate file filelist.array - function(n){ cpufile - list() cpufiledescriptors - array(n,dim=c(0,n)) length(cpufile) - n for (i in 1:n) { cpufile[[i]] - paste(output, i, .txt, sep = ) cpufiledescriptors[i]-file( cpufile[[i]], a ) } listoffiles - list(cpufile=cpufile, cpufiledescriptors=cpufiledescriptors) return (listoffiles) } Thanks, Mohan Re: [R] List of lists Jim Lemon to: mohan.radhakrishnan 31-07-2013 05:19 PM On 07/31/2013 04:18 PM, mohan.radhakrish...@polarisft.com wrote: Hi Jim, close(filedescriptors$cpufiledescriptors[[1]]) close(filedescriptors$cpufiledescriptors[[2]]) close(filedescriptors$cpufiledescriptors[[3]]) I might be doing something wrong. Error is Error in UseMethod(close) : no applicable method for 'close' applied to an object of class c ('integer', 'numeric') Hi Mohan, I just ran the code within your function filelist.array and then was able to close the connections I had created. I entered your function in R: filelist.array- function(n){ cpufile- list() cpufiledescriptors- list() length(cpufile)- n for (i in 1:n) { cpufile[[i]]- paste(output, i, .txt, sep = ) cpufiledescriptors[[i]]-file( cpufile[[i]], a ) } listoffiles- list(cpufile=cpufile, cpufiledescriptors=cpufiledescriptors) return (listoffiles) } and then: filedescriptors-filelist.array(3) close(filedescriptors$cpufiledescriptors[[1]]) close(filedescriptors$cpufiledescriptors[[2]]) close(filedescriptors$cpufiledescriptors[[3]]) and it worked fine. Perhaps a typo in your code somewhere? Jim This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.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] Highlight selected bar in barplot
On 08/01/2013 12:57 AM, Jurgens de Bruin wrote: Hi All, I am new at R so any help would be appreciate. Below my current R-code/script: initial.dir-getwd() setwd('/Users/jurgens/VirtualEnv/venv/Projects/QTLS/Resaved_Results') dataset- read.table(LWxANNA_FinalReport_resaved_spwc.csv, header=TRUE, sep=\t ) n- length(dataset$X..No.Call) x- sort(dataset$X..No.Call,partial = n )[n] outlier- dataset[ dataset$X..No.Call quantile(dataset$X..No.Call,0.25) + (IQR(dataset$X..No.Call) *1.5),] par( las=2, cex.axis=0.5, cex.lab=1, cex.main=2, cex.sub=1) barplot(dataset$X..No.Call, names.arg = dataset$Individual.Sample, cex.names=0.5 ,space=0.5, ylim=c(0,x*1.5) ) setwd(initial.dir) I would like to highlight the sample in outlier on the barplot that is create, would this be possible? Hi Jurgens, Even without the data, I think that what you mean by highlight is the major point of confusion. If you have five bars in the resulting barplot and the third one is the one you want to highlight, you could do this: barplot(...,col=c(NA,NA,red,NA,NA),...) You would then have four empty bars and one highlighted in red. You could put an asterisk in the center of the third bar: barpos-barplot(...) text(barpos[3],dataset$X..No.Call[3]/2,*) Just depends upon how you want to highlight the bar in question. 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] merge matrix row data
Hello arun I modified your code a little bit but failed to retrieve the row.names. The response is NULL. Please kindly help and thanks. Elaine Code load(h:/b_W_line/R_workspace/dataset_Residence_2748.RData) dim(dataR) str(dataR) dataR.m- as.matrix(dataR, header=TRUE) dataR.m[,1] row.names(dataR.m) dput(dataR.m) .skipped...0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), .Dim = c(4873L, 14L), .Dimnames = list(NULL, c(GID, D0407, D0409, D0410, D0462, D0463, D0473, D0475, D0488, D0489, D0492, D0493, D0504, D0536 ))) On Thu, Aug 1, 2013 at 1:24 PM, Elaine Kuo elaine.kuo...@gmail.com wrote: Hello Arun Thank for comments. You are right. GID is the first column in the matrix this time. In the second row of the first column, it used to be GID 1 in the first e-mail. But you are also right. You answered it already, and this time In the second row of the first column is 1. Below is part of dput()(too many columns) .. .Names = c(GID, D5291, D5293, D7414, D7415, D7416, D7417, D7418, D7419, D7420, D7421, D7422, D7423, D7424, D7425, D7426, D7427, D7428, D7429, D7430, D7431, D7432, D7433, D7434, D7435, D7436, D7437, D7438, D7439, D7440, D7441, D7442, D7443, D7444, D7445, D7446, Elaine On Thu, Aug 1, 2013 at 12:35 PM, arun smartpink...@yahoo.com wrote: Hi Elaine, I am not sure how your original matrix keeps on changing from the original post. Here, your statement about rownames are 1, 2, 4 (the answer I already provided in the last post) and the matrix you showed looks different. It seems like GID is the first column in the matrix. I requested you to dput() the data to reduce these confusions. mat1-as.matrix(read.table(text= GID D0989 D9820 D5629 D4327 D2134 1 100 1 0 2 011 0 0 4 001 0 0 5 110 0 0 7 010 0 1 ,sep=,header=TRUE)) IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7)t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),mat1[,1]),-1];(!!colSums(x1))*1})) #D0989 D9820 D5629 D4327 D2134 #IslandA 1 1 0 1 0 #IslandB 0 1 1 0 1 A.K. From: Elaine Kuo elaine.kuo...@gmail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Thursday, August 1, 2013 12:00 AM Subject: Re: [R] merge matrix row data Hello arun Thanks for the answers. I understand the answer to question 2. However, about question 1, sorry I did not clarify the question. 1. If the row names are 1, 2, and 4 etc (numbers) instead of GID 1, GID 2, and GID 3, is there any modification in need for the code ? The original data looks like below. Original matrix GID D0989 D9820 D5629 D4327 D2134 1 100 1 0 2 011 0 0 4 001 0 0 5 110 0 0 7 010 0 1 Resulting matrix D0989 D9820 D5629 D4327 D2134 Island A 11 0 1 0 Island B 01 1 0 1 Elaine On Thu, Aug 1, 2013 at 7:15 AM, arun smartpink...@yahoo.com wrote: Hi Elaine, In that case: Do you have GID in the IslandA and IslandBs? IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7) If there is no change in the two Islands, then using the same dataset: mat1- as.matrix(read.table(text= D0989 D9820 D5629 D4327 D2134 GID_1100 1 0 GID_2011 0 0 GID_4001 0 0 GID_5110 0 0 GID_7010 0 1 ,sep=,header=TRUE)) row.names(mat1)- gsub(.*\\_,,row.names(mat1)) #to replace the GID_ from the row.names() mat1 # D0989 D9820 D5629 D4327 D2134 #1 1 0 0 1 0 #2 0 1 1 0 0 #4 0 0 1 0 0 #5 1 1 0 0 0 #7 0 1 0 0 1 IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7) res-t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];(!!colSums(x1))*1})) res # D0989 D9820 D5629 D4327 D2134 #IslandA 1 1 0 1 0 #IslandB 0 1 1 0 1 Regarding the use of !!colSums() You can check these: t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),row.names(mat1)),];!colSums(x1)})) #D0989 D9820 D5629 D4327 D2134 #IslandA FALSE FALSE TRUE FALSE TRUE #IslandB TRUE FALSE FALSE TRUE FALSE t(sapply(c(IslandA,IslandB),function(x) {x1-
Re: [R] heatmap scale parameter question
I do not want to use the b word, but can anyone who also subscribes to the r-developer list forward my observation regarding heatmap? I am pretty confident that the behaviour of heatmap in R 3.0.1 is not that one intended. On 31 July 2013 14:03, Witold E Wolski wewol...@gmail.com wrote: Would anyone of the more experienced r-users explain to me the behaviour of the scale parameter in the heatmap function. different options for scale (R 3.0.1) do change only the colors but do not affect the dendrograms. Please see for yourself executing the following code: d - matrix(rnorm(100),nrow=20) stats::heatmap(d) X11() heatmap(d,scale=column) X11() heatmap(d,scale=row) X11() heatmap(d,scale=none) In all four above cases the dendrograms look exactly the same However, scaling clearly affects clustering. see: d - scale(d) heatmap(d,scale=none) best regards R version 3.0.1 (2013-05-16) -- Good Sport ciao -- Witold Eryk Wolski -- Witold Eryk Wolski -- Witold Eryk Wolski __ 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] readBin into a data frame
Hello. readBin is designed to read a batch of data with the same spec, e.g. read 1 floats into a vector. In practise I read into data frame, not vector. For each data frame, I need to read a integer and a float. for (i in 1:1000) { dataframe$int[i] - readBin(con, integer(), size=2) dataframe$float[i] - readBin(con, numeric(), size=4) } And I need to read 100 such data files, ending up with a for loop in a for loop. Something feels wrong here, as it is being said if you use double-FOR you are not speaking R. What is the R way of doing this? I can think of writing the content of the loop into a function, and vectorize it -- But, the result would be a list of list, not exactly data-frame, and the list grows incrementally, which is inefficient, since I know the size of my data frame at the outset. I am a new learner, not speaking half of R vocabulary, kindly provide some hint please:) Best. __ 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] Resampling
Thank you! I have used the replicate function. In fact, I had just found the solution when I received your answers. Best regards, Rita _ Rita Gamito Centro de Oceanografia Faculdade de Ciências, Universidade de Lisboa Campo Grande, 1749-016 Lisboa, Portugal e-mail: rgam...@fc.ul.pt Tel: + 351 21 750 00 00 - ext. 22575 Fax: + 351 21 750 02 07 www.co.fc.ul.pt __ 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] Use of Bonferroni correction on a set of paired vectors?
Dear all, We are trying to validate a new measurement method by comparing it to a reference method, but we don't manage to find out how to do it... Here are the data we have : *** Sample# ; Ref_1 ; Ref_2 ; Ref_3 ; Ref_4 ; Ref_5 ; Ref_6 ; Ref_7 ; Ref_8 ; Ref_9 ; Ref_10 ; New_1 ; New_2 ; New_3 ; New_4 ; New_5 ; New_6 ; New_7 ; New_8 ; New_9 ; New_10 1 ; 58 ; 56 ; 60 ; 64 ; 76 ; 78 ; 73 ; 73 ; 83 ; 76 ; 61 ; 70 ; 61 ; 61 ; 54 ; 48 ; 60 ; 56 ; 82 ; 63 2 ; 46 ; 51 ; 48 ; 57 ; 61 ; 74 ; 54 ; 63 ; 60 ; 71 ; 77 ; 69 ; 53 ; 56 ; 58 ; 61 ; 64 ; 63 ; 57 ; 71 3 ; 60 ; 79 ; 68 ; 69 ; 70 ; 67 ; 68 ; 71 ; 66 ; 72 ; 76 ; 68 ; 53 ; 82 ; 40 ; 58 ; 51 ; 66 ; 87 ; 68 4 ; 67 ; 59 ; 52 ; 63 ; 61 ; 60 ; 57 ; 54 ; 61 ; 62 ; 71 ; 45 ; 66 ; 56 ; 55 ; 66 ; 56 ; 63 ; 56 ; 76 5 ; 100 ; 112 ; 89 ; 96 ; 111 ; 78 ; 91 ; 93 ; 96 ; 93 ; 92 ; 81 ; 82 ; 102 ; 89 ; 82 ; 69 ; 68 ; 73 ; 98 6 ; 88 ; 77 ; 93 ; 81 ; 77 ; 70 ; 83 ; 67 ; 84 ; 94 ; 81 ; 80 ; 54 ; 101 ; 77 ; 91 ; 104 ; 66 ; 80 ; 92 7 ; 31 ; 48 ; 44 ; 33 ; 49 ; 47 ; 38 ; 33 ; 29 ; 39 ; 21 ; 40 ; 30 ; 27 ; 25 ; 29 ; 25 ; 21 ; 26 ; 37 8 ; 33 ; 40 ; 20 ; 31 ; 30 ; 28 ; 20 ; 25 ; 29 ; 34 ; 30 ; 32 ; 18 ; 32 ; 22 ; 28 ; 27 ; 35 ; 17 ; 28 9 ; 34 ; 31 ; 32 ; 37 ; 38 ; 26 ; 22 ; 40 ; 43 ; 23 ; 26 ; 37 ; 39 ; 33 ; 35 ; 41 ; 26 ; 27 ; 24 ; 36 10 ; 45 ; 47 ; 53 ; 49 ; 47 ; 62 ; 44 ; 55 ; 52 ; 50 ; 59 ; 32 ; 40 ; 43 ; 46 ; 56 ; 34 ; 38 ; 44 ; 56 *** First line are headers. The 10 following lines refer to 10 independent samples. On each line, the first column is the sample number, the next 10 columns are reps of measurements performed with the reference method, and the 10 last columns are reps of measurements performed with the new method we would like to validate. Each of the 20 reps measurements are performed on distinct subsets of the sample, so they're not supposed to be identical (in particular, Ref_i and New_i are performed on different subsets) Let's come to our question : we would like to statistically validate the fact that the new measurement method is as good as the older one. At the end, what interests us is the average of the 10 measurements we perform. Ouf course, there always are some differences between the averages obtained by the reference and the new method, but we are convinced this difference is actually contained within the subseting fluctuation. We've been told using a Bonferroni correction would be a good way to address our problem, but despite reading quite a lot of documentation, we were unable to find out how to implement it. All the examples we've seen apply Bonferroni correction to pairwise tests between 2 vectors, can it actually be applied to a set of paired vectors as in our data? Or should we just compare the averages of the reference and the new measurement methods for each sample? Finally, will this test actually answer our question, or would be another data treatment more appropriated? Thanks in advance for your help, it will be very appreciated since we're running out of resources to solve our issue... Best regards, Stephanie [[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] Creating DAGS with plate notation in R
Here is a way to do it with qgraph. Requires lots of manual placement though. I have been asked before to write a package to do these kind of graphics automatically from R given some model. Might do it eventually :) library(qgraph) # Placement of nodes: Layout - matrix(c( 1,1, 2,1, 3,1, 4,1, 3,0),,2,byrow=TRUE) # Graph structure: E - matrix(c( 1,2, 2,3, 3,4, 5,4),,2,byrow=TRUE) # Labels: Lab - list(expression(alpha),expression(theta),expression(z),expression(w),expression(beta)) # Colors: Col - c(rep(white,4),gray) pdf(Model.pdf,width=6, height = 4) # Open plot: par(mar=c(0,0,0,0)) plot(1,type=n,xlim=c(0.5,5),ylim=c(-1,3)) # add graph: qgraph(E, layout = Layout, labels = Lab, color = Col, plot = FALSE, rescale = FALSE) # Add boxes: rect(1.6,0.4,4.6,2) rect(2.6, 0.6, 4.4, 1.6 ) # Add labels: text(3.1, 1.9, M) text(3.5, 1.5, N) dev.off() --- Sacha Epskamp, MSc Department of Psychological Methods University of Amsterdam Weesperplein 4, room 2.05 1018 XA Amsterdam The Netherlands http://www.sachaepskamp.com 2013/7/2 Raghu Naik naik.ra...@gmail.com The image did not come through as pointed out by a list member. I have attached a pdf image file; the link is http://stackoverflow.com/questions/3461931/software-to-draw-graphical-models-in-plate-notation . Cheers. Raghu On Tue, Jul 2, 2013 at 9:42 AM, Raghu Naik naik.ra...@gmail.com wrote: I am trying to create a directed graph with plate notation (like the one shown below) in R. [image: The output image] Could someone direct to me an example code that will get me started. I could not see any reference to plate notations in igraph, qgraph packages though I may be wrong. The above figure made in graphviz by a poster on stackoverflow. I am not sure if this can be replicated in Rgraphviz - I was not able to get there. I would appreciate any help. Thanks. Raghu __ 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. Model.pdf Description: Adobe PDF document __ 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] GARCH Optimization Problems
Hi all, Since am new to the forums I'd like to say hello to everyone. My questions revolves around optimizing a simple GARCH process. Lets assume we have a function names garchlik and takes as inputs (parameters, data, p,q); where p and q are the ARCH and GARCH effects. Have tried the simple approaches such as: optim(parameters, fn=garchlik, method = L-BFGS-B,hessian=TRUE, control = list(maxit = 2, pgtol=1e-8), data=data, p=p, q=q) However am looking into constraint optimization and the functions such that: constrOptim, solnp among others. But am faced with a number of issues. Let me describe what am doing and perhaps you may spot what am doing wrong. parameters = c(mean(data), 0.005, 0.10, 0.85) r = NROW(parameters) Constrains are: omega =0 ARCH =0 GARCH=0 ARCH+GARC H=1 (A = rbind(cbind(array(0, c((r-1),1)), -diag(r-1)), cbind(array(0, c(1,r-p-q)), array(1,c(1,2) (b = c(array(0,c(1,r-1)), array(1 - 1e-6, 1))) lowerBounds = c(-100*abs(a0), array(1e-6, c((length(parameters)-1 upperBounds = c(100*abs(a0), array(1-1e-6, c((length(parameters)-1 Case A: constrOptim: constrOptim(parameters, garchlik, grad=NULL, ui=A, ci=b) Error in constrOptim(parameters, garchlik, grad = NULL, ui = A, ci = b) : initial value is not in the interior of the feasible region Case B: solnp(parameters, fun=garchlik, neqfun =A, ineqLB = b, LB=lowerBounds, UB=upperBounds, p=1,q=1,data=data) whereas in solnp it works perfectly if neqfun and ineqLB are not used. But both appear to fail for various reaons. Any ideas? Many thanks, Tony -- View this message in context: http://r.789695.n4.nabble.com/GARCH-Optimization-Problems-tp4672807.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] qgraph: how to create legend (scale) for edge thickness?
Hi Maria, Thanks! I just happened to read this but normally don't read r-help. It is best to send specific questions on not well known packages to the maintainer directly. The example on my website is hardcoded in the package. I should really also add the option to make a legend like you want though. But what you could do is create a dummy graph with the same parameters to get the color en width of the lines and then just add that as a legend. The graphs are just base R graphics so you could add a legend directly to it or plot it in a separate panel using layout(), e.g.: library(qgraph) # Dummy plot to extract edge coloring: g - qgraph(cbind(1:4,1:4,c(0.4,0.6,0.8,1)),esize=7,gray=TRUE,maximum=1.4,cut=0.0001,DoNotPlot=TRUE) # Colors: col - g$graphAttributes$Edges$color # lwd: lwd - g$graphAttributes$Edges$width # Original plot: qgraph(Edges2,esize=7,nsize=12,gray=TRUE,layout=circular,filetype=pdf,width=5,height=5,vsize=11,label.prop=1.2,arrows=FALSE,border.color=c(red,red,blue,green,purple),border.width=4,maximum=1.4,cut=0.0001) # Add legend: legend(topright,legend=c(0.4,0.6,0.8,1),col=col,lwd=lwd,bty=n) Best, Sacha --- Sacha Epskamp, MSc Department of Psychological Methods University of Amsterdam Weesperplein 4, room 2.05 1018 XA Amsterdam The Netherlands http://www.sachaepskamp.com 2013/7/31 María Antonieta Sánchez Farrán antos...@gmail.com Hello R community, I am creating some network representations using the qgraph package (big thanks to Sacha Epskamp for developing it!). The package is very well documented, but I am unable to find how to create a legend (scale) for edge thickness. In one of his qgraph examples, Sacha shows such type of scale (fifth graph in http://sachaepskamp.com/qgraph/examples - scale for edge thickness relative to p-values). I have searched the documentation and it seems that a legend relates to the definition of node groups, so I am uncertain on which option/command I need to use for achieving what I need. I would also like to be able to select the values for which the scale is created too. If it is unclear, what I am looking for is to display this next to the network graph: probability edge thickness 1.0 display line with thickness for 1.0 0.8 display line with thickness for 0.8 0.6 display line with thickness for 0.6 0.4 display line with thickness for 0.4 My line of code for generating the network is the following: qgraph(Edges2,esize=7,nsize=12,gray=TRUE,layout=circular,filetype=pdf,width=5,height=5,vsize=11,label.prop=1.2,arrows=FALSE,border.color=c(red,red,blue,green,purple),border.width=4,maximum=1.4,cut=0.0001) I would appreciate if somebody can help me out. Thanks, Maria Antonieta [[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. [[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] readBin into a data frame
On 13-08-01 4:36 AM, Zhang Weiwu wrote: Hello. readBin is designed to read a batch of data with the same spec, e.g. read 1 floats into a vector. In practise I read into data frame, not vector. For each data frame, I need to read a integer and a float. for (i in 1:1000) { dataframe$int[i] - readBin(con, integer(), size=2) dataframe$float[i] - readBin(con, numeric(), size=4) } And I need to read 100 such data files, ending up with a for loop in a for loop. Something feels wrong here, as it is being said if you use double-FOR you are not speaking R. What is the R way of doing this? I can think of writing the content of the loop into a function, and vectorize it -- But, the result would be a list of list, not exactly data-frame, and the list grows incrementally, which is inefficient, since I know the size of my data frame at the outset. I am a new learner, not speaking half of R vocabulary, kindly provide some hint please:) I don't think there are any functions to do this directly. I'd probably use the loop (since the time to read 1000 entries would be small). If it was longer, what I might do is to read the file as raw bytes, then read the integer and float vector from subsets of the bytes. For example, the following untested code: rawvec - readBin(con, raw) n - length(rawvec) / 6 i - 0:(n-1) # Using sort here is inefficient, but I'm lazy... indices - sort( c(6*i + 1, 6*i + 2) ) con - rawConnection(rawvec[indices]) int - readBin(con, integer, size=2) close(con) indices - sort( c(6*i + 3, 6*i + 4, 6*i + 5, 6*i + 6) ) con - rawConnection(rawvec[indices]) float - readBin(con, numeric, 4) close(con) dataframe - data.frame(int=int, float=float) The other way to do this is to read the data in a C function, using .Call or .C to get it into R. Duncan Murdoch __ 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] merge matrix row data
mat1-structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L), .Dim = c(20L, 14L), .Dimnames = list(NULL, c(GID, D0407, D0409, D0410, D0462, D0463, D0473, D0475, D0488, D0489, D0492, D0493, D0504, D0536))) IslandA-c(GID 1, GID 5) IslandB- c(GID 2, GID 4, GID 7) t(sapply(c(IslandA,IslandB),function(x) {x1- mat1[match(gsub(.*\\s+,,get(x)),mat1[,1]),-1];(!!colSums(x1))*1})) # D0407 D0409 D0410 D0462 D0463 D0473 D0475 D0488 D0489 D0492 D0493 D0504 #IslandA 0 0 0 0 0 0 0 0 0 0 0 0 #IslandB 0 0 0 0 0 1 0 0 0 0 1 0 # D0536 #IslandA 0 #IslandB 1 A.K. From: Elaine Kuo elaine.kuo...@gmail.com To: arun smartpink...@yahoo.com Sent: Thursday, August 1, 2013 7:57 AM Subject: Re: [R] merge matrix row data Thanks. Here you go. structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L), .Dim = c(20L, 14L), .Dimnames = list(NULL, c(GID, D0407, D0409, D0410, D0462, D0463, D0473, D0475, D0488, D0489, D0492, D0493, D0504, D0536))) __ 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] Use of Bonferroni correction on a set of paired vectors?
This has nothing to do with R per se. You need to consult a local statistician and stop fooling with Internet forums. Cheers. Bert On Thu, Aug 1, 2013 at 3:10 AM, Stéph BELLEGO ion...@hotmail.com wrote: Dear all, We are trying to validate a new measurement method by comparing it to a reference method, but we don't manage to find out how to do it... Here are the data we have : *** Sample# ; Ref_1 ; Ref_2 ; Ref_3 ; Ref_4 ; Ref_5 ; Ref_6 ; Ref_7 ; Ref_8 ; Ref_9 ; Ref_10 ; New_1 ; New_2 ; New_3 ; New_4 ; New_5 ; New_6 ; New_7 ; New_8 ; New_9 ; New_10 1 ; 58 ; 56 ; 60 ; 64 ; 76 ; 78 ; 73 ; 73 ; 83 ; 76 ; 61 ; 70 ; 61 ; 61 ; 54 ; 48 ; 60 ; 56 ; 82 ; 63 2 ; 46 ; 51 ; 48 ; 57 ; 61 ; 74 ; 54 ; 63 ; 60 ; 71 ; 77 ; 69 ; 53 ; 56 ; 58 ; 61 ; 64 ; 63 ; 57 ; 71 3 ; 60 ; 79 ; 68 ; 69 ; 70 ; 67 ; 68 ; 71 ; 66 ; 72 ; 76 ; 68 ; 53 ; 82 ; 40 ; 58 ; 51 ; 66 ; 87 ; 68 4 ; 67 ; 59 ; 52 ; 63 ; 61 ; 60 ; 57 ; 54 ; 61 ; 62 ; 71 ; 45 ; 66 ; 56 ; 55 ; 66 ; 56 ; 63 ; 56 ; 76 5 ; 100 ; 112 ; 89 ; 96 ; 111 ; 78 ; 91 ; 93 ; 96 ; 93 ; 92 ; 81 ; 82 ; 102 ; 89 ; 82 ; 69 ; 68 ; 73 ; 98 6 ; 88 ; 77 ; 93 ; 81 ; 77 ; 70 ; 83 ; 67 ; 84 ; 94 ; 81 ; 80 ; 54 ; 101 ; 77 ; 91 ; 104 ; 66 ; 80 ; 92 7 ; 31 ; 48 ; 44 ; 33 ; 49 ; 47 ; 38 ; 33 ; 29 ; 39 ; 21 ; 40 ; 30 ; 27 ; 25 ; 29 ; 25 ; 21 ; 26 ; 37 8 ; 33 ; 40 ; 20 ; 31 ; 30 ; 28 ; 20 ; 25 ; 29 ; 34 ; 30 ; 32 ; 18 ; 32 ; 22 ; 28 ; 27 ; 35 ; 17 ; 28 9 ; 34 ; 31 ; 32 ; 37 ; 38 ; 26 ; 22 ; 40 ; 43 ; 23 ; 26 ; 37 ; 39 ; 33 ; 35 ; 41 ; 26 ; 27 ; 24 ; 36 10 ; 45 ; 47 ; 53 ; 49 ; 47 ; 62 ; 44 ; 55 ; 52 ; 50 ; 59 ; 32 ; 40 ; 43 ; 46 ; 56 ; 34 ; 38 ; 44 ; 56 *** First line are headers. The 10 following lines refer to 10 independent samples. On each line, the first column is the sample number, the next 10 columns are reps of measurements performed with the reference method, and the 10 last columns are reps of measurements performed with the new method we would like to validate. Each of the 20 reps measurements are performed on distinct subsets of the sample, so they're not supposed to be identical (in particular, Ref_i and New_i are performed on different subsets) Let's come to our question : we would like to statistically validate the fact that the new measurement method is as good as the older one. At the end, what interests us is the average of the 10 measurements we perform. Ouf course, there always are some differences between the averages obtained by the reference and the new method, but we are convinced this difference is actually contained within the subseting fluctuation. We've been told using a Bonferroni correction would be a good way to address our problem, but despite reading quite a lot of documentation, we were unable to find out how to implement it. All the examples we've seen apply Bonferroni correction to pairwise tests between 2 vectors, can it actually be applied to a set of paired vectors as in our data? Or should we just compare the averages of the reference and the new measurement methods for each sample? Finally, will this test actually answer our question, or would be another data treatment more appropriated? Thanks in advance for your help, it will be very appreciated since we're running out of resources to solve our issue... Best regards, Stephanie [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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] ggplot2: color histograms by quintile
There is a problem with your example data set. Series has only one value so there is no faceting. Also you refer to trim.index$Rate . Where is it coming from or is trim.index just another name for thing John Kane Kingston ON Canada -Original Message- From: david_txert...@yahoo.fr Sent: Thu, 1 Aug 2013 01:23:37 +0100 (BST) To: r-help@r-project.org Subject: [R] ggplot2: color histograms by quintile Hello, I have a basic panel of histograms as follows, whose current colors don't matter: binsize=diff(range(thing$Rate))/64 ggplot(thing, aes(x=Rate, fill=Series)) + geom_histogram(binwidth=binsize) + facet_grid(Series~.,scales=free)+ labs(fill=Index) + xlab(Growth Rate (%)) + theme(axis.title.y=element_blank(),legend.position=c(1,.64), legend.justification=c(1,1),strip.text.y = theme_blank()) + scale_x_continuous(breaks=c(-10,-5,-2:10,15,20)) + geom_vline(xintercept=0, linetype=dotted) rm(binsize) What I would like to do is color each of the four histograms by its own deciles. Essentially quantile(trim.index$Rate,c(0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1)) would give me the over-all deciles, but I would like them broken down by the elements of the Series variable, and then applied to the histograms as shading or coloring. Does this makes sense? I've dumped the first 100 rows of data below. Thanks in advance for any help you're able to provide. David structure(list(Trials = 1:100, Year = c(2005L, 2008L, 2006L, 2007L, 2006L, 2004L, 2004L, 2003L, 2007L, 2005L, 2008L, 2006L, 2011L, 2005L, 2004L, 2003L, 2010L, 2002L, 2008L, 2005L, 2005L, 2004L, 2006L, 2011L, 2011L, 2008L, 2006L, 2004L, 2002L, 2003L, 2009L, 2004L, 2003L, 2011L, 2006L, 2002L, 2007L, 2010L, 2005L, 2008L, 2011L, 2008L, 2010L, 2005L, 2004L, 2009L, 2002L, 2008L, 2002L, 2006L, 2003L, 2007L, 2006L, 2006L, 2002L, 2002L, 2010L, 2008L, 2008L, 2003L, 2003L, 2009L, 2007L, 2009L, 2004L, 2005L, 2011L, 2010L, 2005L, 2008L, 2008L, 2008L, 2007L, 2008L, 2008L, 2007L, 2002L, 2009L, 2011L, 2002L, 2002L, 2006L, 2007L, 2007L, 2002L, 2009L, 2007L, 2003L, 2010L, 2010L, 2009L, 2003L, 2010L, 2003L, 2007L, 2006L, 2010L, 2005L, 2004L, 2010L), Month = c(12L, 4L, 5L, 3L, 9L, 12L, 4L, 3L, 6L, 10L, 6L, 11L, 1L, 6L, 9L, 10L, 5L, 3L, 11L, 10L, 2L, 8L, 9L, 7L, 8L, 8L, 7L, 1L, 9L, 1L, 11L, 3L, 12L, 1L, 6L, 7L, 6L, 8L, 12L, 8L, 11L, 11L, 5L, 7L, 2L, 6L, 9L, 9L, 11L, 6L, 11L, 5L, 5L, 3L, 10L, 6L, 7L, 8L, 9L, 2L, 3L, 11L, 8L, 4L, 12L, 6L, 10L, 10L, 12L, 9L, 4L, 12L, 12L, 12L, 6L, 6L, 11L, 1L, 5L, 6L, 2L, 4L, 7L, 10L, 12L, 4L, 5L, 8L, 7L, 2L, 6L, 10L, 10L, 10L, 10L, 2L, 6L, 6L, 9L, 9L), Core.CPI.Weighting = c(2L, 3L, 2L, 5L, 1L, 5L, 4L, 5L, 4L, 1L, 3L, 4L, 5L, 2L, 4L, 5L, 1L, 5L, 1L, 3L, 2L, 1L, 5L, 2L, 1L, 2L, 5L, 5L, 4L, 2L, 4L, 4L, 5L, 5L, 2L, 5L, 3L, 4L, 5L, 1L, 2L, 2L, 5L, 3L, 2L, 2L, 5L, 3L, 2L, 4L, 2L, 4L, 1L, 3L, 1L, 4L, 1L, 3L, 1L, 1L, 4L, 2L, 3L, 2L, 2L, 5L, 4L, 4L, 3L, 4L, 2L, 5L, 2L, 5L, 1L, 2L, 5L, 5L, 5L, 2L, 5L, 3L, 3L, 1L, 5L, 2L, 2L, 2L, 1L, 3L, 5L, 3L, 4L, 3L, 3L, 1L, 1L, 2L, 2L, 3L), CPI.Food = c(0.023474768, 0.043433814, 0.029315923, 0.042208873, 0.035479323, 0.024429485, 0.028537661, 0.027623773, 0.045546671, 0.023973579, 0.045546671, 0.038421672, 0.037161108, 0.023102181, 0.032765694, 0.032962625, 0.008051879, 0.028741685, 0.053639179, 0.025192645, 0.025077433, 0.032806764, 0.023605006, 0.025644434, 0.029584922, 0.031756778, 0.032450724, 0.026035343, 0.020656969, 0.026035343, 0.010684754, 0.029551194, 0.02442531, 0.012348667, 0.030959528, 0.023781539, 0.045546671, 0.008345359, 0.024429485, 0.031756778, 0.034731773, 0.053639179, 0.008051879, 0.023005118, 0.030315091, 0.04149634, 0.019373857, 0.051078725, 0.022406708, 0.030959528, 0.022406708, 0.044396055, 0.023304811, 0.025196539, 0.020831987, 0.016599861, 0.008044572, 0.049349997, 0.026691689, 0.01612059, 0.015903088, 0.010684754, 0.033979886, 0.048496522, 0.024429485, 0.023102181, 0.033084021, 0.033084021, 0.024429485, 0.026691689, 0.048496522, 0.054246603, 0.039956669, 0.054246603, 0.045546671, 0.045546671, 0.018027105, 0.053917666, 0.034171337, 0.025416646, 0.029331567, 0.02412957, 0.032450724, 0.052641267, 0.017531941, 0.048496522, 0.044396055, 0.018367312, 0.008044572, 0.013896245, 0.04149634, 0.032962625, 0.009905593, 0.032962625, 0.052641267, 0.025077433, 0.023022986, 0.023102181, 0.032765694, 0.00916168), PPI.Farm = c(0.009730106, 0.204892729, 0.138453455, 0.210017271, 0.178801715, -0.017104315, 0.168632738, 0.157512456, 0.208907609, -0.007879949, 0.208907609, 0.187585976, 0.171910952, -0.0471555, 0.144318736, 0.111713247, -0.000515726, 3.019e-05, 0.120566043, -0.027737238, -0.021152479, 0.168890071, -0.020784628, 0.231482252, 0.050380553, -0.141247793, 0.16832412, 0.140014634, -0.04669922, 0.140014634, 0.095775695, 0.02684028, 0.142349938, 0.125929795, 0.154898078, -0.043965946, 0.208907609, 0.033632438, -0.017104315, -0.141247793, 0.215496099, 0.120566043, -0.000515726, -0.041130752,
[R] Error Help: duplicate?
Hi, I'm working through practice data in R and I am held up on this step. I am not sure why there is an error that claims there is a duplicate subscript for columns? Does anyone know what this means and how I can fix it? newdata2-cbind(newdata2,predict(mylogit,newdata=newdata2,type=link,se=TRUE)) newdata2-within(newdata2,{PredictedProb-plogis(fit) + LL-plogis(fit- (1.96 * se.fit)) + UL-plogis(fit + (1.96 *se.fit)) + }) Error in `[-.data.frame`(`*tmp*`, nl, value = list(UL = c(0.549206434665668, : duplicate subscripts for columns -- View this message in context: http://r.789695.n4.nabble.com/Error-Help-duplicate-tp4672819.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.
[R] Error Help: duplicate?
Hi, I'm working through practice data in R and I am helped up on this step. I am not sure why there is an error that claims there is a duplicate subscript for columns? Does anyone know what this means and how I can fix it? newdata2-cbind(newdata2,predict(mylogit,newdata=newdata2,type=link,se=TRUE)) newdata2-within(newdata2,{PredictedProb-plogis(fit) + LL-plogis(fit- (1.96 * se.fit)) + UL-plogis(fit + (1.96 *se.fit)) + }) Error in `[-.data.frame`(`*tmp*`, nl, value = list(UL = c(0.549206434665668, : duplicate subscripts for columns -- View this message in context: http://r.789695.n4.nabble.com/Error-Help-duplicate-tp4672818.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] merge matrix row data
HI Elaine, From the error, it looks like there are cases where none of the elements in one of the element matches to the GID column of dataNP.m. It's only a guess as you didn't provide information about the Islands. I was able to recreate the error you got. dataNP.m-structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L), .Dim = c(20L, 14L), .Dimnames = list(NULL, c(GID, D0407, D0409, D0410, D0462, D0463, D0473, D0475, D0488, D0489, D0492, D0493, D0504, D0536))) Conti_Australia- c(1,14,18) Conti_Malay- c(2,6,8) Island_Sumatra- c(3,9,21) Island_New_Guinea- c(22,24,28) #none of the elements are present in the GID column of example dataset lapply(c(Conti_Australia,Conti_Malay,Island_Sumatra,Island_New_Guinea),function(x) {x1- match(get(x),dataNP.m[,1]); x2-x1[!is.na(x1)];colSums(x2)}) #Error in colSums(x2) : 'x' must be an array of at least two dimensions lst1-sapply(c(Conti_Australia,Conti_Malay,Island_Sumatra,Island_New_Guinea),function(x) {x1- match(get(x),dataNP.m[,1]); x2-x1[!is.na(x1)];if(length(x2)0) (!!colSums(dataNP.m[x2,-1]))*1}) t(simplify2array(lst1[lapply(lst1,length)0])) # D0407 D0409 D0410 D0462 D0463 D0473 D0475 D0488 D0489 D0492 #Conti_Australia 0 0 0 0 0 1 0 0 0 0 #Conti_Malay 0 0 0 0 0 1 0 0 0 0 #Island_Sumatra 0 0 0 0 0 0 0 0 0 1 # D0493 D0504 D0536 #Conti_Australia 0 0 1 #Conti_Malay 1 0 1 #Island_Sumatra 0 0 0 A.K. From: Elaine Kuo elaine.kuo...@gmail.com To: arun smartpink...@yahoo.com Sent: Thursday, August 1, 2013 9:20 AM Subject: Re: [R] merge matrix row data Hello arun, It is Elaine again. After running the function in the last sentence of your code, an error message says Error in colSums(x1) : 'x' must be an array of at least two dimensions Please kindly help and thanks Elaine dput dput(head(dataNP.m,20)) structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L), .Dim = c(20L, 14L), .Dimnames = list(NULL, c(GID, D0407, D0409, D0410, D0462, D0463, D0473, D0475, D0488, D0489, D0492, D0493, D0504, D0536))) Code island- t(sapply(c( Conti_Australia,Conti_Korea,Conti_Malay, + Island_Sumatra,Island_Bali,Island_Lombok, + Island_Lesser_Sunda,Island_Maluku,Island_Sulawesi,Island_Kepu_Sula, + Island_New_Guinea,Island_Palawan,Island_Phillipines, + Island_Hainan,Island_Taiwan, + Island_Sakishima,Island_Ryukyu,Island_Amami,Island_Osumi, + Island_Kyushu,Island_Shikoku,Island_Honshu,Island_Hokkaido,Island_Sakhalin), + function(x) {x1-
Re: [R] R Help.
Hi Darren, Take a look at the effects package. The documentation is good and these articles will help you get oriented: http://www.jstatsoft.org/v08/i15 http://www.jstatsoft.org/v32/i01 Best, Ista On Thu, Aug 1, 2013 at 1:56 AM, Darren Andrew Whitehead darrenwhitehe...@hotmail.com wrote: Hello R Project, I am having a little trouble with interpreting my GLM results and I wonder if you may be able to help. I am doing a generalised linear model in R studio by outcome variable is binary either effected or not effected. I have my final model structure which has been validated and fits well. But, I am having some trouble understanding how to produce graphs and show the results visually. I have one significant main effect variable which is continuos and I have one 3 way interaction which is highly significant. My problem is I dont have any idea what to do next Please can you help? Help with either advise on how to preform these visual interpretations or introduce someone to me who might be willing to do the analysis for me if i sent them my data and script. For this I would offer payment for there time- Have a great day, Kindest regards, Darren [[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-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] 'format' behaviour in a 'apply' call depending on 'options(digits = K)'
This problem does not seem to be widely popular, but at least affects two users (both on Linux, maybe a hint here?). To me, it looks like a bug (is it a R bug, or a OS-related bug, I don't know). Should I forward it to R-devel, or some other place where R gurus may have a chance to look at it? Mathieu. Le 07/30/2013 02:34 PM, arun a écrit : Hi Mathieu yes, the original problem occurs in my system too. I am using R 3.0.1 on linux mint 15. I guess the default case would be trim=FALSE, but still it looks very strange especially in ?apply(), as it starts from 5 onwards. sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] stringr_0.6.2 reshape2_1.2.2 loaded via a namespace (and not attached): [1] plyr_1.8tools_3.0.1 - Original Message - From: Mathieu Basille basille@ase-research.org To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, July 30, 2013 2:29 PM Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Thanks Arun for your answer. 'trim = TRUE' does indeed solve the symptoms of the problem, and this is the solution I'm currently using. However, it does not help to understand what the problem is, and what is the cause of it. Can you confirm that the original problem also occurs on your computer (and what is your OS)? It would be interesting since David is not able to reproduce the problem with Mac OS X. Mathieu. Le 07/30/2013 02:15 PM, arun a écrit : Hi, Try using trim=TRUE, in ?format() options(digits=4) df2 - data.frame(x = rnorm(11), y = rnorm(11), id = 1:11) df2$id2 - apply(df2, 1, function(dfi) format(dfi[id], trim=TRUE,scientific = FALSE)) df2$id2[0:100010] # [1] 0 1 2 3 4 5 6 7 # [9] 8 9 10 11 12 13 14 15 #[17] 16 17 18 19 100010 id2 - format(1:11, scientific = FALSE,trim=TRUE) id2[0:100010] # [1] 0 1 2 3 4 5 6 7 #[9] 8 9 10 11 12 13 14 15 #[17] 16 17 18 19 100010 A.K. - Original Message - From: Mathieu Basille basille@ase-research.org To: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Sent: Tuesday, July 30, 2013 2:07 PM Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Thanks David for your interest. I have to admit that your answer puzzles me even more than before. It seems that the underlying problem is way beyond my R skills... The generation of id2 is indeed quite demanding, especially compared to a simple 'as.character' call. Anyway, since it seems to be system specific, here is the sessionInfo() that I forgot to attach to my first message: R version 3.0.1 (2013-05-16) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C [3] LC_TIME=fr_FR.UTF-8LC_COLLATE=fr_FR.UTF-8 [5] LC_MONETARY=fr_FR.UTF-8LC_MESSAGES=fr_FR.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base In brief: last stable R available under Debian Testing... Hopefully this can help tracking down the problem. Mathieu. Le 07/30/2013 01:58 PM, David Winsemius a écrit : On Jul 30, 2013, at 9:01 AM, Mathieu Basille wrote: Dear list, Here is a simple example in which the behaviour of 'format' does not make sense to me. I have read the documentation and searched the archives, but nothing pointed me in the right direction to understand this behaviour. Let's start with a simple data frame: df1 - data.frame(x = rnorm(11), y = rnorm(11), id = 1:11) Let's now create a new variable 'id2' which is the character representation of 'id'. Note that I use 'scientific = FALSE' to ensure that long numbers such as 100,000 are not formatted using their scientific representation (in this case 1e+05): df1$id2 - apply(df1, 1, function(dfi) format(dfi[id], scientific = FALSE)) Let's have a look at part of the result: df1$id2[0:100010] [1] 0 1 2 3 4 5 6 [8] 7 8 9 10 11 12 13 [15] 14 15 16 17 18 19 100010 Some formating processes are carried out by system functions. In this case I am unable to reproduce with the same
Re: [R] Issue when using a coxph + summary function in R while using a pspline-transformed covariate
On Aug 1, 2013, at 1:02 AM, Dumortier, Thomas wrote: Hello I have an issue with obtaining a confidence interval from a coxph object in R while using a spline-transformed covariate. This is a time to event analysis using coxph() from the survival package. In the model below, COVA is a continuous covariate. COVA is time-dependent hence the counting process notation. COVA is transformed via pspline, COVB (FALSE or TRUE) is a fixed covariate. My goal is to get the confidence interval for COVB. With this purpose, I use the summary(…,conf.int=.95) function. I have pasted the code and the console below. The estimation works well. The summary function returns the desired confidence interval in the console, but it returns a NULL object (psp.sum is returned NULL, see below the code and the console) Note that if I do not use pspline, it works ! So it seems that the use of pspline is not compatible with the summary function. Not exactly. It's two different functions in reality. This is a problem because I would like to do some simulation and need to retrieve the confidence interval from psp.sum. Can you kindly help? Rgds Tom CODE psp-coxph(Surv(DAY2,DAY2P1,EVTF)~COVB+pspline(COVA, df = 0, caic = T),data=dsn4,method='breslow') psp psp.sum-summary(psp,conf.int=.95) psp.sum If you add the line: class(psp) # you will find that it returns [1] coxph.penal coxph Then looking at the code for survival:::summary.coxph.penal, you will see that the final line is `invisible()`, so Therneau did not intend anything to be returned from a penalized fit. Generally the failure to return an object is a sign that the author thought it was a bad idea. I think the problem comes from the interval nature of the data layout. In the past, Therneau has written that the request for even plotting a survival curve itself is problematic in this situation. http://markmail.org/message/ufmtidvzfcgqdsot?q=list:org%2Er-project%2Er-help+time+dependent+covariates+survival+from:%22Terry+Therneau%22page=1 -- David. CONSOLE 1 psp-coxph(Surv(DAY2,DAY2P1,EVTF)~COVB+pspline(COVA, df = 0, caic = T),data=dsn4,method='breslow') 1 psp Call: coxph(formula = Surv(DAY2, DAY2P1, EVTF) ~ COVB + pspline(COVA, df = 0, caic = T), data = dsn4, method = breslow) coef se(coef) se2Chisq DF p COVBTRUE -1.625 0.4223 0.4198 14.80 1.00 1.2e-04 pspline(COVA, df = 0, caic -0.341 0.0761 0.0761 20.04 1.00 7.6e-06 pspline(COVA, df = 0, caic 1.95 0.83 1.3e-01 Iterations: 10 outer, 29 Newton-Raphson Theta= 0.98 Degrees of freedom for terms= 1.0 1.8 Likelihood ratio test=22.3 on 2.81 df, p=4.52e-05 n= 16933 1 psp.sum-summary(psp,conf.int=.95) Call: coxph(formula = Surv(DAY2, DAY2P1, EVTF) ~ COVB + pspline(COVA, df = 0, caic = T), data = dsn4, method = breslow) n= 16933, number of events= 35 coef se(coef) se2Chisq DF p COVBTRUE -1.625 0.4223 0.4198 14.80 1.00 1.2e-04 pspline(COVA, df = 0, caic -0.341 0.0761 0.0761 20.04 1.00 7.6e-06 pspline(COVA, df = 0, caic 1.95 0.83 1.3e-01 exp(coef) exp(-coef) lower .95 upper .95 COVBTRUE0.19690 5.08 8.61e-020.4506 ps(COVA)30.59903 1.67 3.48e-011.0301 ps(COVA)40.35872 2.79 1.36e-010.9470 ps(COVA)50.21394 4.67 5.82e-020.7857 ps(COVA)60.12594 7.94 2.69e-020.5898 ps(COVA)70.07290 13.72 1.31e-020.4051 ps(COVA)80.04275 23.39 6.84e-030.2673 ps(COVA)90.02647 37.78 3.89e-030.1802 ps(COVA)10 0.01785 56.04 2.45e-030.1301 ps(COVA)11 0.01310 76.32 1.68e-030.1024 ps(COVA)12 0.01019 98.11 1.19e-030.0870 ps(COVA)13 0.00810 123.39 8.32e-040.0790 ps(COVA)14 0.00645 154.95 5.43e-040.0767 ps(COVA)15 0.00512 195.45 3.26e-040.0803 ps(COVA)16 0.00405 246.92 1.80e-040.0913 ps(COVA)17 0.00320 312.04 9.11e-050.1127 ps(COVA)18 0.00254 394.32 4.29e-050.1499 ps(COVA)19 0.00201 498.30 1.89e-050.2133 Iterations: 10 outer, 29 Newton-Raphson Theta= 0.98 Degrees of freedom for terms= 1.0 1.8 Concordance= 0.673 (se = 0.05 ) Rsquare= 0.001 (max possible= 0.026 ) Likelihood ratio test= 22.3 on 2.81 df, p=4.52e-05 Wald test= 24.6 on 2.81 df, p=1.48e-05 1 psp.sum NULL 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. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list
[R] algorithm for clustering categorical data
Hi All, Does anyone know what algorithm for clustering categorical variables? R packages? Which is the best? If a data has both numeric and categorical data, what is the best clustering algorithm to use and R package? I tried numeric transformation of all categorical fields and doing clustering afterwards. But the transformed fields have values from 1...10, and my other fields is in a bigger scale: 1-...This will make the categorical fields has less effect on the distance calculation... Thank you! Yan [[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] Highlight selected bar in barplot
You may be interested in the iplots package. It has methods where you can create multiple plots and select a point or points in one plot and they will be highlighted on the other plots. On Wed, Jul 31, 2013 at 8:57 AM, Jurgens de Bruin debrui...@gmail.comwrote: Hi All, I am new at R so any help would be appreciate. Below my current R-code/script: initial.dir-getwd() setwd('/Users/jurgens/VirtualEnv/venv/Projects/QTLS/Resaved_Results') dataset - read.table(LWxANNA_FinalReport_resaved_spwc.csv, header=TRUE, sep=\t ) n - length(dataset$X..No.Call) x - sort(dataset$X..No.Call,partial = n )[n] outlier - dataset[ dataset$X..No.Call quantile(dataset$X..No.Call,0.25) + (IQR(dataset$X..No.Call) *1.5),] par( las=2, cex.axis=0.5, cex.lab=1, cex.main=2, cex.sub=1) barplot(dataset$X..No.Call, names.arg = dataset$Individual.Sample, cex.names=0.5 ,space=0.5, ylim=c(0,x*1.5) ) setwd(initial.dir) I would like to highlight the sample in outlier on the barplot that is create, would this be possible? Thanks -- Regards/Groete/Mit freundlichen GrüÃen/recuerdos/meilleures salutations/ distinti saluti/siong/duì yú/пÑÐ¸Ð²ÐµÑ Jurgens de Bruin [[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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com [[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] Error Help: duplicate?
Your example is not reproducible, so we can only guess what is happening. Please read the footer of this (or any other R-help) email and follow those instructions. You may also find the discussion at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example helpful. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Docbanks84 mban...@partners.org wrote: Hi, I'm working through practice data in R and I am held up on this step. I am not sure why there is an error that claims there is a duplicate subscript for columns? Does anyone know what this means and how I can fix it? newdata2-cbind(newdata2,predict(mylogit,newdata=newdata2,type=link,se=TRUE)) newdata2-within(newdata2,{PredictedProb-plogis(fit) + LL-plogis(fit- (1.96 * se.fit)) + UL-plogis(fit + (1.96 *se.fit)) + }) Error in `[-.data.frame`(`*tmp*`, nl, value = list(UL = c(0.549206434665668, : duplicate subscripts for columns -- View this message in context: http://r.789695.n4.nabble.com/Error-Help-duplicate-tp4672819.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. __ 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] algorithm for clustering categorical data
Read up on Gower's Distance measures (available in the ecodist package) which can combine numeric and categorical data. You didn't give us any information about how you numerically transformed the categorical variables, but the usual approach is to create indicator variables that code presence/absence for each category within a categorical variable. Different variances between variables can be reduced by standardizing the variables. - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Li, Yan Sent: Thursday, August 1, 2013 11:00 AM To: r-help@r-project.org Subject: [R] algorithm for clustering categorical data Hi All, Does anyone know what algorithm for clustering categorical variables? R packages? Which is the best? If a data has both numeric and categorical data, what is the best clustering algorithm to use and R package? I tried numeric transformation of all categorical fields and doing clustering afterwards. But the transformed fields have values from 1...10, and my other fields is in a bigger scale: 1-...This will make the categorical fields has less effect on the distance calculation... Thank you! Yan [[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-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] algorithm for clustering categorical data
Great! Thanks! Yeah, I just use the usual way: as.numeric(..) for numeric transformation...seemed a standardization is needed. Thank you. -Original Message- From: David Carlson [mailto:dcarl...@tamu.edu] Sent: Thursday, August 01, 2013 12:08 PM To: Li, Yan; r-help@r-project.org Subject: RE: [R] algorithm for clustering categorical data Read up on Gower's Distance measures (available in the ecodist package) which can combine numeric and categorical data. You didn't give us any information about how you numerically transformed the categorical variables, but the usual approach is to create indicator variables that code presence/absence for each category within a categorical variable. Different variances between variables can be reduced by standardizing the variables. - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Li, Yan Sent: Thursday, August 1, 2013 11:00 AM To: r-help@r-project.org Subject: [R] algorithm for clustering categorical data Hi All, Does anyone know what algorithm for clustering categorical variables? R packages? Which is the best? If a data has both numeric and categorical data, what is the best clustering algorithm to use and R package? I tried numeric transformation of all categorical fields and doing clustering afterwards. But the transformed fields have values from 1...10, and my other fields is in a bigger scale: 1-...This will make the categorical fields has less effect on the distance calculation... Thank you! Yan [[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-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] algorithm for clustering categorical data
On Aug 1, 2013, at 9:00 AM, Li, Yan wrote: Hi All, Does anyone know what algorithm for clustering categorical variables? R packages? Many. http://cran.r-project.org/web/views/Cluster.html Which is the best? For what purpose? If a data has both numeric and categorical data, what is the best clustering algorithm to use and R package? I tried numeric transformation of all categorical fields and doing clustering afterwards. But the transformed fields have values from 1...10, and my other fields is in a bigger scale: 1-...This will make the categorical fields has less effect on the distance calculation... This seems impossibly vague and confused. You are asked in the Posting Guide to provide a working example if you want help with code. -- David. David Winsemius Alameda, CA, USA __ 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] algorithm for clustering categorical data
Thanks for the reply From the link you provided, only two packages mentioned categorical field: depmix and depmixS4. I'll look at them. -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Thursday, August 01, 2013 12:15 PM To: Li, Yan Cc: r-help@r-project.org Subject: Re: [R] algorithm for clustering categorical data On Aug 1, 2013, at 9:00 AM, Li, Yan wrote: Hi All, Does anyone know what algorithm for clustering categorical variables? R packages? Many. http://cran.r-project.org/web/views/Cluster.html Which is the best? For what purpose? If a data has both numeric and categorical data, what is the best clustering algorithm to use and R package? I tried numeric transformation of all categorical fields and doing clustering afterwards. But the transformed fields have values from 1...10, and my other fields is in a bigger scale: 1-...This will make the categorical fields has less effect on the distance calculation... This seems impossibly vague and confused. You are asked in the Posting Guide to provide a working example if you want help with code. -- David. David Winsemius Alameda, CA, USA __ 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] Conversion of matrix in r to integer
Hi, It is better to keep it as a data.frame as matrix cannot hold different classes together, so it automatically converts the other columns into character as the first column gene is character. dat1- read.table(RP_matrix_RF_ZPTvsPGR.txt,sep=,header=TRUE,stringsAsFactors=FALSE) dat1[,-1]- lapply(lapply(dat1[,-1],round),as.integer) str(dat1) #'data.frame': 28597 obs. of 8 variables: # $ gene : chr XLOC_01 XLOC_02 XLOC_03 XLOC_04 ... # $ ZPT.1: int 3516 342 2000 143 0 0 0 0 0 7 ... # $ ZPT.0: int 626 82 361 30 0 0 0 0 0 1 ... # $ ZPT.2: int 1277 185 867 67 0 0 0 0 0 5 ... # $ ZPT.3: int 770 72 438 37 0 0 0 0 0 3 ... # $ PGR.1: int 2603 304 195 66 0 1 0 0 0 0 ... # $ PGR.0: int 1534 175 80 49 0 0 1 0 0 0 ... # $ PGR.2: int 1764 208 109 54 0 0 1 0 0 1 ... In case you want it as matrix: then mat1- as.matrix(dat1[,-1]) row.names(mat1)- dat1[,1] str(mat1) # int [1:28597, 1:7] 3516 342 2000 143 0 0 0 0 0 7 ... # - attr(*, dimnames)=List of 2 # ..$ : chr [1:28597] XLOC_01 XLOC_02 XLOC_03 XLOC_04 ... # ..$ : chr [1:7] ZPT.1 ZPT.0 ZPT.2 ZPT.3 ... head(mat1) # ZPT.1 ZPT.0 ZPT.2 ZPT.3 PGR.1 PGR.0 PGR.2 #XLOC_01 3516 626 1277 770 2603 1534 1764 #XLOC_02 342 82 185 72 304 175 208 #XLOC_03 2000 361 867 438 195 80 109 #XLOC_04 143 30 67 37 66 49 54 #XLOC_05 0 0 0 0 0 0 0 #XLOC_06 0 0 0 0 1 0 0 A.K. From: Vivek Das vd4mm...@gmail.com To: arun smartpink...@yahoo.com; R help r-help@r-project.org Sent: Thursday, August 1, 2013 11:48 AM Subject: Conversion of matrix in r to integer Hi, I have a matrix which which I need for some analysis and that package in R only works on integer values. My data.frame is not integer value . I want to convert the values to the nearest integer values for my matrix. Can you tell me how to do it in r. I am sending you the matrix where you can see a lot of decimal point numbers and all of them needs to be converted to integer values -- Vivek Das PhD Student in Computational Biology Giuseppe Testa's Lab European School of Molecular Medicine IFOM-IEO Campus Via Adamello, 16 Milan, Italy emails: vivek@ieo.eu vchris...@yahoo.co.in vd4mm...@gmail.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] Error Help: duplicate?
On Aug 1, 2013, at 18:09 , Jeff Newmiller wrote: Your example is not reproducible, so we can only guess what is happening. Please read the footer of this (or any other R-help) email and follow those instructions. You may also find the discussion at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example helpful. However, eliminating the reuse of newdata2 might help. In particular, if you accidentally repeat the cbind() step, you _will_ end up with a data frame with duplicate column names. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Docbanks84 mban...@partners.org wrote: Hi, I'm working through practice data in R and I am held up on this step. I am not sure why there is an error that claims there is a duplicate subscript for columns? Does anyone know what this means and how I can fix it? newdata2-cbind(newdata2,predict(mylogit,newdata=newdata2,type=link,se=TRUE)) newdata2-within(newdata2,{PredictedProb-plogis(fit) + LL-plogis(fit- (1.96 * se.fit)) + UL-plogis(fit + (1.96 *se.fit)) + }) Error in `[-.data.frame`(`*tmp*`, nl, value = list(UL = c(0.549206434665668, : duplicate subscripts for columns -- View this message in context: http://r.789695.n4.nabble.com/Error-Help-duplicate-tp4672819.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. __ 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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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] 'format' behaviour in a 'apply' call depending on 'options(digits = K)'
I see the problem on both Linux and Windows, R-3.0.1. vapply(as.numeric(9994:9995), function(x)format(x, scientific=FALSE, digits=3), ) [1] 9994 9995 vapply(as.numeric(4:5), function(x)format(x, scientific=FALSE, digits=4), ) [1] 4 5 vapply(as.numeric(94:95), function(x)format(x, scientific=FALSE, digits=5), ) [1] 94 95 The ones with the initial space are the ones that would round up to the next power of 10 when rounded to the requested number of significant digits: x - as.numeric(1:5e5) z - vapply(x, function(x)format(x, scientific=FALSE, digits=3), ) i - grep( , z) z[i] [1] 9995 9996 9997 9998 99950 99951 99952 [9] 99953 99954 99955 99956 99957 99958 99959 99960 [17] 99961 99962 99963 99964 99965 99966 99967 99968 [25] 99969 99970 99971 99972 99973 99974 99975 99976 [33] 99977 99978 99979 99980 99981 99982 99983 99984 [41] 99985 99986 99987 99988 99989 0 1 2 [49] 3 4 5 6 7 8 9 print(x[i], digits=3) [1] 1e+04 1e+04 1e+04 1e+04 1e+04 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [13] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [25] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [37] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [49] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mathieu Basille Sent: Thursday, August 01, 2013 8:31 AM To: R help Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' This problem does not seem to be widely popular, but at least affects two users (both on Linux, maybe a hint here?). To me, it looks like a bug (is it a R bug, or a OS-related bug, I don't know). Should I forward it to R-devel, or some other place where R gurus may have a chance to look at it? Mathieu. Le 07/30/2013 02:34 PM, arun a écrit : Hi Mathieu yes, the original problem occurs in my system too. I am using R 3.0.1 on linux mint 15. I guess the default case would be trim=FALSE, but still it looks very strange especially in ?apply(), as it starts from 5 onwards. sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] stringr_0.6.2 reshape2_1.2.2 loaded via a namespace (and not attached): [1] plyr_1.8tools_3.0.1 - Original Message - From: Mathieu Basille basille@ase-research.org To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, July 30, 2013 2:29 PM Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Thanks Arun for your answer. 'trim = TRUE' does indeed solve the symptoms of the problem, and this is the solution I'm currently using. However, it does not help to understand what the problem is, and what is the cause of it. Can you confirm that the original problem also occurs on your computer (and what is your OS)? It would be interesting since David is not able to reproduce the problem with Mac OS X. Mathieu. Le 07/30/2013 02:15 PM, arun a écrit : Hi, Try using trim=TRUE, in ?format() options(digits=4) df2 - data.frame(x = rnorm(11), y = rnorm(11), id = 1:11) df2$id2 - apply(df2, 1, function(dfi) format(dfi[id], trim=TRUE,scientific = FALSE)) df2$id2[0:100010] # [1] 0 1 2 3 4 5 6 7 # [9] 8 9 10 11 12 13 14 15 #[17] 16 17 18 19 100010 id2 - format(1:11, scientific = FALSE,trim=TRUE) id2[0:100010] # [1] 0 1 2 3 4 5 6 7 #[9] 8 9 10 11 12 13 14 15 #[17] 16 17 18 19 100010 A.K. - Original Message - From: Mathieu Basille basille@ase-research.org To: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Sent: Tuesday, July 30, 2013 2:07 PM Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Thanks David for your interest. I have to admit that your answer puzzles me even more than before. It seems that the underlying problem is
[R] Replicate an SAS/SQL request
I am very confuse, I send with a wrong subject. All my Apologizes - De : Guibert TCHINDE Date d'envoi : jeudi 1 août 2013 18:51 À : r-help@r-project.org Cc : R help Objet : RE : [R] Conversion of matrix in r to integer Dear List, I am trying to replicate an SQL request run wih SAS using R The request is : PROC SQL; CREATE VIEW myview AS SELECT a.*, b.semaine b.date_debut b.date_fin FROM myfirsttable. a INNER JOIN mycalendar ON ( a.DEBUT1= b.date_fin AND a.FIN= b.date_debut AND (a.MIG = 'O' AND a.DATE_MIG = b. date_fin) QUIT; Like we see, ther's not join key between the two datasets and the job run by sas is to : make cartesian product and subsetting according to the conditions So when i try to replicate this in R. I do this : system.time(extract-merge(myfirsttable,mycalendar)) utilisateur système écoulé 6509.51 47.61 6792.12 system.time(VueAnalyse-subset(extracts, +(DEBUT1=date_fin FIN=date_debut) +((MIG == 'O' DATE_MIG = date_fin)) utilisateur système écoulé 178.59 14.07 211.11 The first datasets contains 40 millions rows and the second just 5. So the first cartesian product take ~2 hours. Somebody have any idea to do this in R with less time? Thanks in advance Regards, GT __ 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] Forest plot with sub-group analyses
Greetings. I am conducting a meta analyses that has Beta and SE values. I am wondering how to place the command to split the analyses. Could you assist me to develop the command within the syntax? I would also like to add the N and Year values in the plot. I would like my plot to look like the one below: http://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups#code I attach here in an example of the syntax I have come up with so far and csv file I am using. I look forward to your response and thank you in advance. Regards, -- Wanjiku N Gichohi Tel: +254723766517 / +31645272661 Email: wanjiku_nyaw...@yahoo.com / wngich...@gmail.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.
[R] use Vectorized function as range of for statement
I guess this has been discussed before, but I don't know the name of this problem, thus had to ask again. Consider this scenario: fun - function(x) { print(x)} for (i in Vectorize(fun, x)(1:3)) print(OK) [1] 1 [1] 2 [1] 3 [1] OK [1] OK [1] OK The optimal behaviour is: fun - function(x) { print(x)} for (i in Vectorize(fun, x)(1:3)) print(OK) [1] 1 [1] OK [1] 2 [1] OK [1] 3 [1] OK That is, each iteration of vectorized function should yield some result for the 'for' statement, rather than having all results collected beforehand. The intention of such a pattern, is to separates the data generation logic from data processing logic. The latter mechanism, I think, is more efficient because it doesn't cache all data before processing -- and the interpreter has the sure knowledge that caching is not needed, since the vectorized function is not used in assignment but as a range. The difference may be trivial, but this pseud code demonstrates otherwise: readSample - function(x) { sampling_time - readBin(con, integer(), 1, size=4) sample_count - readBin(con, integer(), 1, size=2) samples - readBin(con, float(), sample_count, size=4) matrix # return a big matrix representing a sample } for (sample in Vectorize(readSample, x)(1:1)) { # process sample } The data file is a few Gigabytes, and caching them is not effortless. Not having to cache them would make a difference. This email asks to 1. validate this need of the langauge; 2. alternative design pattern to workaround it; 3. Ask the proper place to discuss this. Thanks and best... __ 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] 'format' behaviour in a 'apply' call depending on 'options(digits = K)'
Nicely spotted, Bill! You went much farther than I could have. We can basically summarize the problem with the following simple example: format(9994, digits = 3) [1] 9994 format(9995, digits = 3) [1] 9995 I'm still not sure why this is happening, though: The 'digits' parameter is used to guess the number of characters of the output, but not to format the actual number (i.e. all digits are still there anyway)? Is this case a bug, or a feature? And if the latter, is it documented anywhere? I couldn't see any hint of it in ?format, or ?options... The use of 'trim = TRUE' to fix the problem seems to me like a workaround, not a real solution... Lastly, should I report this somewhere else? Thanks for your comment, Mathieu. Le 08/01/2013 12:36 PM, William Dunlap a écrit : I see the problem on both Linux and Windows, R-3.0.1. vapply(as.numeric(9994:9995), function(x)format(x, scientific=FALSE, digits=3), ) [1] 9994 9995 vapply(as.numeric(4:5), function(x)format(x, scientific=FALSE, digits=4), ) [1] 4 5 vapply(as.numeric(94:95), function(x)format(x, scientific=FALSE, digits=5), ) [1] 94 95 The ones with the initial space are the ones that would round up to the next power of 10 when rounded to the requested number of significant digits: x - as.numeric(1:5e5) z - vapply(x, function(x)format(x, scientific=FALSE, digits=3), ) i - grep( , z) z[i] [1] 9995 9996 9997 9998 99950 99951 99952 [9] 99953 99954 99955 99956 99957 99958 99959 99960 [17] 99961 99962 99963 99964 99965 99966 99967 99968 [25] 99969 99970 99971 99972 99973 99974 99975 99976 [33] 99977 99978 99979 99980 99981 99982 99983 99984 [41] 99985 99986 99987 99988 99989 0 1 2 [49] 3 4 5 6 7 8 9 print(x[i], digits=3) [1] 1e+04 1e+04 1e+04 1e+04 1e+04 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [13] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [25] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [37] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [49] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mathieu Basille Sent: Thursday, August 01, 2013 8:31 AM To: R help Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' This problem does not seem to be widely popular, but at least affects two users (both on Linux, maybe a hint here?). To me, it looks like a bug (is it a R bug, or a OS-related bug, I don't know). Should I forward it to R-devel, or some other place where R gurus may have a chance to look at it? Mathieu. Le 07/30/2013 02:34 PM, arun a écrit : Hi Mathieu yes, the original problem occurs in my system too. I am using R 3.0.1 on linux mint 15. I guess the default case would be trim=FALSE, but still it looks very strange especially in ?apply(), as it starts from 5 onwards. sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] stringr_0.6.2 reshape2_1.2.2 loaded via a namespace (and not attached): [1] plyr_1.8tools_3.0.1 - Original Message - From: Mathieu Basille basille@ase-research.org To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, July 30, 2013 2:29 PM Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Thanks Arun for your answer. 'trim = TRUE' does indeed solve the symptoms of the problem, and this is the solution I'm currently using. However, it does not help to understand what the problem is, and what is the cause of it. Can you confirm that the original problem also occurs on your computer (and what is your OS)? It would be interesting since David is not able to reproduce the problem with Mac OS X. Mathieu. Le 07/30/2013 02:15 PM, arun a écrit : Hi, Try using trim=TRUE, in ?format() options(digits=4) df2 - data.frame(x = rnorm(11), y = rnorm(11), id = 1:11) df2$id2 - apply(df2, 1, function(dfi) format(dfi[id], trim=TRUE,scientific = FALSE)) df2$id2[0:100010] # [1] 0 1 2 3 4 5 6 7 # [9] 8 9 10 11 12 13 14 15 #[17] 16 17 18 19 100010 id2 -
Re: [R] Conversion of matrix in r to integer
Assuming you have created a data.frame from the text file you sent that is called RP: str(RP) # 'data.frame': 28597 obs. of 8 variables: # $ gene : chr XLOC_01 XLOC_02 XLOC_03 XLOC_04 ... # $ ZPT.1: num 3516 342 2000 143 0 ... # $ ZPT.0: num 626 82 361 30 0 0 0 0 0 1 ... # $ ZPT.2: num 1277 185 867 67 0 ... # $ ZPT.3: num 770 72 438 37 0 0 0 0 0 3 ... # $ PGR.1: num 2603 304 195 66 0 ... # $ PGR.0: num 1534 175 80 49 0 ... # $ PGR.2: num 1764 208 109 54 0 ... RP[,-1] - sapply(round(RP[,-1], 0), as.integer) str(RP) # 'data.frame': 28597 obs. of 8 variables: # $ gene : chr XLOC_01 XLOC_02 XLOC_03 XLOC_04 ... # $ ZPT.1: int 3516 342 2000 143 0 0 0 0 0 7 ... # $ ZPT.0: int 626 82 361 30 0 0 0 0 0 1 ... # $ ZPT.2: int 1277 185 867 67 0 0 0 0 0 5 ... # $ ZPT.3: int 770 72 438 37 0 0 0 0 0 3 ... # $ PGR.1: int 2603 304 195 66 0 1 0 0 0 0 ... # $ PGR.0: int 1534 175 80 49 0 0 1 0 0 0 ... # $ PGR.2: int 1764 208 109 54 0 0 1 0 0 1 ... - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Vivek Das Sent: Thursday, August 1, 2013 10:49 AM To: arun; R help Subject: [R] Conversion of matrix in r to integer Hi, I have a matrix which which I need for some analysis and that package in R only works on integer values. My data.frame is not integer value . I want to convert the values to the nearest integer values for my matrix. Can you tell me how to do it in r. I am sending you the matrix where you can see a lot of decimal point numbers and all of them needs to be converted to integer values -- Vivek Das PhD Student in Computational Biology Giuseppe Testa's Lab European School of Molecular Medicine IFOM-IEO Campus Via Adamello, 16 Milan, Italy emails: vivek@ieo.eu vchris...@yahoo.co.in vd4mm...@gmail.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] 'format' behaviour in a 'apply' call depending on 'options(digits = K)'
You could report it as a bug at https://bugs.r-project.org/bugzilla3/ Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: Mathieu Basille [mailto:basille@ase-research.org] Sent: Thursday, August 01, 2013 10:31 AM To: R help Cc: William Dunlap Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Nicely spotted, Bill! You went much farther than I could have. We can basically summarize the problem with the following simple example: format(9994, digits = 3) [1] 9994 format(9995, digits = 3) [1] 9995 I'm still not sure why this is happening, though: The 'digits' parameter is used to guess the number of characters of the output, but not to format the actual number (i.e. all digits are still there anyway)? Is this case a bug, or a feature? And if the latter, is it documented anywhere? I couldn't see any hint of it in ?format, or ?options... The use of 'trim = TRUE' to fix the problem seems to me like a workaround, not a real solution... Lastly, should I report this somewhere else? Thanks for your comment, Mathieu. Le 08/01/2013 12:36 PM, William Dunlap a écrit : I see the problem on both Linux and Windows, R-3.0.1. vapply(as.numeric(9994:9995), function(x)format(x, scientific=FALSE, digits=3), ) [1] 9994 9995 vapply(as.numeric(4:5), function(x)format(x, scientific=FALSE, digits=4), ) [1] 4 5 vapply(as.numeric(94:95), function(x)format(x, scientific=FALSE, digits=5), ) [1] 94 95 The ones with the initial space are the ones that would round up to the next power of 10 when rounded to the requested number of significant digits: x - as.numeric(1:5e5) z - vapply(x, function(x)format(x, scientific=FALSE, digits=3), ) i - grep( , z) z[i] [1] 9995 9996 9997 9998 99950 99951 99952 [9] 99953 99954 99955 99956 99957 99958 99959 99960 [17] 99961 99962 99963 99964 99965 99966 99967 99968 [25] 99969 99970 99971 99972 99973 99974 99975 99976 [33] 99977 99978 99979 99980 99981 99982 99983 99984 [41] 99985 99986 99987 99988 99989 0 1 2 [49] 3 4 5 6 7 8 9 print(x[i], digits=3) [1] 1e+04 1e+04 1e+04 1e+04 1e+04 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [13] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [25] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [37] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 [49] 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 1e+05 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mathieu Basille Sent: Thursday, August 01, 2013 8:31 AM To: R help Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' This problem does not seem to be widely popular, but at least affects two users (both on Linux, maybe a hint here?). To me, it looks like a bug (is it a R bug, or a OS-related bug, I don't know). Should I forward it to R-devel, or some other place where R gurus may have a chance to look at it? Mathieu. Le 07/30/2013 02:34 PM, arun a écrit : Hi Mathieu yes, the original problem occurs in my system too. I am using R 3.0.1 on linux mint 15. I guess the default case would be trim=FALSE, but still it looks very strange especially in ?apply(), as it starts from 5 onwards. sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] stringr_0.6.2 reshape2_1.2.2 loaded via a namespace (and not attached): [1] plyr_1.8tools_3.0.1 - Original Message - From: Mathieu Basille basille@ase-research.org To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, July 30, 2013 2:29 PM Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Thanks Arun for your answer. 'trim = TRUE' does indeed solve the symptoms of the problem, and this is the solution I'm currently using. However, it does not help to understand what the problem is, and what is the cause of it. Can you confirm that the original
[R] Bayesian Variance Components Estimation
Hi all, Does anyone know whether there is an R function available to find the Bayesian variance components estimators for random effects or mixed models? Thank you very much. Hanna [[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] Conversion of matrix in r to integer
Thanks David. It is more compact than my code. dat1- read.table(RP_matrix_RF_ZPTvsPGR.txt,sep=,header=TRUE,stringsAsFactors=FALSE) dat2- dat1 #Speed comparison: system.time(dat1[,-1]- lapply(lapply(dat1[,-1],round),as.integer)) # user system elapsed #0.012 0.000 0.011 system.time(dat2[,-1] - sapply(round(dat2[,-1], 0), as.integer)) # user system elapsed # 0.440 0.000 0.441 identical(dat1,dat2) #[1] TRUE A.K. - Original Message - From: David Carlson dcarl...@tamu.edu To: 'Vivek Das' vd4mm...@gmail.com; 'arun' smartpink...@yahoo.com; 'R help' r-help@r-project.org Cc: Sent: Thursday, August 1, 2013 1:46 PM Subject: RE: [R] Conversion of matrix in r to integer Assuming you have created a data.frame from the text file you sent that is called RP: str(RP) # 'data.frame': 28597 obs. of 8 variables: # $ gene : chr XLOC_01 XLOC_02 XLOC_03 XLOC_04 ... # $ ZPT.1: num 3516 342 2000 143 0 ... # $ ZPT.0: num 626 82 361 30 0 0 0 0 0 1 ... # $ ZPT.2: num 1277 185 867 67 0 ... # $ ZPT.3: num 770 72 438 37 0 0 0 0 0 3 ... # $ PGR.1: num 2603 304 195 66 0 ... # $ PGR.0: num 1534 175 80 49 0 ... # $ PGR.2: num 1764 208 109 54 0 ... RP[,-1] - sapply(round(RP[,-1], 0), as.integer) str(RP) # 'data.frame': 28597 obs. of 8 variables: # $ gene : chr XLOC_01 XLOC_02 XLOC_03 XLOC_04 ... # $ ZPT.1: int 3516 342 2000 143 0 0 0 0 0 7 ... # $ ZPT.0: int 626 82 361 30 0 0 0 0 0 1 ... # $ ZPT.2: int 1277 185 867 67 0 0 0 0 0 5 ... # $ ZPT.3: int 770 72 438 37 0 0 0 0 0 3 ... # $ PGR.1: int 2603 304 195 66 0 1 0 0 0 0 ... # $ PGR.0: int 1534 175 80 49 0 0 1 0 0 0 ... # $ PGR.2: int 1764 208 109 54 0 0 1 0 0 1 ... - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Vivek Das Sent: Thursday, August 1, 2013 10:49 AM To: arun; R help Subject: [R] Conversion of matrix in r to integer Hi, I have a matrix which which I need for some analysis and that package in R only works on integer values. My data.frame is not integer value . I want to convert the values to the nearest integer values for my matrix. Can you tell me how to do it in r. I am sending you the matrix where you can see a lot of decimal point numbers and all of them needs to be converted to integer values -- Vivek Das PhD Student in Computational Biology Giuseppe Testa's Lab European School of Molecular Medicine IFOM-IEO Campus Via Adamello, 16 Milan, Italy emails: vivek@ieo.eu vchris...@yahoo.co.in vd4mm...@gmail.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] use Vectorized function as range of for statement
I think this is on topic here, but a reproducible example is highly desirable if not required for clarity. The Vectorize function is essentially a wrapped up for loop, so you are really executing two successive for loops. Note that the Vectorize function is not itself vectorised, so there is no particular advantage to using it in this way. You might as well call fun as a statement in the for loop. However, interleaving output and computation is quite inefficient, so it it strongly recommended to handle output in its own loop or function in most cases. This allows true vectorization to be applied to the computation phase. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Zhang Weiwu zhangwe...@realss.com wrote: I guess this has been discussed before, but I don't know the name of this problem, thus had to ask again. Consider this scenario: fun - function(x) { print(x)} for (i in Vectorize(fun, x)(1:3)) print(OK) [1] 1 [1] 2 [1] 3 [1] OK [1] OK [1] OK The optimal behaviour is: fun - function(x) { print(x)} for (i in Vectorize(fun, x)(1:3)) print(OK) [1] 1 [1] OK [1] 2 [1] OK [1] 3 [1] OK That is, each iteration of vectorized function should yield some result for the 'for' statement, rather than having all results collected beforehand. The intention of such a pattern, is to separates the data generation logic from data processing logic. The latter mechanism, I think, is more efficient because it doesn't cache all data before processing -- and the interpreter has the sure knowledge that caching is not needed, since the vectorized function is not used in assignment but as a range. The difference may be trivial, but this pseud code demonstrates otherwise: readSample - function(x) { sampling_time - readBin(con, integer(), 1, size=4) sample_count - readBin(con, integer(), 1, size=2) samples - readBin(con, float(), sample_count, size=4) matrix # return a big matrix representing a sample } for (sample in Vectorize(readSample, x)(1:1)) { # process sample } The data file is a few Gigabytes, and caching them is not effortless. Not having to cache them would make a difference. This email asks to 1. validate this need of the langauge; 2. alternative design pattern to workaround it; 3. Ask the proper place to discuss this. Thanks and best... __ 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] 'format' behaviour in a 'apply' call depending on 'options(digits = K)'
Hi Mathieu, I don't have a full explanation, but here is some additional observations: options(digits = 4) ## Simplified example df2 - data.frame(x = rnorm(21), y = rnorm(21), id = 0:100010) apply(df2, 1, function(dfi) format(dfi[id], scientific = FALSE)) [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 [15] 14 15 16 17 18 19 100010 ## Based on magnitude of id ( 9994 gets padded regardless of position) df2 - data.frame(x = rnorm(21), y = rnorm(21), id = 100010:0) apply(df2, 1, function(dfi) format(dfi[id], scientific = FALSE)) [1] 100010 19 18 17 16 15 14 13 12 11 10 9 8 7 [15] 6 5 4 3 2 1 0 ## The issue is that formatting a double leads to the originally noted behavior. ## The apply version coerces df2 to a matrix of type double which is why this ## happens there as well. for(i in 1:nrow(df2)) print(format(df2[i, id], scientific=FALSE)) [1] 100010 [1] 19 [1] 18 [1] 17 [1] 16 [1] 15 [1] 14 [1] 13 [1] 12 [1] 11 [1] 10 [1] 9 [1] 8 [1] 7 [1] 6 [1] 5 [1] 4 [1] 3 [1] 2 [1] 1 [1] 0 for(i in 1:nrow(df2)) print(format(as.double(df2[i, id]), scientific=FALSE)) [1] 100010 [1] 19 [1] 18 [1] 17 [1] 16 [1] 15 [1] 14 [1] 13 [1] 12 [1] 11 [1] 10 [1] 9 [1] 8 [1] 7 [1] 6 [1] 5 [1] 4 [1] 3 [1] 2 [1] 1 [1] 0 Best, Ista On Thu, Aug 1, 2013 at 11:31 AM, Mathieu Basille basille@ase-research.org wrote: This problem does not seem to be widely popular, but at least affects two users (both on Linux, maybe a hint here?). To me, it looks like a bug (is it a R bug, or a OS-related bug, I don't know). Should I forward it to R-devel, or some other place where R gurus may have a chance to look at it? Mathieu. Le 07/30/2013 02:34 PM, arun a écrit : Hi Mathieu yes, the original problem occurs in my system too. I am using R 3.0.1 on linux mint 15. I guess the default case would be trim=FALSE, but still it looks very strange especially in ?apply(), as it starts from 5 onwards. sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] stringr_0.6.2 reshape2_1.2.2 loaded via a namespace (and not attached): [1] plyr_1.8tools_3.0.1 - Original Message - From: Mathieu Basille basille@ase-research.org To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, July 30, 2013 2:29 PM Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Thanks Arun for your answer. 'trim = TRUE' does indeed solve the symptoms of the problem, and this is the solution I'm currently using. However, it does not help to understand what the problem is, and what is the cause of it. Can you confirm that the original problem also occurs on your computer (and what is your OS)? It would be interesting since David is not able to reproduce the problem with Mac OS X. Mathieu. Le 07/30/2013 02:15 PM, arun a écrit : Hi, Try using trim=TRUE, in ?format() options(digits=4) df2 - data.frame(x = rnorm(11), y = rnorm(11), id = 1:11) df2$id2 - apply(df2, 1, function(dfi) format(dfi[id], trim=TRUE,scientific = FALSE)) df2$id2[0:100010] # [1] 0 1 2 3 4 5 6 7 # [9] 8 9 10 11 12 13 14 15 #[17] 16 17 18 19 100010 id2 - format(1:11, scientific = FALSE,trim=TRUE) id2[0:100010] # [1] 0 1 2 3 4 5 6 7 #[9] 8 9 10 11 12 13 14 15 #[17] 16 17 18 19 100010 A.K. - Original Message - From: Mathieu Basille basille@ase-research.org To: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Sent: Tuesday, July 30, 2013 2:07 PM Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Thanks David for your interest. I have to admit that your answer puzzles me even more than before. It seems that the underlying problem is way beyond my R skills... The generation of id2 is indeed quite demanding, especially compared to a simple 'as.character' call. Anyway, since it seems to be system specific, here is the sessionInfo() that I forgot to attach to my first
Re: [R] Bayesian Variance Components Estimation
I suggest you post this on the r-sig-mixed-models list, instead, as there are likely to be follow-up questions and that is where there is the most interest in this sort of thing. Cheers, Bert On Thu, Aug 1, 2013 at 10:56 AM, li li hannah@gmail.com wrote: Hi all, Does anyone know whether there is an R function available to find the Bayesian variance components estimators for random effects or mixed models? Thank you very much. Hanna [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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] Bayesian Variance Components Estimation
... and please search before posting. Googling bayesian mixed models in R brought up package blme among others. -- Bert On Thu, Aug 1, 2013 at 11:10 AM, Bert Gunter bgun...@gene.com wrote: I suggest you post this on the r-sig-mixed-models list, instead, as there are likely to be follow-up questions and that is where there is the most interest in this sort of thing. Cheers, Bert On Thu, Aug 1, 2013 at 10:56 AM, li li hannah@gmail.com wrote: Hi all, Does anyone know whether there is an R function available to find the Bayesian variance components estimators for random effects or mixed models? Thank you very much. Hanna [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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] 'format' behaviour in a 'apply' call depending on 'options(digits = K)'
Ista, you were right with the integer vs. double issue: I just found this out while filing a bug to the R Bugzilla. You can find the bug report here: https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15411 Please let me know if it does not seem to cover all your comments, I'll add more details in the bug report. Let's see now how this one turns out... Mathieu. Le 08/01/2013 02:08 PM, Ista Zahn a écrit : Hi Mathieu, I don't have a full explanation, but here is some additional observations: options(digits = 4) ## Simplified example df2 - data.frame(x = rnorm(21), y = rnorm(21), id = 0:100010) apply(df2, 1, function(dfi) format(dfi[id], scientific = FALSE)) [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 [15] 14 15 16 17 18 19 100010 ## Based on magnitude of id ( 9994 gets padded regardless of position) df2 - data.frame(x = rnorm(21), y = rnorm(21), id = 100010:0) apply(df2, 1, function(dfi) format(dfi[id], scientific = FALSE)) [1] 100010 19 18 17 16 15 14 13 12 11 10 9 8 7 [15] 6 5 4 3 2 1 0 ## The issue is that formatting a double leads to the originally noted behavior. ## The apply version coerces df2 to a matrix of type double which is why this ## happens there as well. for(i in 1:nrow(df2)) print(format(df2[i, id], scientific=FALSE)) [1] 100010 [1] 19 [1] 18 [1] 17 [1] 16 [1] 15 [1] 14 [1] 13 [1] 12 [1] 11 [1] 10 [1] 9 [1] 8 [1] 7 [1] 6 [1] 5 [1] 4 [1] 3 [1] 2 [1] 1 [1] 0 for(i in 1:nrow(df2)) print(format(as.double(df2[i, id]), scientific=FALSE)) [1] 100010 [1] 19 [1] 18 [1] 17 [1] 16 [1] 15 [1] 14 [1] 13 [1] 12 [1] 11 [1] 10 [1] 9 [1] 8 [1] 7 [1] 6 [1] 5 [1] 4 [1] 3 [1] 2 [1] 1 [1] 0 Best, Ista On Thu, Aug 1, 2013 at 11:31 AM, Mathieu Basille basille@ase-research.org wrote: This problem does not seem to be widely popular, but at least affects two users (both on Linux, maybe a hint here?). To me, it looks like a bug (is it a R bug, or a OS-related bug, I don't know). Should I forward it to R-devel, or some other place where R gurus may have a chance to look at it? Mathieu. Le 07/30/2013 02:34 PM, arun a écrit : Hi Mathieu yes, the original problem occurs in my system too. I am using R 3.0.1 on linux mint 15. I guess the default case would be trim=FALSE, but still it looks very strange especially in ?apply(), as it starts from 5 onwards. sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] stringr_0.6.2 reshape2_1.2.2 loaded via a namespace (and not attached): [1] plyr_1.8tools_3.0.1 - Original Message - From: Mathieu Basille basille@ase-research.org To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Tuesday, July 30, 2013 2:29 PM Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Thanks Arun for your answer. 'trim = TRUE' does indeed solve the symptoms of the problem, and this is the solution I'm currently using. However, it does not help to understand what the problem is, and what is the cause of it. Can you confirm that the original problem also occurs on your computer (and what is your OS)? It would be interesting since David is not able to reproduce the problem with Mac OS X. Mathieu. Le 07/30/2013 02:15 PM, arun a écrit : Hi, Try using trim=TRUE, in ?format() options(digits=4) df2 - data.frame(x = rnorm(11), y = rnorm(11), id = 1:11) df2$id2 - apply(df2, 1, function(dfi) format(dfi[id], trim=TRUE,scientific = FALSE)) df2$id2[0:100010] # [1] 0 1 2 3 4 5 6 7 # [9] 8 9 10 11 12 13 14 15 #[17] 16 17 18 19 100010 id2 - format(1:11, scientific = FALSE,trim=TRUE) id2[0:100010] # [1] 0 1 2 3 4 5 6 7 #[9] 8 9 10 11 12 13 14 15 #[17] 16 17 18 19 100010 A.K. - Original Message - From: Mathieu Basille basille@ase-research.org To: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Sent: Tuesday, July 30, 2013 2:07 PM Subject: Re: [R] 'format' behaviour in a 'apply' call depending on 'options(digits = K)' Thanks David for your
[R] Tracing the top border of a histogram
I want to represent a histogram by the line along its top border, *without* kernel smoothing (to show several histograms in the same plot). This works, but is there simpler recommended way? x - rnorm(1000) tmp - hist(x, border=white) for (i in 1:(length(tmp$breaks)-1)){ segments(x0=tmp$breaks[i], x1=tmp$breaks[i+1], y0=tmp$counts[i]) segments(x0=tmp$breaks[i+1], y0=tmp$counts[i], y1=tmp$counts[i+1]) } [[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] Tracing the top border of a histogram
lines( tmp$breaks, c(tmp$counts,tail(tmp$counts,1)), type='s', col='#00ff0077', lwd=5 ) On Thu, Aug 1, 2013 at 1:30 PM, Levi Waldron lwaldron.resea...@gmail.comwrote: I want to represent a histogram by the line along its top border, *without* kernel smoothing (to show several histograms in the same plot). This works, but is there simpler recommended way? x - rnorm(1000) tmp - hist(x, border=white) for (i in 1:(length(tmp$breaks)-1)){ segments(x0=tmp$breaks[i], x1=tmp$breaks[i+1], y0=tmp$counts[i]) segments(x0=tmp$breaks[i+1], y0=tmp$counts[i], y1=tmp$counts[i+1]) } [[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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com [[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] rms plot.Predict when type=p
Hi all, I'm trying to change the pch, color, lty, and lwd in a type=p plot produced by plot.Predict in the rms package. What I'm shooting for is a separate plotting symbol symbol color for each level of a factor (and also to manage the line width for the CIs). Here's what I hope is a working example #make up some data n = 30 x1 = runif(n) group = factor(rep(1:3, length.out=n)) e = rnorm(n, 0, 1) #population model y = as.numeric(group) + 0.2*x1 + e #make a dataframe population.df - data.frame(x1,group,y) #clean up rm(n,x1,group,e,y) #load rms package require(rms) #store predictor characteristics d-datadist(population.df) options(datadist=d) # model. f1 - ols(y ~ x1+group, population.df) #model result summary(f1) #get predicted values pf1-Predict(f1,group) #plot myplot-plot(pf1,~group,nlines=T,type='p', ylab='fitted Y', xlab='Treatment') #print plot with defaults myplot #try to alter settings plot.symbol.settings-trellis.par.get(plot.symbol) #have a look at settings str(plot.symbol.settings) plot.symbol.settings$pch-c(1,2,3) plot.symbol.settings$col-c(2,1,3) plot.symbol.settings$lwd-3 plot.symbol.settings$cex-1.5 trellis.par.set(plot.symbol, plot.symbol.settings) #print again with new settings myplot As you can see, only the first pch and color are passed. So, obviously I am missing something important. Also, I notice that the lwd argument has no effect, so I am assuming this is controlled by something else, but I haven't found it yet. I'd be grateful if somebody could point me in the right direction. Thanks, Mike Babyak Department of Psychiatry and Behavioral Sciences Duke University Medical Center R version 3.01 Windows 7 [[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] Tracing the top border of a histogram
Very nice - thank you, I didn't know about type='s'. On Thu, Aug 1, 2013 at 3:43 PM, Greg Snow 538...@gmail.com wrote: lines( tmp$breaks, c(tmp$counts,tail(tmp$counts,1)), type='s', col='#00ff0077', lwd=5 ) On Thu, Aug 1, 2013 at 1:30 PM, Levi Waldron lwaldron.resea...@gmail.comwrote: I want to represent a histogram by the line along its top border, *without* kernel smoothing (to show several histograms in the same plot). This works, but is there simpler recommended way? x - rnorm(1000) tmp - hist(x, border=white) for (i in 1:(length(tmp$breaks)-1)){ segments(x0=tmp$breaks[i], x1=tmp$breaks[i+1], y0=tmp$counts[i]) segments(x0=tmp$breaks[i+1], y0=tmp$counts[i], y1=tmp$counts[i+1]) } [[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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com [[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-Help
Greetings. I am conducting a meta analyses that has Beta and SE values. I am wondering how to place the command to split the analyses. Could you assist me to develop the command within the syntax? I would also like to add the N and Year values in the plot. I would like my plot to look like the one below: http://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups#code I attach here in an example of the syntax I have come up with so far and csv file I am using. I look forward to your response and thank you in advance. Regards, -- Wanjiku N Gichohi Tel: +254723766517 / +31645272661 Email: wanjiku_nyaw...@yahoo.com / wngich...@gmail.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] GARCH Optimization Problems
Hi Tony, Did you try the `auglag' algorithm in alabma package? Ravi [[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 runs on Windows Server 2012?
Hi- Can someone confirm whether R runs on the Windows Server 2012 OS, and if so whether there are any significant differences from running on e.g. Windows 7 that I ought to be aware of? The R for Windows FAQ (URL below) seems to indicate that running on Windows Server 2012 is possible, but the text is a little vague and I haven't been able to find any clear answers on the mailing list archives. We are considering spending a chunk of money on a small server and I want to be very sure that R will run before we do. URL for relevant FAQ: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#How-do-I-install-R-for-Windows_003f Thanks Chris * Dr. Chris Solomon Dept. of Natural Resource Sciences McGill 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] Kolmogorov-Smirnov Test
Dear r-users, I am using KS test to test the goodness of fit for my data and the got the following output. However, I don't understand about the warning messages. What does it mean by horizontals is not a graphical parameter Thank you so much for any help given and it is very much appreciated. ks.test(compare[,1], compare[,2]) Two-sample Kolmogorov-Smirnov test data: compare[, 1] and compare[, 2] D = 0.0755, p-value = 2.238e-05 alternative hypothesis: two-sided Warning messages: 1: horizontals is not a graphical parameter 2: horizontals is not a graphical parameter 3: horizontals is not a graphical parameter 4: horizontals is not a graphical parameter 5: horizontals is not a graphical parameter 6: horizontals is not a graphical parameter 7: In ks.test(compare[, 1], compare[, 2]) : cannot compute correct p-values with ties ks.test(compare[,1], compare[,2]) Two-sample Kolmogorov-Smirnov test data: compare[, 1] and compare[, 2] D = 0.0755, p-value = 2.238e-05 alternative hypothesis: two-sided Warning messages: 1: horizontals is not a graphical parameter 2: horizontals is not a graphical parameter 3: horizontals is not a graphical parameter 4: horizontals is not a graphical parameter 5: horizontals is not a graphical parameter 6: horizontals is not a graphical parameter 7: In ks.test(compare[, 1], compare[, 2]) : cannot compute correct p-values with ties [[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] GO TO function in R
Does R has a GO TO function? For example, I want to run this script at a given interval and save the results. #Step one a - Sys.time() b - paste(Figure_, a, sep = ) shape - as.numeric(a)/1 scale - as.numeric(a)/100 #I want to save the file using b object (above) as a file name #However it is saved as b.pdf pdf(f:/b.pdf) #How to save the file using b above? par(mfrow=c(2,1)) x - sort(rgamma(100, shape=shape, scale = scale)) y - dgamma(x, shape=shape, scale = scale) par(mfrow=c(2,1)) plot(x, y, type=l,col=red, lwd=5) #Step 2 Sys.sleep(2) # For Quick results in the model it is one hour shape - (as.numeric(Sys.time()))/1 scale - (as.numeric(Sys.time()))/100 x - sort(rgamma(100, shape=shape, scale = scale)) y - dgamma(x, shape=shape, scale = scale) plot(x, y, type=b,col= dark red, lwd=5) dev.off() #Step 3 Sys.sleep(2) Again in the model it is one hour #I Want to go back to step 1 to start over again Sincerely, Peter Maclean Department of Economics UDSM [[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] GO TO function in R
There is no 'GO TO'. Try wrapping your code in a while(TRUE){...} loop. while(TRUE) { ... do something ... Sys.sleep(time) } Or you could have it read from a named pipe which some other process feeds. while(length(readLines(n=1, someNamedPipe))==1) { ... do something ... } Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Maclean Sent: Thursday, August 01, 2013 6:58 PM To: r-help@r-project.org Subject: Re: [R] GO TO function in R Does R has a GO TO function? For example, I want to run this script at a given interval and save the results. #Step one a - Sys.time() b - paste(Figure_, a, sep = ) shape - as.numeric(a)/1 scale - as.numeric(a)/100 #I want to save the file using b object (above) as a file name #However it is saved as b.pdf pdf(f:/b.pdf) #How to save the file using b above? par(mfrow=c(2,1)) x - sort(rgamma(100, shape=shape, scale = scale)) y - dgamma(x, shape=shape, scale = scale) par(mfrow=c(2,1)) plot(x, y, type=l,col=red, lwd=5) #Step 2 Sys.sleep(2) # For Quick results in the model it is one hour shape - (as.numeric(Sys.time()))/1 scale - (as.numeric(Sys.time()))/100 x - sort(rgamma(100, shape=shape, scale = scale)) y - dgamma(x, shape=shape, scale = scale) plot(x, y, type=b,col= dark red, lwd=5) dev.off() #Step 3 Sys.sleep(2) Again in the model it is one hour #I Want to go back to step 1 to start over again Sincerely, Peter Maclean Department of Economics UDSM [[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] GO TO function in R
On Aug 1, 2013, at 6:58 PM, Peter Maclean wrote: Does R has a GO TO function? For example, I want to run this script at a given interval and save the results. Generally communication is more effective if you make your goals clear in a natural language (English in the case of this mailing list) first. #Step one a - Sys.time() b - paste(Figure_, a, sep = ) shape - as.numeric(a)/1 scale - as.numeric(a)/100 #I want to save the file using b object (above) as a file name #However it is saved as b.pdf pdf(f:/b.pdf) #How to save the file using b above? Perhaps: pdf(file=paste0(f:/, b, .pdf)) par(mfrow=c(2,1)) x - sort(rgamma(100, shape=shape, scale = scale)) y - dgamma(x, shape=shape, scale = scale) par(mfrow=c(2,1)) plot(x, y, type=l,col=red, lwd=5) #Step 2 Sys.sleep(2) # For Quick results in the model it is one hour shape - (as.numeric(Sys.time()))/1 scale - (as.numeric(Sys.time()))/100 x - sort(rgamma(100, shape=shape, scale = scale)) y - dgamma(x, shape=shape, scale = scale) plot(x, y, type=b,col= dark red, lwd=5) dev.off() #Step 3 Sys.sleep(2) #Again in the model it is one hour # it? It would help if you explained what it is. #I Want to go back to step 1 to start over again I think is a measure of my success in training my mind to think functionally that I cannot conceive of how I would use GOTO as a function. (Using `replicate`, I can imagine.) -- David. Sincerely, Peter Maclean Department of Economics UDSM [[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. David Winsemius Alameda, CA, USA __ 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] merge matrix row data
Hi Elaine, I didn't find any errors by running the code. Regarding the first question, the former is of class numeric, and latter is character library(foreign) dataNP_1 -read.dbf(Anseriformes_13.dbf, as.is = FALSE) ##all the other vectors res-t(sapply(c( Conti_Australia,Conti_Korea,Conti_Malay, Island_Sumatra,Island_Bali,Island_Lombok, Island_Lesser_Sunda,Island_Maluku,Island_Sulawesi,Island_Kepu_Sula, Island_New_Guinea,Island_Palawan,Island_Phillipines, Island_Hainan,Island_Taiwan, Island_Sakishima,Island_Ryukyu,Island_Amami,Island_Osumi, Island_Kyushu,Island_Shikoku,Island_Honshu,Island_Hokkaido,Island_Sakhalin), function(x) {x1- match(get(x),dataNP_1[,1]);(!!colSums(dataNP_1[x1,-1]))*1})) head(res,3) # D0407 D0409 D0410 D0462 D0463 D0473 D0475 D0488 D0489 D0492 #Conti_Australia 0 0 1 0 0 0 0 0 0 0 #Conti_Korea 0 0 0 0 0 0 0 0 0 0 #Conti_Malay 0 0 0 1 0 0 0 0 0 0 # D0493 D0504 D0536 #Conti_Australia 0 0 0 #Conti_Korea 0 0 0 #Conti_Malay 0 0 0 A.K. From: Elaine Kuo elaine.kuo...@gmail.com To: arun smartpink...@yahoo.com Sent: Thursday, August 1, 2013 6:37 PM Subject: Re: [R] merge matrix row data Hello Arun, Thanks. I went to bed early and did not reply to your mail immediately. I have some questions. 1. What is the difference between Conti_Australia- c(1,14,18) and Conti_Australia- c(1,14,18) Both generated the same error message: Error in colSums(x1) : 'x' must be an array of at least two dimensions 2. I used your following code but found nothing NULL. lapply(c(Conti_Australia,Conti_Korea,Conti_Malay, Island_Sumatra,Island_Bali,Island_Lombok, Island_Lesser_Sunda,Island_Maluku,Island_Sulawesi,Island_Kepu_Sula, Island_New_Guinea,Island_Palawan,Island_Phillipines, Island_Hainan,Island_Taiwan, Island_Sakishima,Island_Ryukyu,Island_Amami,Island_Osumi, Island_Kyushu,Island_Shikoku,Island_Honshu,Island_Hokkaido,Island_Sakhalin), function(x) {x1- dataNP.m[match(get(x),dataNP.m[,1]),-1]}) 3. I attached the data of Anseriformes and code of islands for your reference. Thanks. Elaine On Thu, Aug 1, 2013 at 11:19 PM, arun smartpink...@yahoo.com wrote: A typo: none of the elements in one of the element should be read as: none of the elements in one of the Islands - Original Message - From: arun smartpink...@yahoo.com To: Elaine Kuo elaine.kuo...@gmail.com Cc: R help r-help@r-project.org Sent: Thursday, August 1, 2013 11:18 AM Subject: Re: [R] merge matrix row data HI Elaine, From the error, it looks like there are cases where none of the elements in one of the element matches to the GID column of dataNP.m. It's only a guess as you didn't provide information about the Islands. I was able to recreate the error you got. dataNP.m-structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L), .Dim = c(20L, 14L), .Dimnames = list(NULL, c(GID, D0407, D0409, D0410, D0462, D0463, D0473, D0475, D0488, D0489, D0492, D0493, D0504, D0536))) Conti_Australia- c(1,14,18) Conti_Malay- c(2,6,8) Island_Sumatra- c(3,9,21) Island_New_Guinea- c(22,24,28) #none of the elements are present in the GID column of example dataset lapply(c(Conti_Australia,Conti_Malay,Island_Sumatra,Island_New_Guinea),function(x) {x1- match(get(x),dataNP.m[,1]); x2-x1[!is.na(x1)];colSums(x2)}) #Error in colSums(x2) : 'x' must be an array of at least two dimensions lst1-sapply(c(Conti_Australia,Conti_Malay,Island_Sumatra,Island_New_Guinea),function(x) {x1-
[R] (no subject)
I have a comma delimited file with 62 fields of which some are comments. There are about 1.5 million records/lines. Sme of the fields which has comments and which i do not need have 40 characters. Of the 62 fields, I will need at most 12 fields. What's best way to read in the fields I need. If I read the entire file at once I will run out of memory. Could anyone please suggest some solution? Thanks, Babu. [[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] use Vectorized function as range of for statement
On Thu, 1 Aug 2013, Jeff Newmiller wrote: The Vectorize function is essentially a wrapped up for loop, so you are really executing two successive for loops. Note that the Vectorize function is not itself vectorised, so there is no particular advantage to using it in this way. You might as well call fun as a statement in the for loop. Thanks all who answered me! Now it is answered. __ 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] Editing code in a function?
Hi folks, I've not before had to edit code right in a function, but I think I need to. I am using lmer() and want to use a model that uses zero weights. I found this thread from 2009: https://stat.ethz.ch/pipermail/r-sig-mixed-models/2009q1/001995.html but I'm unsure of how I would actually go about editing the code in the package. Part of the problem is that I can't even find lmerFrames(). I can see it being called in lmer, but if I just type in lmerFrames or fix(lmerFrames) I get nothing. The note from Doug Bates is that the function is hidden- is there a trick to getting at these hidden functions to edit them? Any thoughts or suggestions welcome. Cheers, -- Michael Rennie, Research Scientist Fisheries and Oceans Canada, Freshwater Institute Winnipeg, Manitoba, CANADA [[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] install-packages
hello, i am new and I want to know how to install a packare on R thank you said filahi [[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] install-packages
Try typing this into google search bar: [R] install packages The majority of the results on the first page will help you out. On Thu, Aug 1, 2013 at 8:43 PM, Said Filahi sa.fil...@gmail.com wrote: hello, i am new and I want to know how to install a packare on R thank you said filahi [[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. -- Michael Rennie, Research Scientist Fisheries and Oceans Canada, Freshwater Institute Winnipeg, Manitoba, CANADA [[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] Editing code in a function?
1. ?:: 2. ?getAnywhere 3. Please consult the R language definition manual -- or even An Introduction to R -- to learn about R programming. It **is** a programming language, you know! Cheers, Bert On Thu, Aug 1, 2013 at 8:54 PM, Mike Rennie mikerenni...@gmail.com wrote: Hi folks, I've not before had to edit code right in a function, but I think I need to. I am using lmer() and want to use a model that uses zero weights. I found this thread from 2009: https://stat.ethz.ch/pipermail/r-sig-mixed-models/2009q1/001995.html but I'm unsure of how I would actually go about editing the code in the package. Part of the problem is that I can't even find lmerFrames(). I can see it being called in lmer, but if I just type in lmerFrames or fix(lmerFrames) I get nothing. The note from Doug Bates is that the function is hidden- is there a trick to getting at these hidden functions to edit them? Any thoughts or suggestions welcome. Cheers, -- Michael Rennie, Research Scientist Fisheries and Oceans Canada, Freshwater Institute Winnipeg, Manitoba, CANADA [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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] X11 and printing/copying graphics from mac
Hello all, I frequently use R, but recently have switched to a mac. When creating a new graphic, I have used X11() for a new graphics window and have always (when I used my PC) have been able to copy or print from this graphic window. With my mac, it does not allow me to copy or print. Having multiple graphic windows is a must as well as being able to print or copy from them. Thanks ahead of time. Keith M. Keith Cox, Ph.D. Principal MKConsulting 17105 Glacier Hwy Juneau, AK 99801 U.S. 907.957.4606 [[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.