[R] i want to unsubscribe
how do i unsubscribe [[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] i want to unsubscribe
See the footer to this (and every R-help) message... On Sun, Jun 26, 2011 at 2:17 AM, elisheva corn elishevac...@gmail.com wrote: how do i unsubscribe [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://staterythz.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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ 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] i want to unsubscribe
Check R-help Subscribers at https://stat.ethz.ch/mailman/listinfo/r-help HTH, Jorge On Sun, Jun 26, 2011 at 2:17 AM, elisheva corn wrote: how do i unsubscribe [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] i want to unsubscribe
Another option is http://lmgtfy.com/?q=R-help+unsubscribe Best, Ista On Sun, Jun 26, 2011 at 2:25 AM, Jorge Ivan Velez jorgeivanve...@gmail.com wrote: Check R-help Subscribers at https://stat.ethz.ch/mailman/listinfo/r-help HTH, Jorge On Sun, Jun 26, 2011 at 2:17 AM, elisheva corn wrote: how do i unsubscribe [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ 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] cluster() or frailty() in coxph
Dear List, Can anyone please explain the difference between cluster() and frailty() in a coxph? I am a bit puzzled about it. Would appreciate any useful reference or direction. cheers, Ehsan marginal.model - coxph(Surv(time, status) ~ rx + cluster(litter), rats) frailty.model - coxph(Surv(time, status) ~ rx + frailty(litter), rats) marginal.model Call: coxph(formula = Surv(time, status) ~ rx + cluster(litter), data = rats) coef exp(coef) se(coef) robust sez p rx 0.905 2.470.318 0.303 2.99 0.0028 Likelihood ratio test=7.98 on 1 df, p=0.00474 n= 150 frailty.model Call: coxph(formula = Surv(time, status) ~ rx + frailty(litter), data = rats) coef se(coef) se2 Chisq DF p rx 0.914 0.3230.319 8.01 1.0 0.0046 frailty(litter) 17.69 14.4 0.2400 Iterations: 6 outer, 24 Newton-Raphson Variance of random effect= 0.499 I-likelihood = -180.8 Degrees of freedom for terms= 1.0 14.4 Likelihood ratio test=37.6 on 15.4 df, p=0.00124 n= 150 __ 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] Why is looping in R inefficient, but in C not?
Hey, I just read another post about calling R from C. Someone on stackoverflow (DWin makes me suspect its David W.?) referenced this: http://www.math.univ-montp2.fr/~pudlo/R_files/call_R.pdf Which made me think: Why is a loop in R bad, but in C not? And where exactly does looping cost the most? I wrote a piece of code for my bachelor's thesis where I loop from 1 to 500, and estimate a boosted model in every iteration. The procedure takes 2-6 minutes. In this example the loop (instead of some kind of apply()) shouldn't cost too much time, right? I suspect it's way worse if someone would loop from 1 to 1 and perform only a small task (a mean(), for example) in each loop. Can someone confirm this? Regards, Alex __ 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] memory usage upon web-query using try function
Dear Community, my program below runs quite slow and I'm not sure whether the http-requests are to blame for this. Also, when running it gradually increases the memory usage enormously. After the program finishes, the memory is not freed. Can someone point out a problem in the code? Sorry my basic question, but I am totally new to R programming... Many thans for your time, Cyrus require(XML) row=0 URL=http://de.finance.yahoo.com/lookup?s=; df - matrix(ncol=6,nrow=10) for (Ticker in 10:20) { URLTicker=paste(URL,Ticker,sep=) query=try(readHTMLTable( URLTicker, which=2, header=T, colClasses = c(character,character,character, character,character,character), stringsAsFactors=F,)[1,],silent=T) if (class(query)==data.frame) { row=row+1 df[row,]=as.character(query) }} __ 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] Why is looping in R inefficient, but in C not?
For the same reason the Cray XMP was fast at numerical computations... a loop written in a low level language can be optimized to work faster than one written in a higher level language. The XMP optimized loops into hardware, but R just optimizes them in C code, exposed to the R programmer as vector operations. --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Alexander Engelhardt a...@chaotic-neutral.de wrote: Hey, I just read another post about calling R from C. Someone on stackoverflow (DWin makes me suspect its David W.?) referenced this: http://www.math.univ-montp2.fr/~pudlo/R_files/call_R.pdf Which made me think: Why is a loop in R bad, but in C not? And where exactly does looping cost the most? I wrote a piece of code for my bachelor's thesis where I loop from 1 to 500, and estimate a boosted model in every iteration. The procedure takes 2-6 minutes. In this example the loop (instead of some kind of apply()) shouldn't cost too much time, right? I suspect it's way worse if someone would loop from 1 to 1 and perform only a small task (a mean(), for example) in each loop. Can someone confirm this? Regards, Alex _ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cluster() or frailty() in coxph
Hi Ehsan, My understanding (hopefully someone will jump in if this is wrong) is that cluster() identifies a variable that is an indicator for correlated observations (rats in a litter, children in a classroom, etc.). The relative risk from treatment (rx) is for a random sample of rats. frailty() estimates the relative risk from treatment (rx) within litters. Also, by default, it (frailty) uses a gamma distribution and estimates the scale parameter unless specified by theta (or df). There is an entire chapter devoted to frailty models in Therneau Grambsch book on the cox model (the title is something like Survival Data Analysis). HTH, Josh On Sat, Jun 25, 2011 at 3:48 PM, Ehsan Karim wilds...@hotmail.com wrote: Dear List, Can anyone please explain the difference between cluster() and frailty() in a coxph? I am a bit puzzled about it. Would appreciate any useful reference or direction. cheers, Ehsan marginal.model - coxph(Surv(time, status) ~ rx + cluster(litter), rats) frailty.model - coxph(Surv(time, status) ~ rx + frailty(litter), rats) marginal.model Call: coxph(formula = Surv(time, status) ~ rx + cluster(litter), data = rats) coef exp(coef) se(coef) robust se z p rx 0.905 2.47 0.318 0.303 2.99 0.0028 Likelihood ratio test=7.98 on 1 df, p=0.00474 n= 150 frailty.model Call: coxph(formula = Surv(time, status) ~ rx + frailty(litter), data = rats) coef se(coef) se2 Chisq DF p rx 0.914 0.323 0.319 8.01 1.0 0.0046 frailty(litter) 17.69 14.4 0.2400 Iterations: 6 outer, 24 Newton-Raphson Variance of random effect= 0.499 I-likelihood = -180.8 Degrees of freedom for terms= 1.0 14.4 Likelihood ratio test=37.6 on 15.4 df, p=0.00124 n= 150 __ 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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why is looping in R inefficient, but in C not?
Probably the easiest way to think about it is that most of the extra time is the overhead of calling a function. So counting the number of calls to R functions is going to tell you how much overhead there is. (Remember that functions call other functions.) On 26/06/2011 08:21, Jeff Newmiller wrote: For the same reason the Cray XMP was fast at numerical computations... a loop written in a low level language can be optimized to work faster than one written in a higher level language. The XMP optimized loops into hardware, but R just optimizes them in C code, exposed to the R programmer as vector operations. --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Alexander Engelhardta...@chaotic-neutral.de wrote: Hey, I just read another post about calling R from C. Someone on stackoverflow (DWin makes me suspect its David W.?) referenced this: http://www.math.univ-montp2.fr/~pudlo/R_files/call_R.pdf Which made me think: Why is a loop in R bad, but in C not? And where exactly does looping cost the most? I wrote a piece of code for my bachelor's thesis where I loop from 1 to 500, and estimate a boosted model in every iteration. The procedure takes 2-6 minutes. In this example the loop (instead of some kind of apply()) shouldn't cost too much time, right? I suspect it's way worse if someone would loop from 1 to 1 and perform only a small task (a mean(), for example) in each loop. Can someone confirm this? Regards, Alex _ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Patrick Burns pbu...@pburns.seanet.com twitter: @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno') __ 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] Multivariate normal density in C for R
I use the following function which does not uses loops and seems to be pretty fast: dmvnorm - function (x, mu, Sigma, df, log = FALSE) { if (!is.matrix(x)) x - rbind(x) p - nrow(Sigma) ed - eigen(Sigma, symmetric = TRUE) ev - ed$values if (!all(ev = -1e-06 * abs(ev[1]))) stop('Sigma' is not positive definite) ss - if (!is.matrix(mu)) { x - rep(mu, each = nrow(x)) } else { x - mu } inv.Sigma - ed$vectors %*% (t(ed$vectors)/ev) quad - 0.5 * rowSums((ss %*% inv.Sigma) * ss) fact - -0.5 * (p * log(2 * pi) + sum(log(ev))) if (log) as.vector(fact - quad) else as.vector(exp(fact - quad)) } I hope it helps. Best, Dimitris On 6/25/2011 3:58 PM, zerfetzen wrote: Does anyone know of a package that uses C code to calculate a multivariate normal density? My goal is to find a faster way to calculate MVN densities and avoid R loops or apply functions, such as when X and mu are N x K matrices, as opposed to vectors, and in this particular case, speed really matters. I would like to be able to use .C or .Call to pass X, mu, Sigma, and N to a C program and have it return a vector of log densities to R. I'm new to putting C in R, but am sure I'll figure it out. Thanks for any suggestions. -- View this message in context: http://r.789695.n4.nabble.com/Multivariate-normal-density-in-C-for-R-tp3624602p3624602.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. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/ __ 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] columnwise nnzero for dgCMatrix
Hi R users, I want to know whether there is a fast method to compute the nonzeroes for each column of dgCMatrix. For summation or average I can use colSums or colMeans. To count the non-zeroes I write a function colCounts - function(Mat) { M1 - apply(Mat, MARGIN=2, FUN=nnzero) } But it seems this is quite slow because the apply function would transform a dgCMatrix to a matrix. So I come here to ask if there is anybody know some fast method. -- View this message in context: http://r.789695.n4.nabble.com/columnwise-nnzero-for-dgCMatrix-tp3625726p3625726.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with lmer
Hello Hugo, Thank you for your reply. This is a snap shot of what my data looks like: Presencebsence Habitatype Substratetype Width Banktype BankIncline Bankheight Waterdepth 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 1 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 I am trying to find out if any off the above factors so substrate type, width, bank type etc have an effect on the presence/absence of the species in question. But as stated below I keep getting an error message up and I have no idea how to fix it in order for me to fun the lmer. Sophie From: hugo.mildenber...@web.de To: r-help@r-project.org CC: england...@hotmail.com Subject: Re: [R] Help with lmer Date: Fri, 24 Jun 2011 17:19:00 +0200 Sophie, I'm myself quite new to linear mixed effect models, but PresenceAbsence sounds like a binary response variable. So wouldn't be m1-lmer(Presencebsence~Habitatype*Width+(1|Sitename),familiy=binomial) the first thing to try? There is also a special mailing list for linear - mixed -effect models: r-sig-mixed-mod...@r-project.org But with numeric problems like this one you really should provide a self contained example (i.e. with data), at least the output of str(yourdata), if ever possible. Kind regards Hugo On Friday 24 June 2011 13:11:23 Sophie Higgins wrote: Hey, I am having trouble with lmer. I am looking at the presence/absence of water shrews against habitat and other factors e.g so I used this: m1-lmer(Presencebsence~Habitatype*Width+(1|Sitename))summary(m1) But i keep getting this error up Error in mer_finalize(ans) : Downdated X'X is not positive definite, 16. summary(m1)Error in asMethod(object) : matrix is not symmetric [1,2] What does this mean and now can I fix it? Sophie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Overlapping areas under normal distributions
Hi everyone. My problem: I've 4 distributions: A, B, C and D: #A mA=16.6 sA=3.0 #B mB=18.9 sB=3.2 #C mC=20.3 sC=2.1 #D mD=24 sD=0.8 ###Graphiques ensembles plot(function(x) dnorm(x,mA,sA),0,40,col=orange,ylim=c(0,0.5)) plot(function(x) dnorm(x,mB,sB),0,40,add=T,col=green) plot(function(x) dnorm(x,mC,sC),0,40,add=T,col=blue) plot(function(x) dnorm(x,mD,sD),0,40,add=T,col=red) Now I've a fifth distribution X #X mX=23 sX=0.7 plot(function(x) dnorm(x,mX,sX),0,40,add=T,col=black) And I would like to know the area of the overlapping of the curve of X with the curves of A, B, C and D (in %). How can I do that? Thank you very much, Kindly regards, Scaramouch -- View this message in context: http://r.789695.n4.nabble.com/Overlapping-areas-under-normal-distributions-tp3625807p3625807.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] how to simulate Likert-type data using R
Dear R members Could someone tell me how to simulate Likert-type data using the rnorm function. Let's say, 200*15 random numbers in a variable that goes from 1 to 4 in steps of 1 (i.e., 1, 2, 3, 4) belonging to a normal distribution? random.data â matrix(rnorm(200 * 15), nrow = 200, ncol = 15) random.data The result cannot be reached. could one help me revise the syntax? Cheers cao -- View this message in context: http://r.789695.n4.nabble.com/how-to-simulate-Likert-type-data-using-R-tp3625664p3625664.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to simulate Likert-type data using R
?sample Date: Sun, 26 Jun 2011 02:26:10 -0700 From: wjca...@hotmail.com To: r-help@r-project.org Subject: [R] how to simulate Likert-type data using R Dear R members Could someone tell me how to simulate Likert-type data using the rnorm function. Let's say, 200*15 random numbers in a variable that goes from 1 to 4 in steps of 1 (i.e., 1, 2, 3, 4) belonging to a normal distribution? random.data matrix(rnorm(200 * 15), nrow = 200, ncol = 15) random.data The result cannot be reached. could one help me revise the syntax? Cheers cao -- View this message in context: http://r.789695.n4.nabble.com/how-to-simulate-Likert-type-data-using-R-tp3625664p3625664.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Accessing variables in a data frame
Hello My data.frame (dat) contains many variables named var.names and others named var.names_var.id For example var.name - c(gdp,inf,unp) var.id - c(w,i) x - paste(var.name, rep(var.id, each=length(var.name)), sep=_) How can I access variables in the dama.frame by names listed in x, for example to compute gdp_w - gdp_i inf_w - inf_i unp_w - unp_i or gdp - gdp_w inf - inf_w unp - unp_w without needing to code each difference separately? Thanks for your help! Serguei Kaniovski [[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] Multivariate normal density in C for R
Dimitris, Thanks for the great code. When the number of rows of X and mu are large, it is probably faster due to R's vectorization. Thanks again. -- View this message in context: http://r.789695.n4.nabble.com/Multivariate-normal-density-in-C-for-R-tp3624602p3625857.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need help on a R script part
Duncan, it isn't really that difficult to diagnose. A google search for ss11=sample(x1, n1, replace=TRUE) turned up this documented R-script ttp://www2.latech.edu/~dcahoy/TwoSampleEqualVarTest.R as a likely source for his fragmented and mangled post; other variable names match as well. But besides this, Lusk also demanded to be provided with a mathematical notation of the R code he posted. While he certainly could have followed Dexter O. Cahoy's reference to the underlying paper at ttp://www.sciencedirect.com/science/article/pii/S016794731000157X to get the theoretical background and a formal notation, I do imagine a tool which takes the R parse tree as input and produces a mathematical notation as a nicely formatted (LaTex) output, similar to what Mathematica does on the fly. At least I like this idea (h/t to Lusk) and think it should be doable for some less complex functions at first. Such a translator could greatly enhance function documentation, facilitate debugging and so on, but may also provide a base implemention for interfaces specific to other programs, thus giving R the ability to also export algorithms. Best regards Hugo Mildenberger On Saturday 25 June 2011 15:55:51 Duncan Murdoch wrote: On 11-06-25 11:33 AM, Mike Miller wrote: I'm curious about what would cause this (see below), if it isn't a joke. Is it possible that it didn't look ridiculous in the deleted HTML but the text looked bad? It's almost unreadable. I guess the HTML gets deleted because it is a waste of space, but I received a 14 MB message from this list the other day. I imagine you need to contact the poster, and find out what they sent. It's hard to diagnose after it's been mangled. Duncan Murdoch Mike On Fri, 24 Jun 2011, Lusk Aris wrote: Hi all, I need all your help on this. I have the next part of code:e1=x1-mean(x1)e2=x2-mean(x2)n1=length(x1)n2=length(x2N=(n1 + n2)nu2=sum( c( ( x1 -mean(x1) )^2 , ( x2-mean(x2) )^2 ) )/Nss=c(e1,e2) b3= N*sum(ss^4)/ (sum( ss^2)^2)what do lines 6-8 (mathematical notation)?Also the, what means part?for(j in 1:B){ ss11=sample(x1, n1, replace=TRUE) ss12=sample(x2, n2, replace=TRUE) }I would appreciate you could help on my inquiry, and I am awaiting for your soon answer Thx in advance, Lusk [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ 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] Access R functions from web
Thanks everyone! Now it became difficult to decide. I will give feedback soon. Caveman On Sat, Jun 25, 2011 at 9:59 PM, Tobias Verbeke tobias.verb...@openanalytics.eu wrote: Hi Caveman, On 06/25/2011 11:18 AM, Orvalho Augusto wrote: I need a way to send R objects and call R functions from web. Is there any project close or similar to that? I want to be able to send an HTTP rquest from an existing application with some data. And obtain a plot from R. This is one of the typical integration scenarios the R Service Bus is able to cope with. http://www.openanalytics.eu/r-**service-bushttp://www.openanalytics.eu/r-service-bus The REST interface is documented here http://rsb.doc.openanalytics.**eu/ http://rsb.doc.openanalytics.eu/ http://rsb.doc.openanalytics.**eu/wsdocs/index.htmlhttp://rsb.doc.openanalytics.eu/wsdocs/index.html Best, Tobias [[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] RJDBC and multiple classpaths
Corect me if this is not the right place to post this. I have a mdbdriver.jar (to access an MSAccess file) under Linux. I bought the license from http://www.csv-jdbc.com/ guys. The driver work fine when tested with DBVisualizer or another JDBC thing. The problem is that driver needs 3 other more jar files to work. Under R I have tried this and does not work: library(RJDBC) Loading required package: DBI Loading required package: rJava .jaddClassPath(/opt/DbVisualizer-7.1.1/jdbc/mdb/log4j.jar) .jaddClassPath(/opt/DbVisualizer-7.1.1/jdbc/mdb/commons_lang.jar) .jaddClassPath(/opt/DbVisualizer-7.1.1/jdbc/mdb/commons_logging.jar) drv - JDBC(jstels.jdbc.mdb.MDBDriver, /opt/DbVisualizer-7.1.1/jdbc/mdb/mdbdriver.jar) Error in .jfindClass(as.character(driverClass)[1]) : java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator As you see I have added the log4j with .jaddClassPath. What is wrong? Caveman [[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] integration function
Thank you all for the answering. Sorry I did not state the problem clearly. I want to take the integration with respect to mu, not x. For example, f1 should have been a function of x after integrating mu out of f(x, mu) which is the following: f(x, mu)=dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1). Thank you! Hannah f1 - function(x) {integrand - function (x, mu){ dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } f2 - function(x) {integrand - function (x, mu){ dnorm(x, mean=mu, sd=1)*mu^2*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } 2011/6/25 Peter Ehlers ehl...@ucalgary.ca On 2011-06-25 08:48, li li wrote: Hi all, Can anyone please take a look at the following two functions. The answer does not seem to be right. Thank you very much! f1- function(x) {integrand- function (x, mu){ dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } f2- function(x) {integrand- function (x, mu){ dnorm(x, mean=mu, sd=1)*mu^2*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } Your x and mu will get mightily confused. The argument x in f1 is in fact used as the argument mu in integrand() because, as the help page clearly indicates, additional arguments follow the lower/upper limits in integrate(). A cleaner version of what you're doing is the following: f1 - function(mu){ integrand - function (x, mu){ dnorm(x, mean=mu, sd=1) * dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf, mu)[[value]] } But then again, you could just evaluate dnorm(mu, 2, 1). So I suspect that you want something different. Ditto for f2. Peter Ehlers [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Ordering a matrix based on cluster no
Hi All I have a symmetric matrix of genes ( 100x100 matrix). I also have a matrix (100x2) of two columns where column 1 has the gene names and column 2 has the cluster it belongs to (they are sorted and grouped based on the cluster no). I would like to order the rows and columns of the 100x 100 matrix such that the first n genes correspond to cluster 1 and next n genes correspond to cluster 2 and so on. The order of genes is taken from the sorted matrix(100x2). Can someone tell me how to do this in R. I tried the grep() but I get a message saying that the length of pattern 1 so only first element will be compared. But i want to check for each gene in the 100x100 matrix for its cluster number and then group it. I also tried the order() but it did not help either. Thanks for the help! :) Aparna -- Aparna Sampath Master of Science (Bioinformatics) Nanyang Technological University Mob no : +65 91601854 [[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] Why is looping in R inefficient, but in C not?
On Jun 26, 2011, at 2:56 AM, Alexander Engelhardt wrote: Hey, I just read another post about calling R from C. Someone on stackoverflow (DWin makes me suspect its David W.?) referenced this: http://www.math.univ-montp2.fr/~pudlo/R_files/call_R.pdf Which made me think: Why is a loop in R bad, but in C not? I do not think the cited authority provides any support to that notion. It rather suggests that things which might benefit from using a compiler can be fairly easily passed to C. And where exactly does looping cost the most? I wrote a piece of code for my bachelor's thesis where I loop from 1 to 500, and estimate a boosted model in every iteration. The procedure takes 2-6 minutes. In this example the loop (instead of some kind of apply()) shouldn't cost too much time, right? I suspect it's way worse if someone would loop from 1 to 1 and perform only a small task (a mean(), for example) in each loop. Can someone confirm this? _You_ can investigate it. I cannot determine from your statements what expectations you have for an apply-vs-loop test, so I am not sure if this is confirming or disproving: z2 - z - vector(numeric, 1) x - matrix(1:100, 1,20) aloop1 - Sys.time(); z-apply(x,1, mean); difftime( Sys.time(), aloop1) aloop2 - Sys.time(); for (i in 1:1) {z2[i] - mean(x[i,]) } ; difftime( Sys.time(), aloop2) identical(z, z2) Probably not in line with your current understanding. I wonder whether the trivial advantage offered by apply (due to the single assignment I suspect) is in line with you understanding. Most of the efficiency in apply operations are at the level of clarity of the code and ease of use. The maximal efficiency gains are to use the proper vectorized operations that can be 50-100 times faster: aloop3 - Sys.time(); z3 - rowMeans(x) ; difftime( Sys.time(), aloop3) Time difference of 0.01409197 secs identical(z, z3) [1] TRUE Other efficincy strategies are to pre-allocate structures of known size and avoid using c, cbind or rbind operatiosn to accumulate results in a loop -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to extract data from a function printout - example provided
Hi there, Does anyone know how to extract data from a function that prints out two or more summaries? In the function below (the whole code is provided) we get 5 different tables of data. I would like to split each of these tables in a separate file (while the function itself shouldn't be changed), so that further analysis on each data set could be carried out. Your help is deeply appreciated. Have a good day. Ana Here is the code: library(MatchIt) f - treat ~ age + I(age^2) + educ + I(educ^2) + black + hispan + married + nodegree + re74 + I(re74^2) + re75 + I(re75^2) d - lalonde m - nearest matching - function(formula,data,method){ library(MatchIt) m.out - matchit(formula=f, data=d, method=m) print(m.out) print(summary(m.out)) } matching(f,d,m) [[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] how to extract data from a function printout - example provided
As a start, run matchit() for a test dataset and look at: names(m.out) and names(summary(m.out)) You can save those named components in the usual ways. Sarah On Sun, Jun 26, 2011 at 10:06 AM, Ana Kolar annako...@yahoo.com wrote: Hi there, Does anyone know how to extract data from a function that prints out two or more summaries? In the function below (the whole code is provided) we get 5 different tables of data. I would like to split each of these tables in a separate file (while the function itself shouldn't be changed), so that further analysis on each data set could be carried out. Your help is deeply appreciated. Have a good day. Ana Here is the code: library(MatchIt) f - treat ~ age + I(age^2) + educ + I(educ^2) + black + hispan + married + nodegree + re74 + I(re74^2) + re75 + I(re75^2) d - lalonde m - nearest matching - function(formula,data,method){ library(MatchIt) m.out - matchit(formula=f, data=d, method=m) print(m.out) print(summary(m.out)) } matching(f,d,m) [[alternative HTML version deleted]] -- Sarah Goslee http://www.functionaldiversity.org __ 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] String manipulation
Dear all, I have following kind of character vector: Vec - c(344426, dwjjsgcj, 123sgdc, aagha123, sdh343asgh, 123jhd51) Now I want to split each element of this vector according to numeric and string element. For example in the 1st element of that vector, there is no string element. Therefore I should get a vector of length 2 like c(, 344426) and so on. Can somebody point me how to achieve that in R? Is there any specific function for doing that? Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] String manipulation
On Sun, Jun 26, 2011 at 10:54 AM, Megh Dal megh700...@yahoo.com wrote: Dear all, I have following kind of character vector: Vec - c(344426, dwjjsgcj, 123sgdc, aagha123, sdh343asgh, 123jhd51) Now I want to split each element of this vector according to numeric and string element. For example in the 1st element of that vector, there is no string element. Therefore I should get a vector of length 2 like c(, 344426) and so on. Can somebody point me how to achieve that in R? Is there any specific function for doing that? Try this and see the gsubfn home page at http://gsubfn.googlecode.com for more info: library(gsubfn) strapply(Vec, \\d+|\\D+, c) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] integration function
On 2011-06-26 06:34, li li wrote: Thank you all for the answering. Sorry I did not state the problem clearly. I want to take the integration with respect to mu, not x. For example, f1 should have been a function of x after integrating mu out of f(x, mu) which is the following: f(x, mu)=dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1). So you probably want something like: h - function(mu, x) dnorm(x, mu, 1) * dnorm(mu, 2, 1) f1 - function(x) integrate(function(mu, x) h(mu, x), -Inf, Inf, x)$value In your original formulation (below), all you have to do is change {integrand - function (x, mu){ to {integrand - function (mu, x){ Peter Ehlers Thank you! Hannah f1- function(x) {integrand - function (x, mu){ dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } f2- function(x) {integrand - function (x, mu){ dnorm(x, mean=mu, sd=1)*mu^2*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } 2011/6/25 Peter Ehlers ehl...@ucalgary.ca mailto:ehl...@ucalgary.ca On 2011-06-25 08:48, li li wrote: Hi all, Can anyone please take a look at the following two functions. The answer does not seem to be right. Thank you very much! f1- function(x) {integrand- function (x, mu){ dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } f2- function(x) {integrand- function (x, mu){ dnorm(x, mean=mu, sd=1)*mu^2*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } Your x and mu will get mightily confused. The argument x in f1 is in fact used as the argument mu in integrand() because, as the help page clearly indicates, additional arguments follow the lower/upper limits in integrate(). A cleaner version of what you're doing is the following: f1 - function(mu){ integrand - function (x, mu){ dnorm(x, mean=mu, sd=1) * dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf, mu)[[value]] } But then again, you could just evaluate dnorm(mu, 2, 1). So I suspect that you want something different. Ditto for f2. Peter Ehlers [[alternative HTML version deleted]] R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/__listinfo/r-help https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/__posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to extract data from a function printout - example provided
summary(m.out) is a list with items with those names. Once you know the names, you can extract them in the same way as you'd extract any element from a list: by name, by position, etc. On Sun, Jun 26, 2011 at 10:48 AM, Ana Kolar annako...@yahoo.com wrote: Thank you Sarah! But names(summary(m.out)) gives only the names and no data. I actually need to extract data (to get a table of data out of that list so that it can be analysed further on). Any idea regarding that? Ana From: Sarah Goslee sarah.gos...@gmail.com To: Ana Kolar annako...@yahoo.com Cc: R r-help@r-project.org Sent: Sunday, 26 June 2011, 16:11 Subject: Re: [R] how to extract data from a function printout - example provided As a start, run matchit() for a test dataset and look at: names(m.out) and names(summary(m.out)) You can save those named components in the usual ways. Sarah On Sun, Jun 26, 2011 at 10:06 AM, Ana Kolar annako...@yahoo.com wrote: Hi there, Does anyone know how to extract data from a function that prints out two or more summaries? In the function below (the whole code is provided) we get 5 different tables of data. I would like to split each of these tables in a separate file (while the function itself shouldn't be changed), so that further analysis on each data set could be carried out. Your help is deeply appreciated. Have a good day. Ana Here is the code: library(MatchIt) f - treat ~ age + I(age^2) + educ + I(educ^2) + black + hispan + married + nodegree + re74 + I(re74^2) + re75 + I(re75^2) d - lalonde m - nearest matching - function(formula,data,method){ library(MatchIt) m.out - matchit(formula=f, data=d, method=m) print(m.out) print(summary(m.out)) } matching(f,d,m) [[alternative HTML version deleted]] -- Sarah Goslee http://www.functionaldiversity.org __ 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] String manipulation
On Jun 26, 2011, at 10:54 AM, Megh Dal wrote: Dear all, I have following kind of character vector: Vec - c(344426, dwjjsgcj, 123sgdc, aagha123, sdh343asgh, 123jhd51) Now I want to split each element of this vector according to numeric and string element. For example in the 1st element of that vector, there is no string element. Therefore I should get a vector of length 2 like c(, 344426) and so on. Can somebody point me how to achieve that in R? Is there any specific function for doing that? ?regex ?strsplit You don't do a very good job of describing your desired output, so this is two versions of what I am guessing that to be: cbind(lapply(strsplit(Vec, [^0-9]+), paste, collapse=), + lapply(strsplit(Vec, [0-9]+), paste, collapse=) ) [,1] [,2] [1,] 344426 [2,]dwjjsgcj [3,] 123sgdc [4,] 123aagha [5,] 343sdhasgh [6,] 12351 jhd data.frame(numbits=unlist(lapply(strsplit(Vec, [^0-9]+), paste, collapse=)), + alphabits=unlist(lapply(strsplit(Vec, [0-9]+), paste, collapse=)) ) numbits alphabits 1 344426 2 dwjjsgcj 3 123 sgdc 4 123 aagha 5 343 sdhasgh 6 12351 jhd -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] String manipulation
On Sun, Jun 26, 2011 at 11:00 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, Jun 26, 2011 at 10:54 AM, Megh Dal megh700...@yahoo.com wrote: Dear all, I have following kind of character vector: Vec - c(344426, dwjjsgcj, 123sgdc, aagha123, sdh343asgh, 123jhd51) Now I want to split each element of this vector according to numeric and string element. For example in the 1st element of that vector, there is no string element. Therefore I should get a vector of length 2 like c(, 344426) and so on. Can somebody point me how to achieve that in R? Is there any specific function for doing that? Try this and see the gsubfn home page at http://gsubfn.googlecode.com for more info: library(gsubfn) strapply(Vec, \\d+|\\D+, c) Also, if what you want is a leading string which begins Vec[[i]] followed by a numeric (and everything else is to be ignored) try this: strapply(Vec, ^(\\D*)(\\d*), c) If the first component must be string and you don't want to limit it to two try this (ignoring the warnings): L - strapply(Vec, \\d+|\\D+, c) lapply(L, function(x) if (length(x) == 0) x else if (is.na(as.numeric(x[1]))) x else c(, x)) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multivariate normal density in C for R
IIRC, package mvtnorm will allow an X matrix, but requires mu to be a vector, so although it's close, it won't do it all...but all suggestions are well received. Dimitrius, you don't happen to have the multivariate t form of that function, do you? -- View this message in context: http://r.789695.n4.nabble.com/Multivariate-normal-density-in-C-for-R-tp3624602p3626127.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Ordering a matrix based on cluster no
Combine the two matrices into one data.frame and order them Example done using data.frames rather than matrices but just use use data.frame(x,y) to convert to a data.frame bmat - data.frame(matrix(1:25,5)) smat - data.frame(aa= LETTERS[1:25], bb = rep(c(a,b,c, d, e),5)) df1 - data.frame(smat, bmat) orddata - df1[order(df1[,2],decreasing=TRUE),] I hope this helps. --- On Sun, 6/26/11, Aparna Sampath aparna.sampat...@gmail.com wrote: From: Aparna Sampath aparna.sampat...@gmail.com Subject: [R] Ordering a matrix based on cluster no To: r-help@r-project.org Received: Sunday, June 26, 2011, 9:42 AM Hi All I have a symmetric matrix of genes ( 100x100 matrix). I also have a matrix (100x2) of two columns where column 1 has the gene names and column 2 has the cluster it belongs to (they are sorted and grouped based on the cluster no). I would like to order the rows and columns of the 100x 100 matrix such that the first n genes correspond to cluster 1 and next n genes correspond to cluster 2 and so on. The order of genes is taken from the sorted matrix(100x2). Can someone tell me how to do this in R. I tried the grep() but I get a message saying that the length of pattern 1 so only first element will be compared. But i want to check for each gene in the 100x100 matrix for its cluster number and then group it. I also tried the order() but it did not help either. Thanks for the help! :) Aparna -- Aparna Sampath Master of Science (Bioinformatics) Nanyang Technological University Mob no : +65 91601854 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multivariate normal density in C for R
On 6/26/2011 5:53 PM, zerfetzen wrote: IIRC, package mvtnorm will allow an X matrix, but requires mu to be a vector, so although it's close, it won't do it all...but all suggestions are well received. Dimitrius, you don't happen to have the multivariate t form of that function, do you? Well, it's relatively easy to adjust it, e.g., dmvt - function (x, mu, Sigma, df, log = FALSE) { if (!is.matrix(x)) x - rbind(x) p - nrow(Sigma) ed - eigen(Sigma, symmetric = TRUE) ev - ed$values if (!all(ev = -1e-06 * abs(ev[1]))) stop('Sigma' is not positive definite) ss - if (!is.matrix(mu)) { x - rep(mu, each = nrow(x)) } else { x - mu } inv.Sigma - ed$vectors %*% (t(ed$vectors)/ev) quad - rowSums((ss %*% inv.Sigma) * ss)/df fact - lgamma((df + p)/2) - lgamma(df/2) - 0.5 * (p * (log(pi) + log(df)) + sum(log(ev))) if (log) fact - 0.5 * (df + p) * log(1 + quad) else exp(fact) * ((1 + quad)^(-(df + p)/2)) } Best, Dimitris -- View this message in context: http://r.789695.n4.nabble.com/Multivariate-normal-density-in-C-for-R-tp3624602p3626127.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. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/ __ 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] tl moments diagram
The package lmomco gives the L-moments ratio diagram for some distributions. It is important to have the TL-moments ration diagrams also. Does anyone know how to get this diagrams. thank you -- Osama Abdelaziz Hussien Department of Statistics Faculty of Commerce Alexandria University Egypt __ 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] integration function
Peter, Thank you very much! 2011/6/26 Peter Ehlers ehl...@ucalgary.ca On 2011-06-26 06:34, li li wrote: Thank you all for the answering. Sorry I did not state the problem clearly. I want to take the integration with respect to mu, not x. For example, f1 should have been a function of x after integrating mu out of f(x, mu) which is the following: f(x, mu)=dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1). So you probably want something like: h - function(mu, x) dnorm(x, mu, 1) * dnorm(mu, 2, 1) f1 - function(x) integrate(function(mu, x) h(mu, x), -Inf, Inf, x)$value In your original formulation (below), all you have to do is change {integrand - function (x, mu){ to {integrand - function (mu, x){ Peter Ehlers Thank you! Hannah f1- function(x) {integrand - function (x, mu){ dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } f2- function(x) {integrand - function (x, mu){ dnorm(x, mean=mu, sd=1)*mu^2*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } 2011/6/25 Peter Ehlers ehl...@ucalgary.ca mailto:ehl...@ucalgary.ca On 2011-06-25 08:48, li li wrote: Hi all, Can anyone please take a look at the following two functions. The answer does not seem to be right. Thank you very much! f1- function(x) {integrand- function (x, mu){ dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } f2- function(x) {integrand- function (x, mu){ dnorm(x, mean=mu, sd=1)*mu^2*dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf,x)$val } Your x and mu will get mightily confused. The argument x in f1 is in fact used as the argument mu in integrand() because, as the help page clearly indicates, additional arguments follow the lower/upper limits in integrate(). A cleaner version of what you're doing is the following: f1 - function(mu){ integrand - function (x, mu){ dnorm(x, mean=mu, sd=1) * dnorm(mu, mean=2, sd=1) } integrate(integrand, -Inf, Inf, mu)[[value]] } But then again, you could just evaluate dnorm(mu, 2, 1). So I suspect that you want something different. Ditto for f2. Peter Ehlers [[alternative HTML version deleted]] __**__ R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/_**_listinfo/r-helphttps://stat.ethz.ch/mailman/__listinfo/r-help https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/__**posting-guide.htmlhttp://www.R-project.org/__posting-guide.html http://www.R-project.org/**posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] columnwise nnzero for dgCMatrix
Hi: What about colSums(mymat != 0) ? # Example: x - matrix(sample(c(-1, 0, 1, 2), 100, replace = TRUE, prob = c(0.1, 0.8, 0.07, 0.03)), nrow = 25) which(x != 0) # 17 nonzero elements in this matrix [1] 9 17 27 32 36 41 44 45 49 50 62 67 68 72 76 78 82 colSums(x != 0) [1] 2 8 4 3 Dennis On Sun, Jun 26, 2011 at 3:15 AM, C6H5NO2 c6h5...@gmail.com wrote: Hi R users, I want to know whether there is a fast method to compute the nonzeroes for each column of dgCMatrix. For summation or average I can use colSums or colMeans. To count the non-zeroes I write a function colCounts - function(Mat) { M1 - apply(Mat, MARGIN=2, FUN=nnzero) } But it seems this is quite slow because the apply function would transform a dgCMatrix to a matrix. So I come here to ask if there is anybody know some fast method. -- View this message in context: http://r.789695.n4.nabble.com/columnwise-nnzero-for-dgCMatrix-tp3625726p3625726.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Only one strip with italic font.
Hi R users: How can I obtain an italic font only for one of the two strips in a xyplot? library(lattice) t-rep(seq(0,10,5),4) logCFU-c(2,2.5,3,4,4.5,1.5,2,2.5,3,3.4,2,2.5) microorg-factor(rep(c(E. coli,L. monocytogenes),each=6)) tratam-factor(rep(c(t1,t2),6)) xyplot(logCFU~t|microorg+tratam,type=p, strip=strip.custom(par.strip.text=list(fontface=c(italic,bold Thank you for your help. Kenneth __ 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] sampling from the multivariate truncated normal
I am trying generate a sample for a truncated multivariate normal distribution via the rtmvnorm function in the {tmvtnorm} package. Why does the following produce NaNs? rtmvnorm(1, mean = rep(0, 2), matrix(c(0.06906084, -0.07463565, -0.07463565, 0.08078086),2),c(-0.4316738, 0.8283240), c(Inf,Inf), algorithm=gibbsR, burn.in.samples=100) Thanks -- View this message in context: http://r.789695.n4.nabble.com/sampling-from-the-multivariate-truncated-normal-tp3626438p3626438.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with lmer
Sophie, sorry for any possibly duplicate email, my email client currently does not work correctly. I understand this snapshot as being a subset of your data only. But I do miss the factor Sitename, which appears in your lmer model as a random factor. Also, by looking at the subset, Presencebsence appears be a binary response variable. Does your response imply that you tried to call (m1-lmer(Presencebsence~Habitatype*Width+(1|Sitename),family=binomial)) and got the same error? (Note: I previously mispelled family) I also observe that many factors in your data appear to be closely correlated, e.g. Habitatype and Width, at least in the subset you passed along. I suspect this correlation to be the reason for the lmer error. Hence either use Width or Habitatype. Finally I'd propose you to put all your data into a dataframe, e.g. mydata-NULL mydata$PresenceAbsence - as.factor(Presencebsence) mydata$Habitattype - as.factor(Habitatype) mydata$Substratetype - as.factor(Substratetype) mydata$Width - Width mydata$Banktype- as.factor(Banktype) mydata$BankIncline - BankIncline mydata$Bankheight - as.factor(Bankheight) mydata$Waterdepth- as.factor(Waterdepth) mydata$Sitename- as.factor(Sitename) and then pass the dataframe to lmer by using data=mydata; mainly because passing a bunch of variables directly from the environment hightens the risk of inadvertently using stale copies, but also because str(mydata) would then produce a well arranged summary of all your variables. Kind regards Hugo On Sunday 26 June 2011 11:26:45 Sophie Higgins wrote: Hello Hugo, Thank you for your reply. This is a snap shot of what my data looks like: Presencebsence Habitatype Substratetype Width Banktype BankIncline Bankheight Waterdepth 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 1 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 I am trying to find out if any off the above factors so substrate type, width, bank type etc have an effect on the presence/absence of the species in question. But as stated below I keep getting an error message up and I have no idea how to fix it in order for me to fun the lmer. Sophie From: hugo.mildenber...@web.de To: r-help@r-project.org CC: england...@hotmail.com Subject: Re: [R] Help with lmer Date: Fri, 24 Jun 2011 17:19:00 +0200 Sophie, I'm myself quite new to linear mixed effect models, but PresenceAbsence sounds like a binary response variable. So wouldn't be m1-lmer(Presencebsence~Habitatype*Width+(1|Sitename),familiy=binomial) the first thing to try? There is also a special mailing list for linear - mixed -effect models: r-sig-mixed-mod...@r-project.org But with numeric problems like this one you really should provide a self contained example (i.e. with data), at least the output of str(yourdata), if ever possible. Kind regards Hugo On Friday 24 June 2011 13:11:23 Sophie Higgins wrote: Hey, I am having trouble with lmer. I am looking at the presence/absence of water shrews against habitat and other factors e.g so I used this: m1-lmer(Presencebsence~Habitatype*Width+(1|Sitename))summary(m1) But i keep getting this error up Error in mer_finalize(ans) : Downdated X'X is not positive definite, 16. summary(m1)Error in asMethod(object) : matrix is not symmetric [1,2] What does this mean and now can I fix it? Sophie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] download R Package for HP-UX ia64 server
Hi, I am new to R. Is there a R package for HP-UX Itanium 64 bits server available? Thanks very much for your help! Hong Hong Zhou, MS, MIS Senior Systems Analyst Center for Outcomes Research The Children's Hospital of Philadelphia 3535 Market St. Suite 1029 Philadelphia, PA 10104 Tel: (215) 590 5444 Fax: (215) 590 2378 Email: z...@email.chop.edu [[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] [R-sig-ME] Help with lmer
I´m not an expert either, but from my own experience with those annoying messages, I can suggest you some precautions you should take: - First of all, make sure, in your .txt file, that you are using dots for separating decimals, NOT commas. - Before writing your model, test each of the variables you are using (just type the name) and check that the software has not interpreted any covariate as a factor or viceversa. Hope that helps a bit. Good luck. De: Sophie Higgins england...@hotmail.com Para: hugo.mildenber...@web.de; r-help@r-project.org; r-sig-mixed-mod...@r-project.org Enviado: dom,26 junio, 2011 13:26 Asunto: Re: [R-sig-ME] [R] Help with lmer Hello Hugo, Thank you for your reply. This is a snap shot of what my data looks like: Presencebsence Habitatype Substratetype Width Banktype BankIncline Bankheight Waterdepth 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 1 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Lake Rocksgravel 600 Earth 0.45 less1 greater2 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 0 Stream Rocksgravel 1 Rocks 0.45 less1 025to05 I am trying to find out if any off the above factors so substrate type, width, bank type etc have an effect on the presence/absence of the species in question. But as stated below I keep getting an error message up and I have no idea how to fix it in order for me to fun the lmer. Sophie From: hugo.mildenber...@web.de To: r-help@r-project.org CC: england...@hotmail.com Subject: Re: [R] Help with lmer Date: Fri, 24 Jun 2011 17:19:00 +0200 Sophie, I'm myself quite new to linear mixed effect models, but PresenceAbsence sounds like a binary response variable. So wouldn't be m1-lmer(Presencebsence~Habitatype*Width+(1|Sitename),familiy=binomial) the first thing to try? There is also a special mailing list for linear - mixed -effect models: r-sig-mixed-mod...@r-project.org But with numeric problems like this one you really should provide a self contained example (i.e. with data), at least the output of str(yourdata), if ever possible. Kind regards Hugo On Friday 24 June 2011 13:11:23 Sophie Higgins wrote: Hey, I am having trouble with lmer. I am looking at the presence/absence of water shrews against habitat and other factors e.g so I used this: m1-lmer(Presencebsence~Habitatype*Width+(1|Sitename))summary(m1) But i keep getting this error up Error in mer_finalize(ans) : Downdated X'X is not positive definite, 16. summary(m1)Error in asMethod(object) : matrix is not symmetric [1,2] What does this mean and now can I fix it? Sophie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ___ r-sig-mixed-mod...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models [[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] What does class call mean? How do I make class formula into a call?
On Jun 26, 2011, at 00:10 , David Winsemius wrote: On Jun 25, 2011, at 4:33 PM, peter dalgaard wrote: I.e., an unevaluated formulae expression (as in quote(y~x)) is class call, as is an unclassed formula object. So it is pretty easy to have objects of class formula very similar to objects of class call. Not the first time I have stumbled on such matters. Chamber's SfDA would be one obvious place to study. Do yu have any others that pop to mind? The last example suggests that mode and class can each be call so that 'call' is somehow more primitive than function or formula. Class and mode can also both be function or numeric, but formula is not a mode. Historically, in S v3, all objects had a mode, but only some had a class, obtained by explicitly adding a class attribute. In S v4, the convention that all objects have a class was introduced, and in many cases an object's mode was promoted to become its class (but matrices became of class matrix). You can learn a lot by simple experimentation. E.g., it may be useful to know that call objects are isomorphic to lists and try things like u - quote(1+3*4) u[[1]] u[[2]] u[[3]] u[[3]][[1]] etc. Beware of false friends: things that look alike but are different, e.g. the call quote(y~x) and the formula that results from evaluating it. And by way of directly addressing the OP's questions, it sounds as though applying unclass() to the formula objects might be attempted? Or evaluating the call, or using as.formula() on it. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] changing graphs in qqplot2
This is what I have now so far. p=ggplot(data = test, aes(x = YEAR, y = TOTAL, colour = TREATMENT)) + geom_point() + geom_smooth(method = lm, se=FALSE) + facet_wrap(~COUNTRY) p +scale_x_continuous(limits=c(1,4)) http://r.789695.n4.nabble.com/file/n3626510/graph.gif I would also like to: 1.) change the headline for the faced wraps ‘high’ and ‘low’. Is there any other way of doing that other than changing the names in the dataset? 2.) show the slope and intercept next to the treatments labels on the right side. The geom_text only works inside the graph. I know I can change the names of the treatments in the data set to include the intercept and slope, but that seems like a detour for what I want to achieve. 3.) avoid the decimals on the x-axis. I would prefer the ticks to be (1,2,3,4). How is that done? 4.) change the lines. The look of the graph is exactly what I am after (except those minor changes mentioned above). However, the slopes and intercepts are not the same as what I got when I completed an ancova model. coef(lm(formula = TOTAL~ TREATMENT + YEAR + COUNTRY + TREATMENT:YEAR, data= test)) r gives the values for the different intercepts and slopes... a. I’ve tried adding an abline that specifies slope and intercept. But then I would have to specify which of the facet wraps that the line belongs to, as it turns up in both grids. Is that possible in qqplot2? p=ggplot(data = test, aes(x = YEAR, y = TOTAL, colour = TREATMENT)) + geom_point() + facet_wrap(~NITROGEN) #this is the treatment A, but should only be displayed in the right graph (low). p + geom_abline(intercept = 81.476,slope=47.2667, colour = red, size = 1) http://r.789695.n4.nabble.com/file/n3626510/graph2.gif b. Another option I’ve tried is to specify the model in the stat_smooth and geom_smooth commandsm=, but in both cases I get an error message. p + stat_smooth(method = lm, formula = TOTAL ~ TREATMENT + YEAR + COUNTRY + TREATMENT:YEAR)+ + geom_point() Error in model.frame.default(formula = formula, data = data, weights = weight, : variable lengths differ (found for 'COUNTRY') Thank you for all help and creative solutions. Sigrid (I am re-posting as I've gotten more information on what I wanted to know under my last post, but my new problems are not reflected by the subject and I feel like some people would be missing out a chance of helping me out. I hope it is okay.) -- View this message in context: http://r.789695.n4.nabble.com/changing-graphs-in-qqplot2-tp3626510p3626510.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] Issue with dataset inclusion in CRAN packages
I was glad to see the new rpart.plot package by Stephen Milborrow. I was however a bit concerned that Stephen distributed a dataset I created, and renamed the dataset (from titanic3 to ptitanic) in the process [with some justification, as some variables were omitted]. Fortunately Stephen included the script he used to download the dataset from our web site, and gave full credit to us. What concerns me is that the rpart.plot package does not contain many functions but the package is as large as packages containing hundreds of functions. This is due to the inclusion of the dataset. I would prefer that authors provide the URL so that users can easily install the binary R binary dataframe directly from our web site (we even have an automated way to do this: require(Hmisc); getHdata(titanic3)). This will allow users to profit from possible future data corrections as well as making the package much more compact. Thanks for listening. I'm writing to r-help because this may applied to other R packages as well. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Issue-with-dataset-inclusion-in-CRAN-packages-tp3626536p3626536.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] download R Package for HP-UX ia64 server
On Jun 26, 2011, at 1:10 PM, Zhou, Hong wrote: Hi, I am new to R. Is there a R package for HP-UX Itanium 64 bits server available? Questions about obscure Unix systems generally get directed to the r- devel mailing list. I'm assuming you are asking if it is possible to compile R from source on such a system. You could try contacting this questioner to see if they had eventual success: https://stat.ethz.ch/pipermail/r-devel/2010-March/056820.html Thanks very much for your help! Hong Hong Zhou, MS, MIS Senior Systems Analyst Center for Outcomes Research The Children's Hospital of Philadelphia 3535 Market St. Suite 1029 Philadelphia, PA 10104 Tel: (215) 590 5444 Fax: (215) 590 2378 Email: z...@email.chop.edu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] bwplot questions: box order, axis breaks, and multiple y-axis labels
Hi all, I used bwplot in lattice to create a 6-panel boxplot grouped by a conditioning variable (param) that displays concentration (conc) in response to treatment (trtmnt). Here is the functional part of my code followed by my three questions: library(lattice); ww-read.csv(file=c:/Rdata/lattice_boxplot_prep.csv,header=TRUE,sep=,); attach(ww); mylist-list(c(0,200), c(0,60), c(0,100), c(0,80), c(0, 5), c(0,300)) print(ww-bwplot(conc~trtmnt| param, data=ww, layout=c(1,6), as.table=TRUE, between=list(y=1), strip=FALSE, scales = list(y = list(alternating = c(1,1), tck=c(1,0), rot=0, relation = free, limits=mylist; detach(ww); 1) I want to change the order of the boxes in my boxplots along the x-axis such that my trtmnt levels are displayed in this order: CW, ACW, AHFCW, AVFCW, Hyb., Integ., Aer. Hyb., Aer. Integ., rather than the default alphabetical order. I read other posts that recommended using the factor or reorder functions to accomplish this but I have not been able to successfully apply this to my data. What is the correct way to invoke the factor or reorder functions? Here is an example of the the code that I tried without success: trtmnt-factor(trtmnt, levels=c(“CW”, “ACW”, “AHFCW”, “AVFCW”, “H”, “I”, “AH”, “AI”), labels=c(“CW”, “ACW”, “AHFCW”, “AVFCW”, “Hyb.”, “Integ.”, “Aer. Hyb.”, “Aer. Integ.”)) 2) I want to specify axis breaks in the the y-axis range for each panel. So far I’ve been able to specify a y-axis range for each panel but have not been able to specify axis breaks. How can I do that? I tried modifying mylist in the code above to denote breaks in the axis, but was unsuccessful. 3) I want to label the y-axis of each panel rather than just creating one label for the entire y-axis. I tried to do this using ylab, but was unsuccessful. What is the correct way to do this? Thanks in advance for your help, Saalem -- Saalem Adera Master of Environmental Science saalem.ad...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Issue with dataset inclusion in CRAN packages
I was wrong about this. The dataset is small. Most of the space is taken up by a nice tutorial on rpart.plot. Still I would favor linking to datasets rather than duplicating part of them. Thanks Frank Frank Harrell wrote: I was glad to see the new rpart.plot package by Stephen Milborrow. I was however a bit concerned that Stephen distributed a dataset I created, and renamed the dataset (from titanic3 to ptitanic) in the process [with some justification, as some variables were omitted]. Fortunately Stephen included the script he used to download the dataset from our web site, and gave full credit to us. What concerns me is that the rpart.plot package does not contain many functions but the package is as large as packages containing hundreds of functions. This is due to the inclusion of the dataset. I would prefer that authors provide the URL so that users can easily install the binary R binary dataframe directly from our web site (we even have an automated way to do this: require(Hmisc); getHdata(titanic3)). This will allow users to profit from possible future data corrections as well as making the package much more compact. Thanks for listening. I'm writing to r-help because this may applied to other R packages as well. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Issue-with-dataset-inclusion-in-CRAN-packages-tp3626536p3626568.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Only one strip with italic font.
On 2011-06-26 11:33, Kenneth Roy Cabrera Torres wrote: Hi R users: How can I obtain an italic font only for one of the two strips in a xyplot? library(lattice) t-rep(seq(0,10,5),4) logCFU-c(2,2.5,3,4,4.5,1.5,2,2.5,3,3.4,2,2.5) microorg-factor(rep(c(E. coli,L. monocytogenes),each=6)) tratam-factor(rep(c(t1,t2),6)) xyplot(logCFU~t|microorg+tratam,type=p, strip=strip.custom(par.strip.text=list(fontface=c(italic,bold Is this what you have in mind: myfonts - c(2, 4) xyplot(logCFU ~ t | microorg + tratam, strip = function(..., which.given, par.strip.text) strip.default(..., which.given = which.given, par.strip.text = list( font = myfonts[which.given]))) Peter Ehlers Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Accessing variables in a data frame
Just to start things off: var.name - c(gdp,inf,unp) var.id - c(w,i) x - paste(var.name, rep(var.id, each=length(var.name)), sep=_) x [1] gdp_w inf_w unp_w gdp_i inf_i unp_i Now the three differences: gdp_w - gdp_i inf_w - inf_i unp_w - unp_i Can be got using dwi - dat[, x[1:3]] - dat[, x[4:6]] and the other three differences gdp - gdp_w inf - inf_w unp - unp_w by dw - dat[, var.name] - dat[, x[1:3]] The results, in both cases, should be data frames Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Serguei Kaniovski Sent: Sunday, 26 June 2011 10:01 PM To: r-help@r-project.org Subject: [R] Accessing variables in a data frame Hello My data.frame (dat) contains many variables named var.names and others named var.names_var.id For example var.name - c(gdp,inf,unp) var.id - c(w,i) x - paste(var.name, rep(var.id, each=length(var.name)), sep=_) How can I access variables in the dama.frame by names listed in x, for example to compute gdp_w - gdp_i inf_w - inf_i unp_w - unp_i or gdp - gdp_w inf - inf_w unp - unp_w without needing to code each difference separately? Thanks for your help! Serguei Kaniovski [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [SOLVED] Only one strip with italic font.
Thank you very much! That was exactly what I need! The answer was not obvious as I thought. El dom, 26-06-2011 a las 14:36 -0700, Peter Ehlers escribió: On 2011-06-26 11:33, Kenneth Roy Cabrera Torres wrote: Hi R users: How can I obtain an italic font only for one of the two strips in a xyplot? library(lattice) t-rep(seq(0,10,5),4) logCFU-c(2,2.5,3,4,4.5,1.5,2,2.5,3,3.4,2,2.5) microorg-factor(rep(c(E. coli,L. monocytogenes),each=6)) tratam-factor(rep(c(t1,t2),6)) xyplot(logCFU~t|microorg+tratam,type=p, strip=strip.custom(par.strip.text=list(fontface=c(italic,bold Is this what you have in mind: myfonts - c(2, 4) xyplot(logCFU ~ t | microorg + tratam, strip = function(..., which.given, par.strip.text) strip.default(..., which.given = which.given, par.strip.text = list( font = myfonts[which.given]))) Peter Ehlers Thank you for your help. Kenneth __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to extract data from a function printout - example provided
Oh. Fantastic! Many thanks for this, Sarah! Have a great week! Ana From: Sarah Goslee sarah.gos...@gmail.com To: Ana Kolar annako...@yahoo.com; r-help r-help@r-project.org Sent: Sunday, 26 June 2011, 17:06 Subject: Re: [R] how to extract data from a function printout - example provided summary(m.out) is a list with items with those names. Once you know the names, you can extract them in the same way as you'd extract any element from a list: by name, by position, etc. On Sun, Jun 26, 2011 at 10:48 AM, Ana Kolar annako...@yahoo.com wrote: Thank you Sarah! But names(summary(m.out)) gives only the names and no data. I actually need to extract data (to get a table of data out of that list so that it can be analysed further on). Any idea regarding that? Ana From: Sarah Goslee sarah.gos...@gmail.com To: Ana Kolar annako...@yahoo.com Cc: R r-help@r-project.org Sent: Sunday, 26 June 2011, 16:11 Subject: Re: [R] how to extract data from a function printout - example provided As a start, run matchit() for a test dataset and look at: names(m.out) and names(summary(m.out)) You can save those named components in the usual ways. Sarah On Sun, Jun 26, 2011 at 10:06 AM, Ana Kolar annako...@yahoo.com wrote: Hi there, Does anyone know how to extract data from a function that prints out two or more summaries? In the function below (the whole code is provided) we get 5 different tables of data. I would like to split each of these tables in a separate file (while the function itself shouldn't be changed), so that further analysis on each data set could be carried out. Your help is deeply appreciated. Have a good day. Ana Here is the code: library(MatchIt) f - treat ~ age + I(age^2) + educ + I(educ^2) + black + hispan + married + nodegree + re74 + I(re74^2) + re75 + I(re75^2) d - lalonde m - nearest matching - function(formula,data,method){ library(MatchIt) m.out - matchit(formula=f, data=d, method=m) print(m.out) print(summary(m.out)) } matching(f,d,m) [[alternative HTML version deleted]] -- Sarah Goslee http://www.functionaldiversity.org [[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] RJDBC and multiple classpaths
My ignorance! I managed to connect doing: library(RJDBC) cp - c( /opt/DbVisualizer-7.1.1/jdbc/mdb/log4j.jar, /opt/DbVisualizer-7.1.1/jdbc/mdb/commons_lang.jar, /opt/DbVisualizer-7.1.1/jdbc/mdb/commons_logging.jar ) .jinit(classpath=cp) drv - JDBC(jstels.jdbc.mdb.MDBDriver, /opt/DbVisualizer-7.1.1/jdbc/mdb/mdbdriver.jar) con - dbConnect(drv, jdbc:jstels:mdb:/mnt/disco/data/fhi/roads/ROADSII.mdb) If there better ways please advice me. Thanks! Caveman On Sun, Jun 26, 2011 at 3:29 PM, Orvalho Augusto orvaq...@gmail.com wrote: Corect me if this is not the right place to post this. I have a mdbdriver.jar (to access an MSAccess file) under Linux. I bought the license from http://www.csv-jdbc.com/ guys. The driver work fine when tested with DBVisualizer or another JDBC thing. The problem is that driver needs 3 other more jar files to work. Under R I have tried this and does not work: library(RJDBC) Loading required package: DBI Loading required package: rJava .jaddClassPath(/opt/DbVisualizer-7.1.1/jdbc/mdb/log4j.jar) .jaddClassPath(/opt/DbVisualizer-7.1.1/jdbc/mdb/commons_lang.jar) .jaddClassPath(/opt/DbVisualizer-7.1.1/jdbc/mdb/commons_logging.jar) drv - JDBC(jstels.jdbc.mdb.MDBDriver, /opt/DbVisualizer-7.1.1/jdbc/mdb/mdbdriver.jar) Error in .jfindClass(as.character(driverClass)[1]) : java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator As you see I have added the log4j with .jaddClassPath. What is wrong? Caveman [[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] Issue with dataset inclusion in CRAN packages
Em 26/6/2011 17:43, Frank Harrell escreveu: I was glad to see the new rpart.plot package by Stephen Milborrow. I was however a bit concerned that Stephen distributed a dataset I created, and renamed the dataset (from titanic3 to ptitanic) in the process [with some justification, as some variables were omitted]. Fortunately Stephen included the script he used to download the dataset from our web site, and gave full credit to us. What concerns me is that the rpart.plot package does not contain many functions but the package is as large as packages containing hundreds of functions. This is due to the inclusion of the dataset. I would prefer that authors provide the URL so that users can easily install the binary R binary dataframe directly from our web site (we even have an automated way to do this: require(Hmisc); getHdata(titanic3)). This will allow users to profit from possible future data corrections as well as making the package much more compact. Thanks for listening. I'm writing to r-help because this may applied to other R packages as well. Frank, I can understand your concern and at first thought would even second it. On the other hand, I think there are reasonable explanations why all authors prefer to include the datasets, especially if the data will be used in examples: 1) Docs written based in the datasets are synced with the dataframes offered with the package; 2) In several environments access to the web may be restricted and the getHdata or read.table(url) be not allowed. my 0.01... Regards, -- Cesar Rabak __ 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] Kernel Density Estimation at manually specified points
Hello, my name is Carsten. This ist my first post to R-help mailing list. I estimate densities with the function density out of the package stats. A simplified example: #generation of test data n=10 z = rnorm(n) #density estimation f=density(z,kernel=epanechnikov,n=n) #evaluation print(f$y[5]) Here I can only evaluate the estimation at given points. These points are determined by the parameter n. By default they are equidistant distributed on the interesting interval. But I need to evaluate the estimation (the estimated densitiy function) at manually specified points. For example I want to compute f(z[i]). This means I am interested in the estimated density at a the observation z[i]. Does anyone know how I can compute this? I think this is an ordinary task so I would be surprised if R can not manage this. But even after a long search I have found nothing. Thanks in advance Carsten Harlaß -- Carsten Harlaß Aachen University of Applied Sciences Campus Jülich E-Mail: carsten_harl...@web.de __ 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] Fw:
- Forwarded Message - From: Ungku Akashah kasla...@yahoo.com To: r-help@r-project.org r-help@r-project.org Sent: Friday, June 24, 2011 3:15 PM Subject: hi dear R crew. may i request the script for volcano plot. if able, pls include any tips about volcano plot. thank you. [[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] Estimate zero inflated mixed model parameter
Hi, I can not estimate the zero inflated mixed model parameters successfully. If it is possible, would you please help me write the code? In my case, I consider the location as a random effect. My data are: location y x1 x2 x3 1 1 1 2 2 2 3 3 3 Thank you very much. Yours, Xiongqing __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plotting a gragh or histogram in a certain colour
Dear Sir, Just started using R. I want to plot x-1:20, for example, in the colour blue. How do I do this? Regards, Ivo [[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] Fw:
- Forwarded Message - From: Ungku Akashah kasla...@yahoo.com To: r-help@r-project.org r-help@r-project.org Sent: Friday, June 24, 2011 3:15 PM Subject: hello. I need some help about this R software. I've been searching for volcano plot script for long, but still not found. May i request the script for volcano plot. If able, pls include any tips about volcano plot. thank you. [[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] (no subject)
hello. I need some help about this R software. I've been searching for volcano plot(statistic) script for long, but still not found. May i request the script for volcano plot. If able, pls include any tips about volcano plot. thank you. [[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] Fw:
Hi Ungku, Check ?persp ?volcano in the R console. HTH, Jorge On Sun, Jun 26, 2011 at 9:22 PM, Ungku Akashah wrote: - Forwarded Message - From: Ungku Akashah To: r-help@r-project.org Sent: Friday, June 24, 2011 3:15 PM Subject: hello. I need some help about this R software. I've been searching for volcano plot script for long, but still not found. May i request the script for volcano plot. If able, pls include any tips about volcano plot. thank you. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting a gragh or histogram in a certain colour
plot(1:20,col='blue') On Mon, Jun 27, 2011 at 9:40 AM, gwanme...@aol.com wrote: Dear Sir, Just started using R. I want to plot x-1:20, for example, in the colour blue. How do I do this? Regards, Ivo [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fw:
You can find the volcano script (along with a lot of others) at the following site: http://addictedtor.free.fr/graphiques/thumbs.php On Mon, Jun 27, 2011 at 11:49 AM, Jorge Ivan Velez jorgeivanve...@gmail.com wrote: Hi Ungku, Check ?persp ?volcano in the R console. HTH, Jorge On Sun, Jun 26, 2011 at 9:22 PM, Ungku Akashah wrote: - Forwarded Message - From: Ungku Akashah To: r-help@r-project.org Sent: Friday, June 24, 2011 3:15 PM Subject: hello. I need some help about this R software. I've been searching for volcano plot script for long, but still not found. May i request the script for volcano plot. If able, pls include any tips about volcano plot. thank you. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-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] Errors when installing RSPerl-0.92
Hello, I am having errors when I try to install RSPerl-0.92 under fedora 14. I have the following rpms installed: R-devel-2.13.0-1.fc14.x86_64 R-core-2.13.0-1.fc14.x86_64 perl-5.12.3-143.fc14.x86_64 perl-devel-5.12.3-143.fc14.x86_64 perl-ExtUtils-* (all of them from yum) Now I get the following errors: # R CMD INSTALL RSPerl_0.92-1.tar.gz * installing to library /usr/lib64/R/library * installing *source* package RSPerl ... checking for perl... /usr/bin/perl No support for any of the Perl modules from calling Perl from R. * Set PERL5LIB to /usr/lib64/R/library/RSPerl/perl * Testing: -L/usr/lib64/R/lib -lR Using '/usr/bin/perl' as the perl executable Perl modules (no): Adding R package to list of Perl modules to enable callbacks to R from Perl Creating the C code for dynamically loading modules with native code for Perl: R modules: R; linking: checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed Support R in Perl: yes configure: creating ./config.status config.status: creating src/Makevars config.status: creating inst/scripts/RSPerl.csh config.status: creating inst/scripts/RSPerl.bsh config.status: creating src/RinPerlMakefile config.status: creating src/Makefile.PL config.status: creating cleanup config.status: creating src/R.pm config.status: creating R/perl5lib.R making target all in RinPerlMakefile gcc -m64 -std=gnu99 -I/usr/include/R -I. -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib64/perl5/CORE -DPERL_POLLUTE -D_R_=1 -DUSE_R=1 -DUSE_TOPLEVEL_EXEC=1 -DWITH_R_IN_PERL=1 -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c Converters.c -o Converters.o Converters.c: In function 'makeForeignPerlReference': Converters.c:568:8: warning: unused variable 'key' Converters.c:566:6: warning: unused variable 'n' Converters.c: In function 'RS_discardPerlForeignReference': Converters.c:675:14: warning: unused variable 'key' Converters.c: In function 'PerlAddHomogeneousElement': Converters.c:1056:7: error: duplicate case value Converters.c:1041:7: error: previously used here make: *** [Converters.o] Error 1 calling make -f Makefile.perl install make: Makefile.perl: No such file or directory make: *** No rule to make target `Makefile.perl'. Stop. chmod: cannot access `blib/lib/R.pm': No such file or directory Finished configuration ** libs gcc -m64 -std=gnu99 -I/usr/include/R -I. -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib64/perl5/CORE -DPERL_POLLUTE -D_R_=1 -DUSE_R=1 -DUSE_TOPLEVEL_EXEC=1 -DWITH_R_IN_PERL=1 -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c Converters.c -o Converters.o Converters.c: In function makeForeignPerlReference: Converters.c:568:8: warning: unused variable key Converters.c:566:6: warning: unused variable n Converters.c: In function RS_discardPerlForeignReference: Converters.c:675:14: warning: unused variable key Converters.c: In function PerlAddHomogeneousElement: Converters.c:1056:7: error: duplicate case value Converters.c:1041:7: error: previously used here make: *** [Converters.o] Error 1 ERROR: compilation failed for package RSPerl * removing /usr/lib64/R/library/RSPerl The errors involve the use of C constants SVt_IV (perl integer) and SVt_RV (perl reference). As of perl 5.12, SVt_RV is synonymous with SVt_IV. So the switch statements containing both throw a duplicate value error. Well, I reasoned that the integer interpretation may only be needed now and commented out the SVt_IV entries in Converters.c and Reflections.c switch statements. I know I am treading on dangerous ground here. But it got RSPerl to compile to the following stage: # R CMD INSTALL RSPerl_0.92-1_modified.tar.gz * installing to library /usr/lib64/R/library * installing *source* package RSPerl ... checking for perl... /usr/bin/perl No support for any of the Perl modules from calling Perl from R. * Set PERL5LIB to /usr/lib64/R/library/RSPerl/perl * Testing: -L/usr/lib64/R/lib -lR Using '/usr/bin/perl' as the perl executable Perl modules (no): Adding R package to list of Perl modules to enable callbacks to R from
Re: [R] changing graphs in qqplot2
Hi On Sun, Jun 26, 2011 at 4:21 PM, Sigrid s.stene...@gmail.com wrote: This is what I have now so far. p=ggplot(data = test, aes(x = YEAR, y = TOTAL, colour = TREATMENT)) + geom_point() + geom_smooth(method = lm, se=FALSE) + facet_wrap(~COUNTRY) p +scale_x_continuous(limits=c(1,4)) http://r.789695.n4.nabble.com/file/n3626510/graph.gif I would also like to: 1.) change the headline for the faced wraps ‘high’ and ‘low’. Is there any other way of doing that other than changing the names in the dataset? Don't think so. Changing the names is easy if you have stored the variable as a factor -- just change the levels. 2.) show the slope and intercept next to the treatments labels on the right side. The geom_text only works inside the graph. I know I can change the names of the treatments in the data set to include the intercept and slope, but that seems like a detour for what I want to achieve. See the breaks and labels argument in ?scale_hue. As far as I know you'll have to calculate the values outside of ggplot though. 3.) avoid the decimals on the x-axis. I would prefer the ticks to be (1,2,3,4). How is that done? See the breaks and labels arguments to ?scale_x_continuous 4.) change the lines. The look of the graph is exactly what I am after (except those minor changes mentioned above). However, the slopes and intercepts are not the same as what I got when I completed an ancova model. coef(lm(formula = TOTAL~ TREATMENT + YEAR + COUNTRY + TREATMENT:YEAR, data= test)) r gives the values for the different intercepts and slopes... Well, those models are not the same. ggplot is calculating separate lines for high and low COUNTRY, you are merely controling for it. It's not clear to me what you actually want to do. a. I’ve tried adding an abline that specifies slope and intercept. But then I would have to specify which of the facet wraps that the line belongs to, as it turns up in both grids. Is that possible in qqplot2? Yes, you can put the intercept and slope values in a separate data.frame. For example, d2 - data.frame(vs = c(0, 1), a = c(11, 11), b = -0.25, -0.25) ggplot(mtcars, aes(mpg, cyl)) + geom_point() + geom_abline(aes(intercept = a, slope = b), data = d2) + facet_wrap(~vs) p=ggplot(data = test, aes(x = YEAR, y = TOTAL, colour = TREATMENT)) + geom_point() + facet_wrap(~NITROGEN) #this is the treatment A, but should only be displayed in the right graph (low). p + geom_abline(intercept = 81.476,slope=47.2667, colour = red, size = 1) http://r.789695.n4.nabble.com/file/n3626510/graph2.gif b. Another option I’ve tried is to specify the model in the stat_smooth and geom_smooth commandsm=, but in both cases I get an error message. p + stat_smooth(method = lm, formula = TOTAL ~ TREATMENT + YEAR + COUNTRY + TREATMENT:YEAR)+ + geom_point() Error in model.frame.default(formula = formula, data = data, weights = weight, : variable lengths differ (found for 'COUNTRY') I think you can only specify transformations to x and y in the formula argument. At least I've never got anything more complicated to work. So I recommend either using geom_abline or going back and thinking about what exactly you want geom_smooth to do (see my comment on part 4 above). Thank you for all help and creative solutions. Hope it helps, Ista Sigrid (I am re-posting as I've gotten more information on what I wanted to know under my last post, but my new problems are not reflected by the subject and I feel like some people would be missing out a chance of helping me out. I hope it is okay.) -- View this message in context: http://r.789695.n4.nabble.com/changing-graphs-in-qqplot2-tp3626510p3626510.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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ 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] bwplot questions: box order, axis breaks, and multiple y-axis labels
On Mon, Jun 27, 2011 at 2:35 AM, Saalem Adera saalemad...@gmail.com wrote: Hi all, I used bwplot in lattice to create a 6-panel boxplot grouped by a conditioning variable (param) that displays concentration (conc) in response to treatment (trtmnt). Here is the functional part of my code followed by my three questions: library(lattice); ww-read.csv(file=c:/Rdata/lattice_boxplot_prep.csv,header=TRUE,sep=,); attach(ww); mylist-list(c(0,200), c(0,60), c(0,100), c(0,80), c(0, 5), c(0,300)) print(ww-bwplot(conc~trtmnt| param, data=ww, layout=c(1,6), as.table=TRUE, between=list(y=1), strip=FALSE, scales = list(y = list(alternating = c(1,1), tck=c(1,0), rot=0, relation = free, limits=mylist; detach(ww); 1) I want to change the order of the boxes in my boxplots along the x-axis such that my trtmnt levels are displayed in this order: CW, ACW, AHFCW, AVFCW, Hyb., Integ., Aer. Hyb., Aer. Integ., rather than the default alphabetical order. I read other posts that recommended using the factor or reorder functions to accomplish this but I have not been able to successfully apply this to my data. What is the correct way to invoke the factor or reorder functions? Here is an example of the the code that I tried without success: trtmnt-factor(trtmnt, levels=c(“CW”, “ACW”, “AHFCW”, “AVFCW”, “H”, “I”, “AH”, “AI”), labels=c(“CW”, “ACW”, “AHFCW”, “AVFCW”, “Hyb.”, “Integ.”, “Aer. Hyb.”, “Aer. Integ.”)) Looks reasonable to me. As you have the data and we do not, only you can figure out why this did not lead to success. 2) I want to specify axis breaks in the the y-axis range for each panel. So far I’ve been able to specify a y-axis range for each panel but have not been able to specify axis breaks. How can I do that? I tried modifying mylist in the code above to denote breaks in the axis, but was unsuccessful. Lattice does not support axis breaks (at least not what I think of as axis breaks). 3) I want to label the y-axis of each panel rather than just creating one label for the entire y-axis. I tried to do this using ylab, but was unsuccessful. What is the correct way to do this? As you have a one-column layout, you should be able to do this with a vector ylab, e.g. ylab = c(lab1, lab2, ..., lab6). -Deepayan __ 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.