[R] spatstat installation
Hello , I am trying the spatstat package installation on R 3.3.0 the package is spatstat_1.63-3.tar.gz ,the OS is oracle enterprise linux 7 at the end I receive the error Error : .onAttach failed in attachNamespace() for 'spatstat', details: call: if (today - as.Date(rdate) > 365) { error: missing value where TRUE/FALSE needed ask to the community if someone encountered this problem. thanks and regards Mauro root@ctrdb10 supporting]# R CMD INSTALL spatstat_1.63-3.tar.gz * installing to library ‘/usr/lib64/R/library’ * installing *source* package ‘spatstat’ ... ** package ‘spatstat’ successfully unpacked and MD5 sums checked ** libs gcc -m64 -std=gnu99 -I/usr/lib64/R/../../include/R -DNDEBUG -I/systemr/port/Linux-X64/include/zlib -I/systemr/port/Linux-X64/include/xz -I/systemr/port/Linux-X64/include/bzip2 -I/systemr/port/Linux-X64/include -fpic -g -O2 -c Ediggatsti.c -o Ediggatsti.o gcc -m64 -std=gnu99 -I/usr/lib64/R/../../include/R -DNDEBUG -I/systemr/port/Linux-X64/include/zlib -I/systemr/port/Linux-X64/include/xz -I/systemr/port/Linux-X64/include/bzip2 -I/systemr/port/Linux-X64/include -fpic -g -O2 -c Ediggra.c -o Ediggra.o gcc -m64 -std=gnu99 -I/usr/lib64/R/../../include/R -DNDEBUG -I/systemr/port/Linux-X64/include/zlib -I/systemr/port/Linux-X64/include/xz -I/systemr/port/Linux-X64/include/bzip2 -I/systemr/port/Linux-X64/include -fpic -g -O2 -c Efiksel.c -o Efiksel.o gcc -m64 -std=gnu99 -I/usr/lib64/R/../../include/R -DNDEBUG -I/systemr/port/Linux-X64/include/zlib -I/systemr/port/Linux-X64/include/xz -I/systemr/port/Linux-X64/include/bzip2 -I/systemr/port/Linux-X64/include -fpic -g -O2 -c Egeyer.c -o Egeyer.o gcc -m64 -std=gnu99 -I/usr/lib64/R/../../include/R -DNDEBUG -I/systemr/port/Linux-X64/include/zlib -I/systemr/port/Linux-X64/include/xz -I/systemr/port/Linux-X64/include/bzip2 -I/systemr/port/Linux-X64/include -fpic -g -O2 -c Estrauss.c -o Estrauss.o gcc -m64 -std=gnu99 -I/usr/lib64/R/../../include/R -DNDEBUG -I/systemr/port/Linux-X64/include/zlib -I/systemr/port/Linux-X64/include/xz -I/systemr/port/Linux-X64/include/bzip2 -I/systemr/port/Linux-X64/include -fpic -g -O2 -c Kborder.c -o Kborder.o gcc -m64 -std=gnu99 -I/usr/lib64/R/../../include/R -DNDEBUG -I/systemr/port/Linux-X64/include/zlib -I/systemr/port/Linux-X64/include/xz -I/systemr/port/Linux-X64/include/bzip2 -I/systemr/port/Linux-X64/include -fpic -g -O2 -c Knone.c -o Knone.o gcc -m64 -std=gnu99 -I/usr/lib64/R/../../include/R -DNDEBUG -I/systemr/port/Linux-X64/include/zlib -I/systemr/port/Linux-X64/include/xz -I/systemr/port/Linux-X64/include/bzip2 -I/systemr/port/Linux-X64/include -fpic -g -O2 -c Krect.c -o Krect.o g++ -m64 -I/usr/lib64/R/../../include/R -DNDEBUG -I/systemr/port/Linux-X64/include/zlib -I/systemr/port/Linux-X64/include/xz -I/systemr/port/Linux-X64/include/bzip2 -I/systemr/port/Linux-X64/include -fpic -g -O2 -c Perfect.cc -o Perfect.o gcc -m64 -std=gnu99 -I/usr/lib64/R/../../include/R -DNDEBUG -I/systemr/port/Linux-X64/include/zlib -I/systemr/port/Linux-X64/include/xz -I/systemr/port/Linux-X64/include/bzip2 -I/systemr/port/Linux-X64/include -fpic -g -O2 -c areadiff.c -o areadiff.o vcov.mppm html vcov.ppmhtml vcov.slrm html venn.tess html verticeshtml volume html weighted.median html where.max html whichhalfplane html whist html will.expand html with.fv html with.hyperframe html with.msrhtml with.ssfhtml yardstick html zapsmall.im html zclustermodel html ** building package indices ** installing vignettes ** testing if installed package can be loaded Error : .onAttach failed in attachNamespace() for 'spatstat', details: call: if (today - as.Date(rdate) > 365) { error: missing value where TRUE/FALSE needed Error: loading failed Execution halted ERROR: loading failed * removing ‘/usr/lib64/R/library/spatstat’ [[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] Integrate inside function
Dear David and Micheal, thanks for your suggestion. Vectorize does what I need. David you suggest me that I didn't built the function in a manner that would vectorize. Could you please explain me what's wrong? Thanks, Mauro > > On Mar 15, 2012, at 6:08 AM, Mauro Rossi wrote: > >> Dear R users, >>first I take this opportunity to greet all the R community for >> your continuous efforts. >> I wrote a function to calculate the pdf and cdf of a custom >> distribution (mixed gamma model). >> The function is the following: >> >> pmixedgamma3 <- function(y, shape1, rate1, shape2, rate2, prev) >> { >> density.function<-function(x) >> { >> shape1=shape1 >> rate1=rate1 >> shape2=shape2 >> rate2=rate2 >> prev=prev >> >> fun<-prev*((rate1^shape1)/gamma(shape1)*(x^(shape1-1))*exp(-rate1*x)) >> + (1-prev)*((rate2^shape2)/gamma(shape2)*(x^(shape2-1))*exp(-rate2*x)) >> return(fun) >> } >> den<-density.function(y) >> p.mixedgamma<-integrate(f=density.function,lower=0,upper=y) >> return(list(density=den,cumdensity=p.mixedgamma$value)) >> } >> >> Why doesn't this calculate cumdensity (p.mixedgamma) in case x is a >> vector? > > You did not build the function in a manner that would vectorize, but > perhaps the convenience vuntion would help here: > > Vpmixedgamma3 <- Vectorize(pmixedgamma3) > > >> >> For instance try: >> pmixedgamma3(c(10,20),shape1=10,rate1=1,shape2=10,rate2=1,prev=0.5) > > > > Vpmixedgamma3(c(10,20),shape1=10,rate1=1,shape2=10,rate2=1,prev=0.5) >[,1] [,2] > density0.12511 0.002908153 > cumdensity 0.5420703 0.9950046 > >> >> As you can see cumdensity is calculated just for the first x value. >> >> -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel. +39 075 5014421 Fax +39 075 5014420 SkypeID: mauro.rossi76 [[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] Integrate inside function
Dear R users, first I take this opportunity to greet all the R community for your continuous efforts. I wrote a function to calculate the pdf and cdf of a custom distribution (mixed gamma model). The function is the following: pmixedgamma3 <- function(y, shape1, rate1, shape2, rate2, prev) { density.function<-function(x) { shape1=shape1 rate1=rate1 shape2=shape2 rate2=rate2 prev=prev fun<-prev*((rate1^shape1)/gamma(shape1)*(x^(shape1-1))*exp(-rate1*x)) + (1-prev)*((rate2^shape2)/gamma(shape2)*(x^(shape2-1))*exp(-rate2*x)) return(fun) } den<-density.function(y) p.mixedgamma<-integrate(f=density.function,lower=0,upper=y) return(list(density=den,cumdensity=p.mixedgamma$value)) } Why doesn't this calculate cumdensity (p.mixedgamma) in case x is a vector? For instance try: pmixedgamma3(c(10,20),shape1=10,rate1=1,shape2=10,rate2=1,prev=0.5) As you can see cumdensity is calculated just for the first x value. Thanks in advance Best Mauro -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel. +39 075 5014421 Fax +39 075 5014420 __ r-h...@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How can I do these simulations with R code
1) The Pareto P(alfa) distribution is defined by its density f(x|alfa) =alfa*X^(-alfa-1) over (1 to infinity). Show that it can be generated as the -1/alfa power of a uniforme variate. Plot the histogram and the density. 2) The Poisson distribution P(lambda) is connected to the exponential distribution through the Poisson process in that it can be simulated by generating exponential random variables until their sums exceeds 1. That is, if Xi~Exp(lambda) and if K is the first value for which summation(i=1 to k+1)Xi>1 então K~P(lambda). Compare this algorithm with rpois. 3) Se U e V are i.i.d U[0,1], the distribuiton of (U^1/alfa)/((U^1/alfa)+V(1/beta)), conditional on U^1/alfa+V^1/beta<=1, is the beta(alfa, beta) distribution. Compare this algorithm for both small and large values of alfa and beta. [[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] perspective plot
Hello, I`m tryint to plot some variable over x and y coordinate, but can`t figure out hot to do it ( I could do a simple scatterplot3d, but there I can`t change the viewing angle). My dataset looks something like this (dataframe): X Y Q95 21 2628711 1104437 0.7723994 22 2628721 1104437 0.5961789 23 2628731 1104437 1.2013182 24 2628741 1104437 1.3468632 25 2628751 1104437 1.1035517 26 2628761 1104437 1.0528809 Is there a way to plot Q95 over x and y? Something like persp(x,y,z) would be nice, but can`t figure out the right input format for this function. Thanks a lot, Mauro -- View this message in context: http://r.789695.n4.nabble.com/perspective-plot-tp3498754p3498754.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] Integrate na.rm in own defined functions
It`s probably an easy question, but couldn`t figure it out. I`ve defined a function like: rmse<-function (x){ dquared<-x^2 sum1<-sum(x^2) rmse<-sqrt((1/length(x))*sum1) rmse} My problem is, that I have NA Values in x and the above function returns NA. I`m looking for a way to use "na.rm=TRUE" like in for instance mean(x,na.rm=TRUE). Does anybody know how to do this? Thank you very much. Mauro -- View this message in context: http://r.789695.n4.nabble.com/Integrate-na-rm-in-own-defined-functions-tp3462492p3462492.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 on stepfunction
Dear members, I would like a help for extracting the values from a step function (stepfun). >From help(stepfun) we have the following example: Y0<-c(1.,2.,4.,3.) y0<-c(1.,2.,3.,4.) sfun<-stepfun(1:3,y0,f=0) plot(sfun) Now, suppose instead I was given the object (*sfun*, say) from which I wanted to extract the values generated by the function *stepfun*. More precisely, I want to know how to get the X and Y (generated by the function *sfun*) that are used in the graph (plot(sfun)). Thanks in advance for helping me. Ferreti [[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] Function rearrange (quantreg)
Dear all How can I obtain the data from the function "rearrange" in package quantreg More especifically, based on the example below (available in the help of the rearrange function), how can I access the data generated by "rearrange(zp)" ? data(engel) z <- rq(foodexp ~ income, tau = -1,data =engel) zp <- predict(z,newdata=list(income=quantile(engel$income,.03)),type="stepfun") plot(zp,do.points = FALSE, xlab = expression(tau), ylab = expression(Q ( tau )), main="Engel Food Expenditure Quantiles") plot(rearrange(zp),do.points = FALSE, add=TRUE,col.h="red",col.v="red") Thanks, Mauro __ 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] Neyman Scott rainfall pulse model
Dear R user, I'm looking to use a stochastic model for rainfall generation. This can be done with the Neyman-Scott Random Pulse (NSRP) model (see e.g. Cowpertwait, P. S. P., C. G. Kilsby, and P. E. O'Connell (2002), A space-time Neyman-Scott model of rainfall: Empirical analysis of extremes, Water Resour. Res., 38(8), 1131, doi:10.1029/2001WR000709). Does anyone have any R code or suggestions for it? Thank you in advance. -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel. +39 075 5014421 Fax +39 075 5014420 __ 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] distribution fitting
Dear R-help readers, I am writing to you in order to ask you a few questions about distribution fitting in R. I am trying to find out whether the set of event interarrival times that I am currently analyzing is distributed with a Gamma or General Pareto distribution. The event arrival granularity is in minutes and interarrival times are in seconds, so the values I have are 0, 60, 120, 180, and so on... Here is what I did. Since several values of the interarrival_times array are zero, to avoid numerical errors when calculating their logarithm, I set them to 1E-10: > # fix numerical values > for (i in 1:length(interarrival_times)) { + if (interarrival_times[i] == 0) + interarrival_times[i] = 0.01 + } Then I defined the negative log likelihood for the Gamma distribution: > nll_gamma_log <- function(lambda_log, alfa_log) { + n <- length(interarrival_times) + x <- interarrival_times + -n*exp(alfa_log)*lambda_log + n*log(gamma(exp(alfa_log))) - (exp(alfa_log)-1)*sum(log(x)) + exp(lambda_log)*sum(x) + } and passed it to the mle function: > est_gamma <- mle(minuslog = nll_gamma_log, start = list(lambda_log = 0, > alfa_log=0)) There were 50 or more warnings (use warnings() to see the first 50) of course I got many "value out of range" warnings: > warnings() Warning messages: 1: In log(gamma(exp(log_alfa))) ... : value out of range in 'gammafn' [...] 7: In gamma(exp(log_alfa)) ... : NaNs produced [...] 50: In log(gamma(exp(log_alfa))) ... : value out of range in 'gammafn' but that was expected, right? The real problems come out when I try to fit a General Pareto distribution. Using the same method, I calculated the negative log likelihood function for the General Pareto distribution: > # negative log-likelihood function for general pareto distribution > nll_gpd <- function(xi, log_sigma, mu) { # shape, scale, location + n <- length(interarrival_times) + x <- interarrival_times + cat("xi:",xi,"; log_sigma:",log_sigma,"; mu:",mu,"\n") + n*log_sigma + (xi+1)*sum(log(1+xi*(x-mu)/exp(log_sigma)))/xi + } and passed it to the mle function. However, this time I get some errors: > est_gpd <- mle(minuslog = nll_gpd, start = list(xi = 1, log_sigma = 1, mu = > 1)) xi: 1 ; log_sigma: 1 ; mu: 1 xi: 1.001 ; log_sigma: 1 ; mu: 1 xi: 0.999 ; log_sigma: 1 ; mu: 1 xi: 1 ; log_sigma: 1.001 ; mu: 1 xi: 1 ; log_sigma: 0.999 ; mu: 1 xi: 1 ; log_sigma: 1 ; mu: 1.001 xi: 1 ; log_sigma: 1 ; mu: 0.999 xi: 52007.84 ; log_sigma: 13414.95 ; mu: 4241.565 xi: 10402.37 ; log_sigma: 2683.789 ; mu: 849.113 xi: 18.08721 ; log_sigma: 3.862682 ; mu: 2.627865 xi: 18.08721 ; log_sigma: 3.860682 ; mu: 2.627865 Error in optim(start, f, method = method, hessian = TRUE, ...) : non-finite finite-difference value [2] In addition: There were 50 or more warnings (use warnings() to see the first 50) I also get many warnings: > warnings() Warning messages: 1: In base::log(x, base) ... : NaNs produced 2: In base::log(x, base) ... : NaNs produced [...] 50: In base::log(x, base) ... : NaNs produced I really don't know how to fix this problem. Do you have any suggestions? Thank you very much in advance. Best regards, Mauro Tortonesi -- Mauro Tortonesi, Ph.D. Research Assistant Distributed Systems Research Group Engineering Department University of Ferrara __ 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] distribution fitting
Dear R-help readers, I am writing to you in order to ask you a few questions about distribution fitting in R. I am trying to find out whether the set of event interarrival times that I am currently analyzing is distributed with a Gamma or General Pareto distribution. The event arrival granularity is in minutes and interarrival times are in seconds, so the values I have are 0, 60, 120, 180, and so on... Here is what I did. Since several values of the interarrival_times array are zero, to avoid numerical errors when calculating their logarithm, I set them to 1E-10: > # fix numerical values > for (i in 1:length(interarrival_times)) { + if (interarrival_times[i] == 0) + interarrival_times[i] = 0.01 + } Then I defined the negative log likelihood for the Gamma distribution: > nll_gamma_log <- function(lambda_log, alfa_log) { + n <- length(interarrival_times) + x <- interarrival_times + -n*exp(alfa_log)*lambda_log + n*log(gamma(exp(alfa_log))) - (exp(alfa_log)-1)*sum(log(x)) + exp(lambda_log)*sum(x) + } and passed it to the mle function: > est_gamma <- mle(minuslog = nll_gamma_log, start = list(lambda_log = 0, alfa_log=0)) There were 50 or more warnings (use warnings() to see the first 50) of course I got many "value out of range" warnings: > warnings() Warning messages: 1: In log(gamma(exp(log_alfa))) ... : value out of range in 'gammafn' [...] 7: In gamma(exp(log_alfa)) ... : NaNs produced [...] 50: In log(gamma(exp(log_alfa))) ... : value out of range in 'gammafn' but that was expected, right? The real problems come out when I try to fit a General Pareto distribution. Using the same method, I calculated the negative log likelihood function for the General Pareto distribution: > # negative log-likelihood function for general pareto distribution > nll_gpd <- function(xi, log_sigma, mu) { # shape, scale, location + n <- length(interarrival_times) + x <- interarrival_times + cat("xi:",xi,"; log_sigma:",log_sigma,"; mu:",mu,"\n") + n*log_sigma + (xi+1)*sum(log(1+xi*(x-mu)/exp(log_sigma)))/xi + } and passed it to the mle function. However, this time I get some errors: > est_gpd <- mle(minuslog = nll_gpd, start = list(xi = 1, log_sigma = 1, mu = 1)) xi: 1 ; log_sigma: 1 ; mu: 1 xi: 1.001 ; log_sigma: 1 ; mu: 1 xi: 0.999 ; log_sigma: 1 ; mu: 1 xi: 1 ; log_sigma: 1.001 ; mu: 1 xi: 1 ; log_sigma: 0.999 ; mu: 1 xi: 1 ; log_sigma: 1 ; mu: 1.001 xi: 1 ; log_sigma: 1 ; mu: 0.999 xi: 52007.84 ; log_sigma: 13414.95 ; mu: 4241.565 xi: 10402.37 ; log_sigma: 2683.789 ; mu: 849.113 xi: 18.08721 ; log_sigma: 3.862682 ; mu: 2.627865 xi: 18.08721 ; log_sigma: 3.860682 ; mu: 2.627865 Error in optim(start, f, method = method, hessian = TRUE, ...) : non-finite finite-difference value [2] In addition: There were 50 or more warnings (use warnings() to see the first 50) I also get many warnings: > warnings() Warning messages: 1: In base::log(x, base) ... : NaNs produced 2: In base::log(x, base) ... : NaNs produced [...] 50: In base::log(x, base) ... : NaNs produced I really don't know how to fix this problem. Do you have any suggestions? Thank you very much in advance. Best regards, Mauro Tortonesi -- Mauro Tortonesi, Ph.D. Research Assistant Distributed Systems Research Group Engineering Department University of Ferrara [[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] S.O.S.
Hi, My name is Mauro Belleggia, I m doing an ANOSIM (using "vegan" package) to test statistically whether there is a significant difference between 3 (1,2 and 3) groups of sampling units. My results were: Call: anosim(dis = distancias, grouping = Lt) Dissimilarity: bray ANOSIM statistic R: 0.1313 Significance: < 0.001 Based on 1000 permutations Empirical upper confidence limits of R: 90%95% 97.5%99% 0.0331 0.0464 0.0569 0.0693 Dissimilarity ranks between and within classes: 0%25%50%75% 100%N Between 2 950.75 1786.5 2641.5 3402.5 2220 1 13 958.50 1927.0 2660.5 3402.5 595 21 629.50 1318.0 2050.5 3258.0 435 3 10 356.00 840.0 1599.0 3367.0 153 I know that there where dissimilarities among grops but i can t interpret between which. 1 Vs 2?, 2 Vs. 3? Or 1 Vs. 3? I will be very very greatful with you. Looking forward to getting your prompt response. -- [EMAIL PROTECTED] [[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] Number -> Fraction
Alle giovedì 13 settembre 2007, Stefano Calza ha scritto: > > see "fractions" in library MASS > Yeah! > 1/3 [1] 0.333 > fractions(0.333) [1] 1/3 Great! Thanks! (grazie :) ) Mauro __ 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] Number -> Fraction
Hi everybody! I'm new to this list and also to the R program. I'd like to know if there is a function able to convert results into Fractional form like my scientific calculator have. For example: > 1/3 [1] 0.333 > function_that_return_a_fraction_from_numbers(0.333) [1] 1/3 Thanks Mauro -- Man, he is constantly growing and when he is bound by a set pattern of ideas or way of doing things, that's when he stops growing -- Bruce Lee __ 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.