Re: [R] Suggestions for vectorizing/double loop
Well, your second post is rather confusing too, as is your not reproducible code. If I understand correctly, you just want to change names of files in a directory according to some rules, which you did not clerly specify. First I am not sure if R is the best tool for it. Nevertheless, you do not change a contents of any file, just change the name. I found this with simple answer questioning internet. http://stackoverflow.com/questions/10758965/how-do-i-rename-files-using-r Is this what you want? Here is another possibility https://www.r-bloggers.com/operating-on-files-with-r-copy-and-rename/ Anyway the concept I would use is. #read old names old_names <- list.files(old_path) #setting new names (you did not explain how do you want to do this) new_names <- some vector of new names If order of names is correct file.rename(old_names, new_names) othervise it would be needed correctly order both vectors before file.rename. The crucial information is how do you want set the new names vector. You shold specify it by reproducible way if you want more precise answer. Copying files is in this case best done by OS itself. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luanna > Dixson > Sent: Monday, January 23, 2017 6:39 PM > To: r-help@r-project.org > Subject: Re: [R] Suggestions for vectorizing/double loop > > Hi all, > > Thanks very much for your help! You are correct in thinking the list is the > same as before, actually, my question was more about how to do the next > steps, where I needed to match the filenames of the files in my directory > with old (i.e current) and new file name prefixes in my list. For each match I > then wanted to rename the original file using the corresponding new > filename prefix from the list. > > Sorry for being a bit confusing, I didn't post my first attempt to do this at > first > as my code just didn't work at all, but I have had another go using a matrix > instead and I think this does the job. > > old_path="./old/" > new_path="./new/" > > old_names <- list.files(old_path) > head(old_names) > > oldnames=c('1002', '1003') > newnames=c('1002_new', '1003_new') > mapping=cbind(oldnames,newnames) > head(mapping) > > for (i in old_names){ > temp <- unlist(strsplit(i, "[.]"))[1] > n <- which(is.element(mapping,temp)) > if(length(n)>0) { > #copy the file to the new folder > #re name it and the name is paste(mapping[n,2], '.xls', sep="") > print(paste(mapping[n,2], '.xls', sep="")) > newnames <- paste(mapping[n,2], '.xls', sep="") > file.copy(from = paste(old_path, i, sep=""), > to = paste(new_path, newnames)) > } > } > > > On 23 January 2017 at 13:28, Luanna Dixson >> wrote: > > > I need to rename a bunch of files, by searching for string matches in > > a list. Each list element containings a character with the old > > filename that I want to match to, and the new file name that I want to > rename by. > > > > For instance, here filename '1001.xls' should match to > > list[[1]]$oldname and I want to rename it to 'newa.xls' from > list[[1]]$newname. > > > > The actual new file names I have will feature a random alphanumeric > > number and the list will have a length of ~600. > > > > > > # files I want to rename > > > > files with old file name =c('1001.xls', '1002.xls') > > > > # list with old file names and new file names > > > > oldnames=c('1001', '1002', '1003') > > > > newnames=c('newa', 'newb', 'newc') > > > > df=data.frame(oldnames,newnames) > > > > list <- split(df, rownames(df)) > > > > > > # turn list elements in character > > > > for(i in 1:length(list)) list[[i]]$oldnames=as. > > character(list[[i]]$oldnames) > > > > for(i in 1:length(list)) list[[i]]$newnames=as. > > character(list[[i]]$newnames) > > > > > > I heard that it would be better to vectorize this than trying to do a > > double loop so if someone could give me a hint about how to do this I > > would be very grateful! > > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento
Re: [R] separate mixture of gamma and normal (with mixtools or ??)
Dear Bert, thank you very much for your suggestion. You are right, ill-conditioning was sometimes a problem for 3 components, but not in the two-component case. The modes are well separated, and the sample size is high. My main problem is (1) the shape of the distributions and (2) the diversity of available packages and approaches to this topic. In the mean time I made some progress in this matter by treating the data as a mixture of gamma distributions (package mixdist, see below), so what I want to know is the purely R technical question ;-) Has someone else has ever stumbled across something like this and can make a suggestion which package to use? Thanks, Thomas ## Approximate an Exponential+Gaussian mixture with ## a mixture of Gammas library("mixdist") set.seed(123) lambda <- c(0.25, 0.75) N <- 2000 x <- c(rexp(lambda[1]*N, 1), rnorm(lambda[2]*N, 20, 4)) xx <- mixgroup(x, breaks=0:40) pp <- mixparam(mu=c(1, 8), sigma=c(1, 3), pi=c(0.2, 0.5)) mix <- mix(xx, pp, dist="gamma", emsteps=10) summary(mix) p <- coef(mix) beta <- with(p, sigma^2/mu) alpha <- with(p, mu /beta) lambda <- p$pi plot(mix, xlim=c(0, 35)) x1 <- seq(0, 35, 0.1) lines(x1, lambda[1]*dgamma(x1, alpha[1], 1/beta[1]), col="orange", lwd=2) lines(x1, lambda[2]*dgamma(x1, alpha[2], 1/beta[2]), col="magenta", lwd=2) Am 24.01.2017 um 00:34 schrieb Bert Gunter: Fitting multicomponent mixtures distributions -- and 3 is already a lot of components -- is inherently ill-conditioned. You may need to reassess your strategy. You might wish to post on stackexchange instead to discuss such statistical issues. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Jan 23, 2017 at 2:32 PM, Thomas Petzoldtwrote: Dear friends, I am trying to separate bi- (and sometimes tri-) modal univariate mixtures of biological data, where the first component is left bounded (e.g. exponential or gamma) and the other(s) approximately Gaussian. After checking several packages, I'm not really clear what to do. Here is an example with "mixtools" that already works quite good, however, the left component is not Gaussian (and not symmetric). Any idea about a more adequate function or package for this problem? Thanks a lot! Thomas library(mixtools) set.seed(123) lambda <- c(0.25, 0.75) N <- 200 ## dist1 ~ gamma (or exponential as a special case) #dist1 <- rexp(lambda[1]*N, 1) dist1 <- rgamma(lambda[1]*N, 1, 1) ## dist2 ~ normal dist2 <- rnorm(lambda[2]*N, 12, 2) ## mixture x <- c(dist1, dist2) mix <- spEMsymloc(x, mu0=2, eps=1e-3, verbose=TRUE) plot(mix, xlim=c(0, 25)) summary(mix) -- Thomas Petzoldt TU Dresden, Institute of Hydrobiology http://www.tu-dresden.de/Members/thomas.petzoldt __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 -- To UNSUBSCRIBE and more, see 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] Extracting first number after * in a character vector
Elegant I don't know, but I think the appended does the trick. -- Mike > foo <- c(" 1 X[0,SMITH] * 0 0 1 ", + " 2 X[0,JOHNSON] * 0 0 1 ", + " 3 X[0,WILLIAMS] * 1 0 1 ", + " 4 X[0,JONES] * 0 0 1 ", + [TRUNCATED] > as.numeric(gsub("^[^*]+[*][^0-9]+([01]).*$", "\\1", foo)) [1] 0 0 1 0 0 0 0 0 0 > On Mon, Jan 23, 2017 at 1:27 PM, Jim Lemonwrote: > Hi Abhinaba, > I'm sure that someone will post a terrifyingly elegant regular > expression that does this, but: > > ardat<- > c([1] " 1 X[0,SMITH] * 0 0 1 ", > ... > numpoststar<-function(x) { > xsplit<-unlist(strsplit(x,"")) > starpos<-which(xsplit=="*") > # watch out for a missing asterisk, they cause an infinite loop > if(length(starpos)) { > digits<-c("0","1","2","3","4","5","6","7","8","9") > while(!any(digits %in% xsplit[starpos])) starpos<-starpos+1 > return(as.numeric(xsplit[starpos])) > } > return(NA) > } > > for(i in 1:length(ardat)) print(numpoststar(ardat[i])) > > The observant will wonder why I didn't use sapply. Because for some > reason it returned the original strings rather than the numbers. I > dunno. > > Jim > > On Mon, Jan 23, 2017 at 11:29 PM, Abhinaba Roy > wrote: >> Hi, >> >> How do I extract the first number after '*' in a vector? >> >> The vector is given below >> >>> dput(out[1:10]) >> c(" 1 X[0,SMITH] * 0 0 1 ", >> " 2 X[0,JOHNSON] * 0 0 1 ", >> " 3 X[0,WILLIAMS]", "* 1 0 >> 1 ", >> " 4 X[0,JONES] * 0 0 1 ", >> " 5 X[0,BROWN] * 0 0 1 ", >> " 6 X[0,DAVIS] * 0 0 1 ", >> " 7 X[0,MILLER] * 0 0 1 ", >> " 8 X[0,WILSON] * 0 0 1 ", >> " 9 X[0,MOORE] * 0 0 1 " >> ) >> >> I want a vector with the first number after the asterisk. >> >> So the output would give me, a vector (0,0,1,0,0,0,0,0,0,0) >> >> How can I do it in R? >> >> Best, >> Abhinaba >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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 -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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-es] Eliminación de filas en data frame según versión del fichero de origen
Hola. 2017-01-23 14:27 GMT-03:00 Rubén Coca: > El caso es que para un mismo id y date debo quedarme con la observación que > tenga la versión más alta (descartando el resto). > Si es válido apoyarse en SQL, yo usaría algo como: > library(sqldf) > sqldf("select rowid, id, max(value) from df group by id") rowid id max(value) 1 4 0001 19.57054 2 5 0002 14.70713 3 7 0003 19.34788 donde se reporta el número de la fila por si se quiere hacer otro join. Saludos. -- «Pídeles sus títulos a los que te persiguen, pregúntales cuándo nacieron, diles que te demuestren su existencia.» Rafael Cadenas [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R] Can R markdown do beamer palo alto theme?
Actually, I figured out that you can, but the syntax is different. You don't declare using \usedocument{beamer} \usetheme{PaloAlto}, instead, title and output are the correct syntax. Is there a full conversion list from Latex Beamer to Markdown Beamer? Thanks! On Mon, Jan 23, 2017 at 7:20 PM, C Wwrote: > Hi R list, > > Is it possible to use R markdown with beamer palo alto theme? Are they > compatible? > > I copy pasted my LaTex code over to R, I get the following error message: > > ! LaTeX Error: Can be used only in preamble. > > See the LaTeX manual or LaTeX Companion for explanation. > Type H for immediate help. > ... > > l.89 \end{frame} > > pandoc: Error producing PDF > Error: pandoc document conversion failed with error 43 > Execution halted > > Thanks for your help in advance! > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Can R markdown do beamer palo alto theme?
Hi R list, Is it possible to use R markdown with beamer palo alto theme? Are they compatible? I copy pasted my LaTex code over to R, I get the following error message: ! LaTeX Error: Can be used only in preamble. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.89 \end{frame} pandoc: Error producing PDF Error: pandoc document conversion failed with error 43 Execution halted Thanks for your help in advance! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] separate mixture of gamma and normal (with mixtools or ??)
Fitting multicomponent mixtures distributions -- and 3 is already a lot of components -- is inherently ill-conditioned. You may need to reassess your strategy. You might wish to post on stackexchange instead to discuss such statistical issues. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Jan 23, 2017 at 2:32 PM, Thomas Petzoldtwrote: > Dear friends, > > I am trying to separate bi- (and sometimes tri-) modal univariate mixtures > of biological data, where the first component is left bounded (e.g. > exponential or gamma) and the other(s) approximately Gaussian. > > After checking several packages, I'm not really clear what to do. Here is an > example with "mixtools" that already works quite good, however, the left > component is not Gaussian (and not symmetric). > > Any idea about a more adequate function or package for this problem? > > Thanks a lot! > > Thomas > > > > library(mixtools) > set.seed(123) > > lambda <- c(0.25, 0.75) > N <- 200 > > ## dist1 ~ gamma (or exponential as a special case) > #dist1 <- rexp(lambda[1]*N, 1) > dist1 <- rgamma(lambda[1]*N, 1, 1) > > ## dist2 ~ normal > dist2 <- rnorm(lambda[2]*N, 12, 2) > > ## mixture > x <- c(dist1, dist2) > > mix <- spEMsymloc(x, mu0=2, eps=1e-3, verbose=TRUE) > plot(mix, xlim=c(0, 25)) > summary(mix) > > > -- > Thomas Petzoldt > TU Dresden, Institute of Hydrobiology > http://www.tu-dresden.de/Members/thomas.petzoldt > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] separate mixture of gamma and normal (with mixtools or ??)
Dear friends, I am trying to separate bi- (and sometimes tri-) modal univariate mixtures of biological data, where the first component is left bounded (e.g. exponential or gamma) and the other(s) approximately Gaussian. After checking several packages, I'm not really clear what to do. Here is an example with "mixtools" that already works quite good, however, the left component is not Gaussian (and not symmetric). Any idea about a more adequate function or package for this problem? Thanks a lot! Thomas library(mixtools) set.seed(123) lambda <- c(0.25, 0.75) N <- 200 ## dist1 ~ gamma (or exponential as a special case) #dist1 <- rexp(lambda[1]*N, 1) dist1 <- rgamma(lambda[1]*N, 1, 1) ## dist2 ~ normal dist2 <- rnorm(lambda[2]*N, 12, 2) ## mixture x <- c(dist1, dist2) mix <- spEMsymloc(x, mu0=2, eps=1e-3, verbose=TRUE) plot(mix, xlim=c(0, 25)) summary(mix) -- Thomas Petzoldt TU Dresden, Institute of Hydrobiology http://www.tu-dresden.de/Members/thomas.petzoldt __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] removing dropouts from survival analysis
Sorry. You may get private replies, but this *is* way OT on this list. Try stats.stackexchange.com instead for statistical queries. Or, better yet, find local consulting help. Non-random dropouts are a difficult issue. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Jan 23, 2017 at 12:48 PM, Damjan Krstajicwrote: > Dear All. > > > Apologies for posting a question regarding survival analysis, and not R, to > the R-help list. In the past I received the best advices from the R community. > > > The random censorship model (the censoring times independent of the failure > times and vice versa) is one of the fundamental assumptions in the survival > analysis. In the medical studies we have random entry to study and study end > which is a censoring mechanism independent of the failure times. However, in > reality we may have dropout subjects, lost to follow-up, which are censored > by a different mechanism which may not be independent of the failure times. > The inclusion of dropout subjects in the survival analysis may break the > random censorship model and include bias in our estimates of survival with > KM. I have studied papers on this subject (e.g. double sampling, copula > approach for dependent censoring), but I have not found any research paper > which examines the removal of dropout subjects from the survival analysis. > > > I am alone in my research and would be grateful to hear thoughts on this > subject. Thank you in advance and apologies for using the R-help list for my > research question. > > > DK > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] [FORGED] Fitting arima Models with Exogenous Variables
This should have been sent to the R-help mailing list, not to me personally. I am not an expert on this sort of time series modelling and cannot thereby provide any useful advice. My reply to you was of a "generic" nature --- when making an enquiry, provide a reproducible example!!! I am cc-ing this email to the R-help list, since someone on that list *may* be able to answer your question. I have (re-) attached the data sets that you sent to me. cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 On 24/01/17 04:36, Paul Bernal wrote: Hello Rolf, Thank you for your kind reply. I am attaching two datasets, one with the historical data that I used to train the model, and the other one with the exogenous variables. The R code that I used is as follows: library(forecast) library(tseries) library(TSA) library(stats) library(stats4) TrainingDat<-read.csv("Training Data.csv") ExogVars<-read.csv("ExogenousVariables5.csv") #The file ExogVars contains 5 columns, one column for each regressor Model1<-auto.arima(TrainingDat[,5], xreg=ExogVars) #In Model1 I was able to incorporate xreg without any trouble #The problem comes when trying to incorporate newxreg Model2<-auto.arima(ExoVars[1:5]) Error in as.ts(x) : object 'ExoVars' not found Model2<-auto.arima(ExogVars[1:5]) Error in auto.arima(ExogVars[1:5]) : No suitable ARIMA model found Model2<-auto.arima(ExogVars[,1]) NewXReg<-forecast(Model2, h=12) Forec<-forecast(Model1, newxreg=NewXReg) Error in forecast.Arima(Model1, newxreg = NewXReg) : No regressors provided In addition: Warning message: In forecast.Arima(Model1, newxreg = NewXReg) : The non-existent newxreg arguments will be ignored. Forec<-forecast(Model1, newxreg=NewXReg$mean) Error in forecast.Arima(Model1, newxreg = NewXReg$mean) : No regressors provided In addition: Warning message: In forecast.Arima(Model1, newxreg = NewXReg$mean) : The non-existent newxreg arguments will be ignored. I would like to generate the forecasts for all 4 variables included in the Training set, along with all 5 regressors, but it seems like I can only chose one training variable at a time, and one regressor at a time. Please let me know if you can work this out, __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Extracting first number after * in a character vector
Hi Abhinaba, I'm sure that someone will post a terrifyingly elegant regular expression that does this, but: ardat<- c([1] " 1 X[0,SMITH] * 0 0 1 ", ... numpoststar<-function(x) { xsplit<-unlist(strsplit(x,"")) starpos<-which(xsplit=="*") # watch out for a missing asterisk, they cause an infinite loop if(length(starpos)) { digits<-c("0","1","2","3","4","5","6","7","8","9") while(!any(digits %in% xsplit[starpos])) starpos<-starpos+1 return(as.numeric(xsplit[starpos])) } return(NA) } for(i in 1:length(ardat)) print(numpoststar(ardat[i])) The observant will wonder why I didn't use sapply. Because for some reason it returned the original strings rather than the numbers. I dunno. Jim On Mon, Jan 23, 2017 at 11:29 PM, Abhinaba Roywrote: > Hi, > > How do I extract the first number after '*' in a vector? > > The vector is given below > >> dput(out[1:10]) > c(" 1 X[0,SMITH] * 0 0 1 ", > " 2 X[0,JOHNSON] * 0 0 1 ", > " 3 X[0,WILLIAMS]", "* 1 0 > 1 ", > " 4 X[0,JONES] * 0 0 1 ", > " 5 X[0,BROWN] * 0 0 1 ", > " 6 X[0,DAVIS] * 0 0 1 ", > " 7 X[0,MILLER] * 0 0 1 ", > " 8 X[0,WILSON] * 0 0 1 ", > " 9 X[0,MOORE] * 0 0 1 " > ) > > I want a vector with the first number after the asterisk. > > So the output would give me, a vector (0,0,1,0,0,0,0,0,0,0) > > How can I do it in R? > > Best, > Abhinaba > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Graphics: Device 2 (Active)
What is the result of running: getOption("device") ? It should be something like: "RStudioGD". It sounds like this has been changed to something else, if that is the case it is a matter of either changing it back, or figuring out where the change is being made and fixing that. On Mon, Jan 23, 2017 at 11:19 AM, Jackson Rodrigueswrote: > Hi, > > after updating R and RStudio I am no longer able to see my plots in the > plot pane. Instead a new window opens called: R Graphics: Device 2 (Active). > > I tried to use dev.off(), reinstalling, update again and etc but it does > not help. > > I've checked this discussion list but I could not find any solution. > > The following are some info about my R version > >> sessionInfo() > > R version 3.3.2 (2016-10-31) > > Platform: x86_64-w64-mingw32/x64 (64-bit) > > Running under: Windows >= 8 x64 (build 9200) > > locale: > > [1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 > > [3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C > > [5] LC_TIME=Portuguese_Brazil.1252 > > > attached base packages: > > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > > [1] RColorBrewer_1.1-2 labdsv_1.8-0 cluster_2.0.5 MASS_7.3-45 > > > [5] mgcv_1.8-15nlme_3.1-128 analogue_0.17-0vegan_2.4-1 > > > [9] lattice_0.20-34permute_0.9-4 > > loaded via a namespace (and not attached): > > [1] Matrix_1.2-7.1 parallel_3.3.2 tools_3.3.2 brglm_0.5-9 > > [5] grid_3.3.2 princurve_1.1-12 > > > $version > > [1] ‘0.99.441’ > > > Any help are very welcome. > > Thanks > > Jackson > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] removing dropouts from survival analysis
Dear All. Apologies for posting a question regarding survival analysis, and not R, to the R-help list. In the past I received the best advices from the R community. The random censorship model (the censoring times independent of the failure times and vice versa) is one of the fundamental assumptions in the survival analysis. In the medical studies we have random entry to study and study end which is a censoring mechanism independent of the failure times. However, in reality we may have dropout subjects, lost to follow-up, which are censored by a different mechanism which may not be independent of the failure times. The inclusion of dropout subjects in the survival analysis may break the random censorship model and include bias in our estimates of survival with KM. I have studied papers on this subject (e.g. double sampling, copula approach for dependent censoring), but I have not found any research paper which examines the removal of dropout subjects from the survival analysis. I am alone in my research and would be grateful to hear thoughts on this subject. Thank you in advance and apologies for using the R-help list for my research question. DK [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Replicate Christensen, Dib (2008) using BMR package
Only your pdf attachment made it through. You would need to follow the Posting Guide regarding file types to achieve successful transmission. I will say that open-ended debugging of your code does not fit the Posting Guide recommendations either... this is an R language mailing list, not a research assistance mailing list. It might fit in better at stats.stackexchange.com, but even they want a focused question rather than general assistance requests. -- Sent from my phone. Please excuse my brevity. On January 23, 2017 7:09:30 AM PST, Xue Liwrote: >Dear all, > > >I am trying to replicate Christensen, Dib (2008)'s estimation results >using "EDSGE" function in BMR package. Attached are my R code, the data >I collected and preprocessed, and the paper. > > >I set the priors following the literature (e.g., Smets and Wouters, >2007). However, when I ran the code, R reported error messages like: > > >Beginning MCMC run, Mon Jan 23 22:42:03 2017. >Error in chol.default(CovM) : > the leading minor of order 2 is not positive definite >In addition: Warning message: >In sqrt(parModeHessian) : NaNs produced > >I also found that the estimation is sensitive to initial values and/or >prior settings. I am struggling with debugging the code and hope >someone could help me out. Thanks! > > >Best, > >April __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Graphics: Device 2 (Active)
This sounds like an RStudio issue to me (just a not-so-informed guess, though). Did you reinstall that, too? Did you look/post on RStudio's site? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Jan 23, 2017 at 10:19 AM, Jackson Rodrigueswrote: > Hi, > > after updating R and RStudio I am no longer able to see my plots in the > plot pane. Instead a new window opens called: R Graphics: Device 2 (Active). > > I tried to use dev.off(), reinstalling, update again and etc but it does > not help. > > I've checked this discussion list but I could not find any solution. > > The following are some info about my R version > >> sessionInfo() > > R version 3.3.2 (2016-10-31) > > Platform: x86_64-w64-mingw32/x64 (64-bit) > > Running under: Windows >= 8 x64 (build 9200) > > locale: > > [1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 > > [3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C > > [5] LC_TIME=Portuguese_Brazil.1252 > > > attached base packages: > > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > > [1] RColorBrewer_1.1-2 labdsv_1.8-0 cluster_2.0.5 MASS_7.3-45 > > > [5] mgcv_1.8-15nlme_3.1-128 analogue_0.17-0vegan_2.4-1 > > > [9] lattice_0.20-34permute_0.9-4 > > loaded via a namespace (and not attached): > > [1] Matrix_1.2-7.1 parallel_3.3.2 tools_3.3.2 brglm_0.5-9 > > [5] grid_3.3.2 princurve_1.1-12 > > > $version > > [1] ‘0.99.441’ > > > Any help are very welcome. > > Thanks > > Jackson > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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-pkgs] Announcing caesar
Dear R users, I am happy to announce that the package caesar is now on CRAN ( https://cran.r-project.org/web/packages/caesar/index.html). The caesar package lets you encrypt and decrypt strings using the common Caesar cipher or a more secure pseudorandom number generator method. If you would like to know more please visit the repository on GitHub ( https://github.com/jacobkap/caesar). Best, Jacob [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Graphics: Device 2 (Active)
You need to be clear in your own mind about the distinction between RStudio and R before you can communicate clearly about it. Specifically, we don't know how to debug problems with RStudio here, and what you describe sounds completely normal for the R Gui program that ships with R. It sounds to me like you need to communicate with RStudio support, but providing a reproducible example here, run from R Gui rather than RStudio, could make the issue more clear. -- Sent from my phone. Please excuse my brevity. On January 23, 2017 10:19:02 AM PST, Jackson Rodrigueswrote: >Hi, > >after updating R and RStudio I am no longer able to see my plots in the >plot pane. Instead a new window opens called: R Graphics: Device 2 >(Active). > >I tried to use dev.off(), reinstalling, update again and etc but it >does >not help. > >I've checked this discussion list but I could not find any solution. > >The following are some info about my R version > >> sessionInfo() > >R version 3.3.2 (2016-10-31) > >Platform: x86_64-w64-mingw32/x64 (64-bit) > >Running under: Windows >= 8 x64 (build 9200) > >locale: > >[1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 > >[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C > >[5] LC_TIME=Portuguese_Brazil.1252 > > >attached base packages: > >[1] stats graphics grDevices utils datasets methods base > >other attached packages: > >[1] RColorBrewer_1.1-2 labdsv_1.8-0 cluster_2.0.5 >MASS_7.3-45 > > >[5] mgcv_1.8-15nlme_3.1-128 analogue_0.17-0 >vegan_2.4-1 > > > [9] lattice_0.20-34permute_0.9-4 > >loaded via a namespace (and not attached): > >[1] Matrix_1.2-7.1 parallel_3.3.2 tools_3.3.2 brglm_0.5-9 > >[5] grid_3.3.2 princurve_1.1-12 > > >$version > >[1] ‘0.99.441’ > > >Any help are very welcome. > >Thanks > >Jackson > > [[alternative HTML version deleted]] > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Graphics: Device 2 (Active)
Hello, That's a question for R Studio, ask here: https://support.rstudio.com Hope this helps, Rui Barradas Em 23-01-2017 18:19, Jackson Rodrigues escreveu: Hi, after updating R and RStudio I am no longer able to see my plots in the plot pane. Instead a new window opens called: R Graphics: Device 2 (Active). I tried to use dev.off(), reinstalling, update again and etc but it does not help. I've checked this discussion list but I could not find any solution. The following are some info about my R version sessionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) locale: [1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 [3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C [5] LC_TIME=Portuguese_Brazil.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RColorBrewer_1.1-2 labdsv_1.8-0 cluster_2.0.5 MASS_7.3-45 [5] mgcv_1.8-15nlme_3.1-128 analogue_0.17-0vegan_2.4-1 [9] lattice_0.20-34permute_0.9-4 loaded via a namespace (and not attached): [1] Matrix_1.2-7.1 parallel_3.3.2 tools_3.3.2 brglm_0.5-9 [5] grid_3.3.2 princurve_1.1-12 $version [1] ‘0.99.441’ Any help are very welcome. Thanks Jackson [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 -- To UNSUBSCRIBE and more, see 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 Graphics: Device 2 (Active)
Hi, after updating R and RStudio I am no longer able to see my plots in the plot pane. Instead a new window opens called: R Graphics: Device 2 (Active). I tried to use dev.off(), reinstalling, update again and etc but it does not help. I've checked this discussion list but I could not find any solution. The following are some info about my R version > sessionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) locale: [1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 [3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C [5] LC_TIME=Portuguese_Brazil.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RColorBrewer_1.1-2 labdsv_1.8-0 cluster_2.0.5 MASS_7.3-45 [5] mgcv_1.8-15nlme_3.1-128 analogue_0.17-0vegan_2.4-1 [9] lattice_0.20-34permute_0.9-4 loaded via a namespace (and not attached): [1] Matrix_1.2-7.1 parallel_3.3.2 tools_3.3.2 brglm_0.5-9 [5] grid_3.3.2 princurve_1.1-12 $version [1] ‘0.99.441’ Any help are very welcome. Thanks Jackson [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] spatial analysis using quickPCNM
I don't know if I will be able to help solve your problem, but failure to follow the recommendations in the Posting Guide was probably getting you off in the wrong foot when you posted on the other (more appropriate?) mailing list, as it is here. A) Code is garbled. Post using plain text format... this is a setting you have to choose in your email program. B) Code is not reproducible. We cannot run your code to get your error due to missing library statements and no data. The Posting Guide and Google have suggestions for how you can make your example reproducible. C) Assuming you are using the PCNM package, the documentation found by Google (which you can probably read using ?quickPCNM) says quickPCNM expects a matrix, but it looks like you are giving it a data frame. Read your introductory R training materials (e.g. the Introduction to R document that ships with R) to understand the distinction. But I have never used this function so this could be a red herring. Please go read the Posting Guide. -- Sent from my phone. Please excuse my brevity. On January 23, 2017 6:42:28 AM PST, Andrew Halfordwrote: >Hi Listers, > >I posted this message to the R-sig-ecology group last Friday but have >not >had a response hence my post here. > >I have been trying to run spatial analyses on a fish community dataset. > >My fish dataset has 114 species(variables) x 45 sites >My spatial dataset has the Lat and Long values for each site, converted >to >cartesian coordinates > > > >> fish <- read.table(file.choose())> latlong <- >read.table(file.choose()) > fish.h <- decostand (fish, "hellinger")> >fish.PCNM.quick <- quickPCNM(fish.h,latlong) > >Truncation level = 639.5348 >Time to compute PCNMs = 0.82 sec Error in if (temp2.test[1, 5] <= >alpha) { : argument is of length zeroTiming stopped at: 1.06 0.05 1.19 > >I do not understand the error message coming up and would appreciate >some advice. > >Andy __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Suggestions for vectorizing/double loop
Hi all, Thanks very much for your help! You are correct in thinking the list is the same as before, actually, my question was more about how to do the next steps, where I needed to match the filenames of the files in my directory with old (i.e current) and new file name prefixes in my list. For each match I then wanted to rename the original file using the corresponding new filename prefix from the list. Sorry for being a bit confusing, I didn't post my first attempt to do this at first as my code just didn't work at all, but I have had another go using a matrix instead and I think this does the job. old_path="./old/" new_path="./new/" old_names <- list.files(old_path) head(old_names) oldnames=c('1002', '1003') newnames=c('1002_new', '1003_new') mapping=cbind(oldnames,newnames) head(mapping) for (i in old_names){ temp <- unlist(strsplit(i, "[.]"))[1] n <- which(is.element(mapping,temp)) if(length(n)>0) { #copy the file to the new folder #re name it and the name is paste(mapping[n,2], '.xls', sep="") print(paste(mapping[n,2], '.xls', sep="")) newnames <- paste(mapping[n,2], '.xls', sep="") file.copy(from = paste(old_path, i, sep=""), to = paste(new_path, newnames)) } } On 23 January 2017 at 13:28, Luanna Dixsonwrote: > I need to rename a bunch of files, by searching for string matches in a > list. Each list element containings a character with the old filename that > I want to match to, and the new file name that I want to rename by. > > For instance, here filename '1001.xls' should match to list[[1]]$oldname > and I want to rename it to 'newa.xls' from list[[1]]$newname. > > The actual new file names I have will feature a random alphanumeric number > and the list will have a length of ~600. > > > # files I want to rename > > files with old file name =c('1001.xls', '1002.xls') > > # list with old file names and new file names > > oldnames=c('1001', '1002', '1003') > > newnames=c('newa', 'newb', 'newc') > > df=data.frame(oldnames,newnames) > > list <- split(df, rownames(df)) > > > # turn list elements in character > > for(i in 1:length(list)) list[[i]]$oldnames=as. > character(list[[i]]$oldnames) > > for(i in 1:length(list)) list[[i]]$newnames=as. > character(list[[i]]$newnames) > > > I heard that it would be better to vectorize this than trying to do a > double loop so if someone could give me a hint about how to do this I would > be very grateful! > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Granger-causality test using vars package
Dear T.Riedle, it is a 'combined' test, see ?causality for a formal description of the test statistic. If you would like results on an 'equation' by equation' approach, you could employ anova() on restricted and unrestricted lm-objects. Best wishes, Bernhard -Ursprüngliche Nachricht- Von: R-help [mailto:r-help-boun...@r-project.org] Im Auftrag von T.Riedle Gesendet: Montag, 23. Januar 2017 13:26 An: R-help@r-project.org Betreff: [EXT] Re: [R] Granger-causality test using vars package Thank you for your reply. The code follows the example in the vignette and I changed it only a little as shown below. library(vars) data(Canada) summary(Canada) stat.desc(Canada,basic=FALSE) plot(Canada, nc=2, xlab="") # Testing for unit roots using ADF adf1<-adf.test(Canada[,"prod"]) adf1 adf2<-adf.test(Canada[,"e"]) adf2 adf3<-adf.test(Canada[,"U"]) adf3 adf4<-adf.test(Canada[,"rw"]) adf4 # Use VAR to create a list of class varest Canada<-Canada[, c("prod", "e", "U", "rw")] p1ct<-VAR(Canada, p=1, type = "both") p1ct summary(p1ct, equation="e") plot(p1ct, names = "e") #Run Granger-causality test causality(p1ct) The Granger-causality test returns following output $Granger Granger causality H0: prod do not Granger-cause e U rw data: VAR object p1ct F-Test = 11.956, df1 = 3, df2 = 308, p-value = 1.998e-07 $Instant H0: No instantaneous causality between: prod and e U rw data: VAR object p1ct Chi-squared = 3.7351, df = 3, p-value = 0.2915 Warning message: In causality(p1ct) : Argument 'cause' has not been specified; using first variable in 'x$y' (prod) as cause variable. I am struggling with the result as it is not clear to me whether the variable prod Granger-causes e or U or rw. H0 is that prod does not Granger-cause e U rw. What does that mean? How can I find out if prod Granger-causes e, U and rw, respectively i.e. how can I determine that prod Granger-causes e, U and rw? Thanks for your support in advance. From: Pfaff, Bernhard Dr.Sent: 23 January 2017 09:12 To: T.Riedle; R-help@r-project.org Subject: AW: [R] Granger-causality test using vars package Dear T.Riedle, you cannot assign *all* variables as a cause at once. Incidentally, in your example, you missed a 'data(Canada)'. Having said this, you can loop over the variables names and extract the statistic/p-values. These are contained as named list elements 'statistic' and 'p.value' in the returned list object 'Granger' which is of informal class 'htest'. Best wishes, Bernhard -Ursprüngliche Nachricht- Von: R-help [mailto:r-help-boun...@r-project.org] Im Auftrag von T.Riedle Gesendet: Sonntag, 22. Januar 2017 14:11 An: R-help@r-project.org Betreff: [EXT] [R] Granger-causality test using vars package Dear R-users, I am trying to compute the test statistics for Granger-causality for a VAR(p) model using the "vars" package. I simply used the example proposed by the vars vignette and added the code for the Granger-causality. The code looks as follows library(vars) Canada<-Canada[, c("prod", "e", "U", "rw")] p1ct<-VAR(Canada, p=1, type = "both") causality(p1ct, cause = c("prod","e","U","rw")) Unfortunately I get the error Error in `[<-`(`*tmp*`, i, w[i], value = 1) : subscript out of bounds Does any body know what is wrong with the code? I would like to create a matrix containing the F-values and the corresponding significance. How can I do that? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. * Confidentiality Note: The information contained in this ...{{dropped:9}} __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Can mice() handle crr()? Fine-Gray model
Look at the finegray command within the survival package; the competing risks vignette has coverage of it. The command creates an expanded data set with case weights, such that coxph() on the new data set = the Fine Gray model for the original data. Anything that works with coxph is valid on the new data. Caveat -- I don't know mice() well at all: the dat1 data set below has multiple observations per subject, should the mice() command be cognizant of this? Terry Therneau library(survival) library(mice) test1 <- data.frame (time=c(4,3,1,1,2,2,3,5,2,4,5,1, 4,3,1,1,2,2,3,5,2,4,5,1), status=c(1,1,1,0,2,2,0,0,1,1,2,0, 1,1,1,0,2,2,0,0,1,1,2,0), x=c(0,2,1,1,NA,NA,0,1,1,2,0,1, 0,2,1,1,NA,NA,0,1,1,2,0,1), sex=c(0,0,0,NA,1,1,1,1,NA,1,0,0, 0,0,0,NA,1,1,1,1,NA,1,0,0))) # Endpoint 1, simple, then with mice fit0 <- copxh(Surv(time, status==1) ~ sex + x, test1) dat0 <- mice(test1, m=10) mfit0 <- with(dat0, coxph(Surv(time, status==1) ~ sex + x)) summary(pool(mfit0)) # Endpoint 1, Fine-Gray model fg1 <- finegray(Surv(time, factor(status)) ~ ., data=test1, etype=1) fit1 <- coxph(Surv(fgstart, fgstop, fgstatus) ~ sex + x, data=fg1, weight= fgwt) dat1 <- mice(fg1, m=10) mfit1 <- with(dat1, coxph(Surv(fgstart, fgstop, fgstatus) ~ sex + x, weight=fgwt)) On 01/23/2017 05:00 AM, r-help-requ...@r-project.org wrote: Here is an example: # example library(survival) library(mice) library(cmprsk) test1 <- as.data.frame(list(time=c(4,3,1,1,2,2,3,5,2,4,5,1, 4,3,1,1,2,2,3,5,2,4,5,1), status=c(1,1,1,0,2,2,0,0,1,1,2,0, 1,1,1,0,2,2,0,0,1,1,2,0), x=c(0,2,1,1,NA,NA,0,1,1,2,0,1, 0,2,1,1,NA,NA,0,1,1,2,0,1), sex=c(0,0,0,NA,1,1,1,1,NA,1,0,0, 0,0,0,NA,1,1,1,1,NA,1,0,0))) dat <- mice(test1,m=10) #Cox regression: cause 1 models.cox1 <- with(dat,coxph(Surv(time, status==1) ~ x +sex )) summary(pool(models.cox1)) #Cox regression: cause 1 or 2 models.cox <- with(dat,coxph(Surv(time, status==1 | status==2) ~ x +sex )) models.cox summary(pool(models.cox)) # crr() #Fine-Gray model models.FG<- with(dat,crr(ftime=time, fstatus=status, cov1=test1[,c( "x","sex")], failcode=1, cencode=0, variance=TRUE)) summary(pool(models.FG)) #Error in pool(models.FG) : Object has no vcov() method. models.FG -- Andreu Ferrero Gregori __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] spatial analysis using quickPCNM
Hi Listers, I posted this message to the R-sig-ecology group last Friday but have not had a response hence my post here. I have been trying to run spatial analyses on a fish community dataset. My fish dataset has 114 species(variables) x 45 sites My spatial dataset has the Lat and Long values for each site, converted to cartesian coordinates > fish <- read.table(file.choose())> latlong <- read.table(file.choose()) > > fish.h <- decostand (fish, "hellinger")> fish.PCNM.quick <- > quickPCNM(fish.h,latlong) Truncation level = 639.5348 Time to compute PCNMs = 0.82 sec Error in if (temp2.test[1, 5] <= alpha) { : argument is of length zeroTiming stopped at: 1.06 0.05 1.19 I do not understand the error message coming up and would appreciate some advice. Andy -- Andrew Halford Ph.D Research Scientist (Kimberley Marine Parks) Dept. Parks and Wildlife Western Australia Ph: +61 8 9219 9795 Mobile: +61 (0) 468 419 473 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Suggestions for vectorizing/double loop
Hi In your case if you want to rename abot 600 items and your doble loop works it is not worth to vectorize it. However if you want to repeat such task often and you expect much bigger number of files vectorizing can speed things up and make them cleaner. Although I must admit that I do not understand what your commands should actually do. AFAICU the list is the same before and after your "double" loop. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luanna > Dixson > Sent: Monday, January 23, 2017 1:28 PM > To: r-help@r-project.org > Subject: [R] Suggestions for vectorizing/double loop > > I need to rename a bunch of files, by searching for string matches in a list. > Each list element containings a character with the old filename that I want to > match to, and the new file name that I want to rename by. > > For instance, here filename '1001.xls' should match to list[[1]]$oldname and I > want to rename it to 'newa.xls' from list[[1]]$newname. > > The actual new file names I have will feature a random alphanumeric number > and the list will have a length of ~600. > > > # files I want to rename > > files with old file name =c('1001.xls', '1002.xls') > > # list with old file names and new file names > > oldnames=c('1001', '1002', '1003') > > newnames=c('newa', 'newb', 'newc') > > df=data.frame(oldnames,newnames) > > list <- split(df, rownames(df)) > > > # turn list elements in character > > for(i in 1:length(list)) list[[i]]$oldnames=as.character(list[[i]]$oldnames) > > for(i in 1:length(list)) list[[i]]$newnames=as.character(list[[i]]$newnames) > > > I heard that it would be better to vectorize this than trying to do a double > loop so if someone could give me a hint about how to do this I would be very > grateful! > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person
Re: [R] Suggestions for vectorizing/double loop
Dear Luanna It is not compulsory to avoid for loops but see below On 23/01/2017 12:28, Luanna Dixson wrote: I need to rename a bunch of files, by searching for string matches in a list. Each list element containings a character with the old filename that I want to match to, and the new file name that I want to rename by. For instance, here filename '1001.xls' should match to list[[1]]$oldname and I want to rename it to 'newa.xls' from list[[1]]$newname. The actual new file names I have will feature a random alphanumeric number and the list will have a length of ~600. # files I want to rename files with old file name =c('1001.xls', '1002.xls') # list with old file names and new file names oldnames=c('1001', '1002', '1003') newnames=c('newa', 'newb', 'newc') df=data.frame(oldnames,newnames) list <- split(df, rownames(df)) Both df and list are already in existience and you are overwriting them. It is best practice not to do that. # turn list elements in character for(i in 1:length(list)) list[[i]]$oldnames=as.character(list[[i]]$oldnames) Something like lapply(list, function(x) x$oldnames <- as.character(x$oldnames)) would probably work. You might want sapply instead of lapply for(i in 1:length(list)) list[[i]]$newnames=as.character(list[[i]]$newnames) I heard that it would be better to vectorize this than trying to do a double loop so if someone could give me a hint about how to do this I would be very grateful! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 http://www.dewey.myzen.co.uk/home.html __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Suggestions for vectorizing/double loop
Dear Luanna, Assuming that oldnames and newnames are character (and not factor), the just use stringsAsFactors = FALSE. That will save you from having to convert the factors back to character. data.frame(oldnames, newnames, stringsAsFactor = FALSE) Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2017-01-23 13:28 GMT+01:00 Luanna Dixson: > I need to rename a bunch of files, by searching for string matches in a > list. Each list element containings a character with the old filename that > I want to match to, and the new file name that I want to rename by. > > For instance, here filename '1001.xls' should match to list[[1]]$oldname > and I want to rename it to 'newa.xls' from list[[1]]$newname. > > The actual new file names I have will feature a random alphanumeric number > and the list will have a length of ~600. > > > # files I want to rename > > files with old file name =c('1001.xls', '1002.xls') > > # list with old file names and new file names > > oldnames=c('1001', '1002', '1003') > > newnames=c('newa', 'newb', 'newc') > > df=data.frame(oldnames,newnames) > > list <- split(df, rownames(df)) > > > # turn list elements in character > > for(i in 1:length(list)) list[[i]]$oldnames=as. > character(list[[i]]$oldnames) > > for(i in 1:length(list)) list[[i]]$newnames=as. > character(list[[i]]$newnames) > > > I heard that it would be better to vectorize this than trying to do a > double loop so if someone could give me a hint about how to do this I would > be very grateful! > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Chi-square test
Dear David and John, Thank you for your replies. Indeed I'm using ape and nlme packages. Here it is: > fit<-gls(fcl~mass+activity+agility,correlation=corBrownian(phy=tree),data=df,method="ML",weights=varFixed(~vf)) > Anova(fit) Analysis of Deviance Table (Type II tests) Response: fcl Df Chisq Pr(>Chisq) mass 1 0.1756 0.6752 activity 2 0.5549 0.7577 agility 4 3.2903 0.5105 Anyway, I have the help I was looking for. Thank you vey much. Best regards, Sérgio. - Mensagem original - > De: "Fox, John"> Para: "Sergio Ferreira Cardoso" > Cc: "R-help list" > Enviadas: Sábado, 21 De Janeiro de 2017 6:09:22 > Assunto: Re: [R] Chi-square test > Dear Sergio, > > You appear to have asked this question twice on r-help. > > Anova() has no specific method for “gls” models (I assume, though you don’t > say > so, that the model is fit by gls() in the nlme package), but the default > method > works and provides Wald chi-square tests for terms in the model. I don’t > understand the model formula x ~ 1 + 2 + 3 + x, however, and so I have no idea > what gls() would do with this model, other than report an error. Perhaps you > can show us the output — or, better yet, provide a reproducible example. > > As a general matter, for 1-df terms in an additive model, the 1-df chi-square > values reported by Anova() will simply be the squares of the corresponding > Wald > statistics (labelled “t” I believe) reported in the summary of the model. > Although the p-value is from the upper tail of the chi-square distribution, > the > test is inherently two-sided. > > Best, > John > > - > John Fox, Professor > McMaster University > Hamilton, Ontario, Canada > Web: http::/socserv.mcmaster.ca/jfox > >> On Jan 20, 2017, at 8:36 AM, Sergio Ferreira Cardoso >> wrote: >> >> Dear all, >> >> Anova() for .car package retrieves Chi-square statistics when I'm testing a >> model the significance of a multivariate .gls model >> gls(x~1+2+3+x,corBrownian(phy=tree), ...). >> Is this Chi-square a two-sided test? >> >> Thank you. >> >> Best, >> Sérgio. >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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 -- To UNSUBSCRIBE and more, see 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] Suggestions for vectorizing/double loop
I need to rename a bunch of files, by searching for string matches in a list. Each list element containings a character with the old filename that I want to match to, and the new file name that I want to rename by. For instance, here filename '1001.xls' should match to list[[1]]$oldname and I want to rename it to 'newa.xls' from list[[1]]$newname. The actual new file names I have will feature a random alphanumeric number and the list will have a length of ~600. # files I want to rename files with old file name =c('1001.xls', '1002.xls') # list with old file names and new file names oldnames=c('1001', '1002', '1003') newnames=c('newa', 'newb', 'newc') df=data.frame(oldnames,newnames) list <- split(df, rownames(df)) # turn list elements in character for(i in 1:length(list)) list[[i]]$oldnames=as.character(list[[i]]$oldnames) for(i in 1:length(list)) list[[i]]$newnames=as.character(list[[i]]$newnames) I heard that it would be better to vectorize this than trying to do a double loop so if someone could give me a hint about how to do this I would be very grateful! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Extracting first number after * in a character vector
On 23.01.2017 13:29, Abhinaba Roy wrote: Hi, How do I extract the first number after '*' in a vector? The vector is given below dput(out[1:10]) c(" 1 X[0,SMITH] * 0 0 1 ", " 2 X[0,JOHNSON] * 0 0 1 ", " 3 X[0,WILLIAMS]", "* 1 0 1 ", " 4 X[0,JONES] * 0 0 1 ", " 5 X[0,BROWN] * 0 0 1 ", " 6 X[0,DAVIS] * 0 0 1 ", " 7 X[0,MILLER] * 0 0 1 ", " 8 X[0,WILSON] * 0 0 1 ", " 9 X[0,MOORE] * 0 0 1 " ) I want a vector with the first number after the asterisk. So the output would give me, a vector (0,0,1,0,0,0,0,0,0,0) How can I do it in R? You know that your vector (called x below) contains an element without an asterisk? If that happened by accident, use gsub(".+\\* *([[:digit:]]+).*", "\\1", x) and if it could happen to have elements without an asterisk or number that follows, you can set these results to NA in a seperate step. Best, Uwe Ligges Best, Abhinaba [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 -- To UNSUBSCRIBE and more, see 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] Extracting first number after * in a character vector
Hi, How do I extract the first number after '*' in a vector? The vector is given below > dput(out[1:10]) c(" 1 X[0,SMITH] * 0 0 1 ", " 2 X[0,JOHNSON] * 0 0 1 ", " 3 X[0,WILLIAMS]", "* 1 0 1 ", " 4 X[0,JONES] * 0 0 1 ", " 5 X[0,BROWN] * 0 0 1 ", " 6 X[0,DAVIS] * 0 0 1 ", " 7 X[0,MILLER] * 0 0 1 ", " 8 X[0,WILSON] * 0 0 1 ", " 9 X[0,MOORE] * 0 0 1 " ) I want a vector with the first number after the asterisk. So the output would give me, a vector (0,0,1,0,0,0,0,0,0,0) How can I do it in R? Best, Abhinaba [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Granger-causality test using vars package
Thank you for your reply. The code follows the example in the vignette and I changed it only a little as shown below. library(vars) data(Canada) summary(Canada) stat.desc(Canada,basic=FALSE) plot(Canada, nc=2, xlab="") # Testing for unit roots using ADF adf1<-adf.test(Canada[,"prod"]) adf1 adf2<-adf.test(Canada[,"e"]) adf2 adf3<-adf.test(Canada[,"U"]) adf3 adf4<-adf.test(Canada[,"rw"]) adf4 # Use VAR to create a list of class varest Canada<-Canada[, c("prod", "e", "U", "rw")] p1ct<-VAR(Canada, p=1, type = "both") p1ct summary(p1ct, equation="e") plot(p1ct, names = "e") #Run Granger-causality test causality(p1ct) The Granger-causality test returns following output $Granger Granger causality H0: prod do not Granger-cause e U rw data: VAR object p1ct F-Test = 11.956, df1 = 3, df2 = 308, p-value = 1.998e-07 $Instant H0: No instantaneous causality between: prod and e U rw data: VAR object p1ct Chi-squared = 3.7351, df = 3, p-value = 0.2915 Warning message: In causality(p1ct) : Argument 'cause' has not been specified; using first variable in 'x$y' (prod) as cause variable. I am struggling with the result as it is not clear to me whether the variable prod Granger-causes e or U or rw. H0 is that prod does not Granger-cause e U rw. What does that mean? How can I find out if prod Granger-causes e, U and rw, respectively i.e. how can I determine that prod Granger-causes e, U and rw? Thanks for your support in advance. From: Pfaff, Bernhard Dr.Sent: 23 January 2017 09:12 To: T.Riedle; R-help@r-project.org Subject: AW: [R] Granger-causality test using vars package Dear T.Riedle, you cannot assign *all* variables as a cause at once. Incidentally, in your example, you missed a 'data(Canada)'. Having said this, you can loop over the variables names and extract the statistic/p-values. These are contained as named list elements 'statistic' and 'p.value' in the returned list object 'Granger' which is of informal class 'htest'. Best wishes, Bernhard -Ursprüngliche Nachricht- Von: R-help [mailto:r-help-boun...@r-project.org] Im Auftrag von T.Riedle Gesendet: Sonntag, 22. Januar 2017 14:11 An: R-help@r-project.org Betreff: [EXT] [R] Granger-causality test using vars package Dear R-users, I am trying to compute the test statistics for Granger-causality for a VAR(p) model using the "vars" package. I simply used the example proposed by the vars vignette and added the code for the Granger-causality. The code looks as follows library(vars) Canada<-Canada[, c("prod", "e", "U", "rw")] p1ct<-VAR(Canada, p=1, type = "both") causality(p1ct, cause = c("prod","e","U","rw")) Unfortunately I get the error Error in `[<-`(`*tmp*`, i, w[i], value = 1) : subscript out of bounds Does any body know what is wrong with the code? I would like to create a matrix containing the F-values and the corresponding significance. How can I do that? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. * Confidentiality Note: The information contained in this ...{{dropped:11}} __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Granger-causality test using vars package
Dear T.Riedle, you cannot assign *all* variables as a cause at once. Incidentally, in your example, you missed a 'data(Canada)'. Having said this, you can loop over the variables names and extract the statistic/p-values. These are contained as named list elements 'statistic' and 'p.value' in the returned list object 'Granger' which is of informal class 'htest'. Best wishes, Bernhard -Ursprüngliche Nachricht- Von: R-help [mailto:r-help-boun...@r-project.org] Im Auftrag von T.Riedle Gesendet: Sonntag, 22. Januar 2017 14:11 An: R-help@r-project.org Betreff: [EXT] [R] Granger-causality test using vars package Dear R-users, I am trying to compute the test statistics for Granger-causality for a VAR(p) model using the "vars" package. I simply used the example proposed by the vars vignette and added the code for the Granger-causality. The code looks as follows library(vars) Canada<-Canada[, c("prod", "e", "U", "rw")] p1ct<-VAR(Canada, p=1, type = "both") causality(p1ct, cause = c("prod","e","U","rw")) Unfortunately I get the error Error in `[<-`(`*tmp*`, i, w[i], value = 1) : subscript out of bounds Does any body know what is wrong with the code? I would like to create a matrix containing the F-values and the corresponding significance. How can I do that? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. * Confidentiality Note: The information contained in this ...{{dropped:10}} __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] runmed {stat}
> on Sun, 22 Jan 2017 10:26:24 -0600 writes: > Dear Dr Mächler, I am using runmed from R's stat > package. I understand that you are the author of this package. not of the package - but of function runmed(). I'm reply to R-help, so this answer maybe available to future web searches. > I am using the function with even length k=40 and the > function forces it to be odd as k=41. I am sure there must > be reason behind this overriding behavior. May I ask if > you could enlighten me on this? Thank you in advance. The help page - which one should really read (!) - says that k must be odd. Why? The median of an *odd* number of observations is "the middle". That's not the case with an even number, but a very desirable property, which is kept even when iterating running medians. (Further, mathematically there are as many odd numbers as integers, so odd numbers should be sufficient ;-) ;-)) Martin Maechler ETH Zurich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.