Re: [R] summary of a list
Hello Dieter and everyone, Thank you for your advice... but I didn't manage to solve my problem... :-( I actually like the fact that R tells me which ones of my regressions didn't achieve convergence and gives me a warning saying that there was a false or singular convergence... the problem is that out of 35 regressions I do with my loop, only 5 don't achieve convergence and I would like to be able to get the summaries(or sigma, or coef, ...) of the 30 regressions that did achieve convergence... (I know from the start that some regression functions will work for some variable and not necessarily for others) At the moment I check which ones reach convergence by doing print(resultList) and then I extract the summary by doing the following loop: summaryList-list() for (i in c(1:8, 11:14, 16:24, 26:34)) { summaryList[[i]]-summary(resultList[[i]]) } But this is quite tedious, since I will have to repeat it for other rivers and also in the next years... Is there a way to tell R to show me the summary of all the results anyway? Cause right now if I do: summaryList-list() for (i in length(resultList)) { summaryList[[i]]-summary(resultList[[i]]) } R only shows me the first 8 summaries and then stops because the ninth didn't reach convergence... Any suggestion? P.S. I tried to use nls2 but I have the same problems... lauramorgana at bluewin.ch lauramorgana at bluewin.ch writes: Hello, I'm using the following for loop to find regression curves using a list of functions (formList), a list of .. long non-reproducible code removed And I got the following error message: Error in chol2inv(object$m$Rmat()) : l'elemento (3, 3) è zero, quindi l'inversa non può essere calcolata Which translated should be: Error in chol2inv(object$m$Rmat()): the element (3, 3) is zero (NULL?), that's why the inverse (inverse function?) can not be computed nls is rather nasty or nice in telling you when the result should not be trusted. Other software gives nonsense result without blinking. In package nlme, there is a function nlsList which does directly what you want, but there is little help besides revising the model for the cases without convergence. Also try check Gabor Grothendieks package nls2 which could help you finding better start values. Dieter __ 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] Bootstrap or Wilcoxons' test?
Hi! I'm comparing the differences in contaminant concentration between 2 different groups of people ( N=36, N=37). When using a simple linear regression model I found no differences between groups, but when evaluating the diagnostic plots of the residuals I found my independent variable to have deviations from normality (even after log transformation). Therefore I have used bootstrap on the regression parameters ( R= 1000 R=1) and this confirms my results , i.e., no differences between groups ( and the distribution is log-normal). However, when using wilcoxons' rank sum test on the same data set I find differences between groups. Should I trust the results from bootstrapping or from wilcoxons' test? Thanks! Regards Lotta Rylander [[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] Latex or html output for freq() in prettyR
christiaan pauw wrote: Hi Everybody I need to create a lot of frequency tables with frequencies and percentages (and cumilative freq and % as well) for a report. freq() in prettyR give more or less what I need. I am trying to export the result of freq() to html but the html doesn't look look the console output. See the following example library(prettyR) library(Hmisc) x - matrix(sample(1:3, 12, replace=TRUE), nrow=3, dimnames=list(c('A','B', 'C'),letters[1:4])) # create a 3x4 matrix with random numbers beteen 1 and 3 x # see what it looks like fx=freq(x) # create frequency table with frequencies and % per column fx # looks pretty good, now I want to export it to latex or html html(fx) # I expected this to look like console output but it doesn't. Can anything be done? fm=as.matrix(fx) #It can't be coerced into a matrix or table (as far as i can see) class(fm) # it's class remains freq Does anyone now what to do? Hi Christiaan, One way to get the same output in HTML as in the console is to use the htmlize function in the prettyR package. htmlize runs an R script (so that you can edit the script until it does just what you want) and formats the output of the script as an HTML page. So if you had a script that contained: library(prettyR) x - matrix(sample(1:3, 12, replace=TRUE), nrow=3, dimnames=list(c('A','B','C'),letters[1:4])) beteen 1 and 3 x # see what it looks like fx-freq(x) # create frequency table with frequencies and % per column fx # looks pretty good, now I want to export it to latex or html and you named it testfreq.R. You could get the output you want with: htmlize(testfreq.R,title=My HTML output) the output will appear in a file named, testfreq.html unless you name it something else with the HTMLbase argument to htmlize. The html function from the Hmisc package is probably expecting a data frame and not the output of the freq function. However, it does the best it can and tries to make a data.frame out of a pig's ear, constructing and displaying the result in an HTML table. Hats off to Professor Harrell for writing the function so that it does anything more than barf in the situation. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extending each element in a list, or rbind()-ing arrays of different length without recycling
My question is: Why would you want a data structure that is clearly not expressive of the data involved? Let me guess. You are coming from statistical software where data are always rectangular. Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of The R Inferno and A Guide for the Unwilling S User) Jason Shaw wrote: Hi, I'm trying to take a matrix such as [,1] [,2] [,3] [,4] [,5] [1,]27279 [2,] 10 10686 [3,]19720 and generate a new matrix which contains only the unique values in each row: [,1] [,2] [,3] [,4] [,5] [1,]279 NA NA [2,] 1068 NA NA [3,]19720 My problem is that I can use apply(matrix,MARGIN=1,FUN=unique) to find the unique values, but this leaves me with a list with arrays of different length: x - apply(peaks,MARGIN=1,FUN=unique) [[1]] [1] 2 7 9 [[2]] [1] 10 6 8 [[3]] [1] 1 9 7 2 0 and using do.call(rbind,x) recycles the values of the shorter vectors instead of filling them with NA: do.call(rbind,x) [,1] [,2] [,3] [,4] [,5] [1,]27927 [2,] 1068 106 [3,]19720 So, I'd like to either take every element of the list and extend it with NAs to the length of the longest element, or rbind every element where missing places are filled with NAs instead of recycled values. Is this possible? Of course, the solution is trivial using a loop, but I'm trying to avoid this. Thanks for any suggestions. __ 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] Problem with lmer and wiki example
James Widman wrote: I am trying to duplicate the example by Spencer Graves in the wiki, using lmer with the Nozzle data. http://wiki.r-project.org/rwiki/doku.php?id=guides:lmer-tests However the Chisq value and the fitAB values that are calculated are different compared to those in the example. I also get a warning message when I attempt the fitAB. Does anyone have any guidance as to why this might happen and how to correct it? I am using R on Kubutu in case that may be helpful. Thanks my code -- [Previously saved workspace restored] rm(list=ls(all=TRUE)) list=ls(all=TRUE) print(list) character(0) y - c(6,6,-15, 26,12,5, 11,4,4, 21,14,7, 25,18,25, + 13,6,13, 4,4,11, 17,10,17, -5,2,-5, 15,8,1, + 10,10,-11, -35,0,-14, 11,-10,-17, 12,-2,-16, -4,10,24) Nozzle - data.frame(Nozzle=rep(LETTERS[1:3], e=15),Operator=rep(letters[1:5], e=3), flowRate=y) summary(Nozzle) Nozzle Operator flowRate A:15 a:9 Min. :-35.000 B:15 b:9 1st Qu.: 0.000 C:15 c:9 Median : 7.000 d:9 Mean : 5.511 e:9 3rd Qu.: 13.000 Max. : 26.000 library(lme4) Loading required package: Matrix Loading required package: lattice fitAB - lmer(flowRate~Nozzle+(Nozzle|Operator),data=Nozzle, method=ML) Warning messages: 1: In .local(x, ..., value) : Estimated variance-covariance for factor ‘Operator’ is singular 2: In .local(x, ..., value) : nlminb returned message false convergence (8) fitB - lmer(flowRate~1+(1|Operator), data=Nozzle, method=ML) anova(fitAB, fitB) Data: Nozzle Models: fitB: flowRate ~ 1 + (1 | Operator) fitAB: flowRate ~ Nozzle + (Nozzle | Operator) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) fitB 2 359.36 362.98 -177.68 fitAB 9 362.13 378.39 -172.06 11.237 7 0.1286 -- Output from Spencer Graves example fitAB 9 359.88 376.14 -170.94 13.479 7 0.06126 Now, on a Mac OS X (using the unstable, development version of R 2.9.0, and recompiled version of lme4_0.999375-28... so caution of course!), I got this: First, the method = ML argument is deprecated and replaced by REML = TRUE/FALSE, but the doc at ?lmer does not tell exactly what is the equivalence to method = ML (and I don't know enough in this field to determine it by myself). Anyway, I tried both: fitAB - lmer(flowRate~Nozzle+(Nozzle|Operator),data=Nozzle, REML = TRUE) #Warning messages: #1: In .local(x, ..., value) : #Estimated variance-covariance for factor Operator is singular #2: In .local(x, ..., value) : #nlminb returned message false convergence (8) fitB - lmer(flowRate~1+(1|Operator), data=Nozzle, REML = TRUE) anova(fitAB, fitB) Data: Nozzle Models: fitB: flowRate ~ 1 + (1 | Operator) fitAB: flowRate ~ Nozzle + (Nozzle | Operator) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) fitB 3 361.36 366.78 -177.68 fitAB 10 362.10 380.17 -171.05 13.261 70.06601 . --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 fitAB - lmer(flowRate~Nozzle+(Nozzle|Operator),data=Nozzle, REML = FALSE) #Warning messages: #1: In .local(x, ..., value) : #Estimated variance-covariance for factor Operator is singular #2: In .local(x, ..., value) : #nlminb returned message false convergence (8) fitB - lmer(flowRate~1+(1|Operator), data=Nozzle, REML = FALSE) anova(fitAB, fitB) Data: Nozzle Models: fitB: flowRate ~ 1 + (1 | Operator) fitAB: flowRate ~ Nozzle + (Nozzle | Operator) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) fitB 3 361.36 366.78 -177.68 fitAB 10 361.96 380.03 -170.98 13.402 7 0.0629 . --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 So, I got same error messages as you. I got results closer to the one in the wiki page, BUT, I am puzzled by the degrees of freedom that are different 3/10 in my case, against 2/9 in yours and in the wiki page! Could the authors of lmer(), and/or of the wiki page, or the code cited in the wiki page (in CC) provide some explanation to this? Corrections/updates of the wiki page so that it reflects latest lmer() version would be also very much appreciated. All the best, Philippe Grosjean Just in case: R.Version() $platform [1] i386-apple-darwin8.11.1 $arch [1] i386 $os [1] darwin8.11.1 $system [1] i386, darwin8.11.1 $status [1] Under development (unstable) $major [1] 2 $minor [1] 9.0 $year [1] 2009 $month [1] 01 $day [1] 22 $`svn rev` [1] 47686 $language [1] R $version.string [1] R version 2.9.0 Under development (unstable) (2009-01-22 r47686) sessionInfo() R version 2.9.0 Under development (unstable) (2009-01-22 r47686) i386-apple-darwin8.11.1 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] tcltk stats graphics grDevices utils datasets methods [8] base other attached packages: [1] lme4_0.999375-28 Matrix_0.999375-18 lattice_0.17-20 [4] svGUI_0.9-44 svSocket_0.9-43svMisc_0.9-47 loaded via a namespace (and not attached): [1] grid_2.9.0 tools_2.9.0
[R] extracting parts of words or extraxting letter to use in ifelse-func.
Hello I want to make some variables with the ifelse-function, but i don't know how to do it. I want to make these five variables; b2$PRRSvac - ifelse(b2$status=='A' | b2$status=='Aa',1,0) b2$PRRSdk - ifelse(b2$status=='B' | b2$status=='Bb',1,0) b2$sanVac - ifelse(b2$status=='C' | b2$status=='sanAa',1,0) b2$sanDk - ifelse(b2$status=='D' | b2$status=='sanBb',1,0) b2$totalvac - ifelse(b2$status=='San',1,0) And b2$UGT - ifelse(b2$status=='UGT',1,0) b2$KOM - ifelse(b2$status=='KOM',1,0) But, as one from this forum told me, it doesn't work because the words is in a wrong format or something like that. I have attached the text-file i've used, and the R-kode. Hope anyone can help me? text-file; http://www.nabble.com/file/p21993098/allesd%2528uden%2Bf%25C3%25B8r%2529060209.txt allesd%28uden+f%C3%B8r%29060209.txt R-kode (just run from line 1-22) ; http://www.nabble.com/file/p21993098/PRRS%2B%2528med%2Ballle%2BSD%2529.r PRRS+%28med+allle+SD%29.r -- View this message in context: http://www.nabble.com/extracting-parts-of-words-or-extraxting-letter-to-use-in-ifelse-func.-tp21993098p21993098.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] .rda extension
Hi, I have very simple question. How to open/read/write the file with .rda extension which is usually available in the data folder of any package? By Sukhbir Singh Rattan [[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] extracting parts of words or extraxting letter to use in ifelse-func.
hey Joe, I had a quick look at your code. In this line: b2$PRRSvac - ifelse(b2$status==MS-X, PRRS-pos|b2$status==R�d SPF+Myc+Ap2+DK+Vac,1,0) some special characters are used. You must use only plain ascii characters Hope this help. Cheers, Patrizio 2009/2/13 joe1985 johan...@dsr.life.ku.dk: Hello I want to make some variables with the ifelse-function, but i don't know how to do it. I want to make these five variables; b2$PRRSvac - ifelse(b2$status=='A' | b2$status=='Aa',1,0) b2$PRRSdk - ifelse(b2$status=='B' | b2$status=='Bb',1,0) b2$sanVac - ifelse(b2$status=='C' | b2$status=='sanAa',1,0) b2$sanDk - ifelse(b2$status=='D' | b2$status=='sanBb',1,0) b2$totalvac - ifelse(b2$status=='San',1,0) And b2$UGT - ifelse(b2$status=='UGT',1,0) b2$KOM - ifelse(b2$status=='KOM',1,0) But, as one from this forum told me, it doesn't work because the words is in a wrong format or something like that. I have attached the text-file i've used, and the R-kode. Hope anyone can help me? text-file; http://www.nabble.com/file/p21993098/allesd%2528uden%2Bf%25C3%25B8r%2529060209.txt allesd%28uden+f%C3%B8r%29060209.txt R-kode (just run from line 1-22) ; http://www.nabble.com/file/p21993098/PRRS%2B%2528med%2Ballle%2BSD%2529.r PRRS+%28med+allle+SD%29.r -- View this message in context: http://www.nabble.com/extracting-parts-of-words-or-extraxting-letter-to-use-in-ifelse-func.-tp21993098p21993098.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] .rda extension
See ?library, ?data and for direct access of the file ?load Uwe Ligges Sukhbir Rattan wrote: Hi, I have very simple question. How to open/read/write the file with .rda extension which is usually available in the data folder of any package? By Sukhbir Singh Rattan [[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] Setting optimizer in lme
lme(..., control=lmeControl(opt=optim)) Uwe Ron Burns wrote: I am using R 2.7.0 on a linux platform. I am trying to reproduce a 2002 example using lme from the nlme library. I want to change the otimizer from the default (nlminb) to optim. Specifically, this is what I am trying to do: R library(nlme) R library(car) # for data only R data(Blackmoor) # from car R Blackmoor$log.exercise - log(Blackmoor$exercise + 5/60, 2) R attach(Blackmoor) R lme(log.exercise ~ I(age - 8)*group, + random = ~ I(age - 8) | subject, + correlation = corCAR1(form = ~ age-8|subject), + data=Blackmoor) Error in lme.formula(log.exercise ~ I(age - 8) * group, random = ~I(age - : nlminb problem, convergence error code = 1 message = iteration limit reached without convergence (9) This converged in the example that I am studying. Help file indicates that opt the optimizer to be used, either nlminb (the default since (R 2.2.0) or optim (the previous default). So tried to go back the old optimize that used in the 2002 example, but I do not seem to be able to get there. lmeControl(opt=optim) Error in match.arg(opt) : 'arg' must be NULL or a character vector R lmeControl(opt=optim) $maxIter [1] 50 ... $opt [1] optim ... R lme(log.exercise ~ I(age - 8)*group, + random = ~ I(age - 8) | subject, + correlation = corCAR1(form = ~ age-8|subject), + data=Blackmoor) Error in lme.formula(log.exercise ~ I(age - 8) * group, random = ~I(age - : nlminb problem, convergence error code = 1 message = iteration limit reached without convergence (9) Seem that the nlminb minimizer is still being. Try setting it in the function call: R lme(log.exercise ~ I(age - 8)*group, + random = ~ I(age - 8) | subject, + correlation = corCAR1(form = ~ age-8|subject), + opt=optim, + data=Blackmoor) Error in lme(log.exercise ~ I(age - 8) * group, random = ~I(age - 8) | : unused argument(s) (opt = function (par, fn, gr = NULL, ..., method = c(Nelder-Mead, BFGS, CG, L-BFGS-B, SANN), lower = -Inf, upper = Inf, control = list(), hessian = FALSE) This does not look like what I want either. Any suggestions appreciated. My thanks in advance, Ron __ 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] Running examples failed (but there are none).
Remko Duursma wrote: Dear R-helpers, making a package (windowsXP), that includes a bunch of functions, but none have examples (all example code is within \dontrun{} blocks). I do R CMD check Maeswrap, all bits get OK-ed, except: Running examples in 'Maeswrap-Ex.R' failed. What does the Maeswrap-Ex.Rout file tell us? Uwe Ligges When I run the 'Maeswrap-Ex.R' file myself, there are no problems. Any pointers? thanks Remko - Remko Duursma Post-Doctoral Fellow Centre for Plant and Food Science University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 __ 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] SAS Institute Adding Support for R
On Thu, 2009-02-12 at 21:32 -0300, milton ruser wrote: Dear all, I was thinking how much of R capabilities SAS Institute could incorporate on SAS support? Cheers miltinho brazil Most likely, as many as they currently provide for Tomcat, Postgres, Apache or other open source products they bundle along with their solutions. Best regards, Carlos J. Gil Bellosta http://www.datanalytics.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] Odp: extracting parts of words or extraxting letter to use in ifelse-func.
Hi r-help-boun...@r-project.org napsal dne 13.02.2009 10:38:31: Hello I want to make some variables with the ifelse-function, but i don't know how to do it. I want to make these five variables; b2$PRRSvac - ifelse(b2$status=='A' | b2$status=='Aa',1,0) b2$PRRSdk - ifelse(b2$status=='B' | b2$status=='Bb',1,0) b2$sanVac - ifelse(b2$status=='C' | b2$status=='sanAa',1,0) b2$sanDk - ifelse(b2$status=='D' | b2$status=='sanBb',1,0) b2$totalvac - ifelse(b2$status=='San',1,0) Basically you do not need ifelse b2$status=='San' gives you logical vector and you can directly multiply it by 1 to get 1 for TRUE and 0 for FALSE 1*(b2$status=='San') However it is exact match so if in b2$status is San or san or SAN or San1 it will give 0 for all of these. Regards Petr And b2$UGT - ifelse(b2$status=='UGT',1,0) b2$KOM - ifelse(b2$status=='KOM',1,0) But, as one from this forum told me, it doesn't work because the words is in a wrong format or something like that. I have attached the text-file i've used, and the R-kode. Hope anyone can help me? text-file; http://www.nabble.com/file/p21993098/allesd%2528uden%2Bf%25C3%25B8r%2529060209.txt allesd%28uden+f%C3%B8r%29060209.txt R-kode (just run from line 1-22) ; http://www.nabble.com/file/p21993098/PRRS%2B%2528med%2Ballle%2BSD%2529.r PRRS+%28med+allle+SD%29.r -- View this message in context: http://www.nabble.com/extracting-parts-of-words- or-extraxting-letter-to-use-in-ifelse-func.-tp21993098p21993098.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] Meta-Analyisis on Correlations
Dear R-Community, I'm currently trying to find a way to conduct a meta-analysis in R. I would like to analyze data from mostly-cross-sectional survey-studies. The effect sizes would be correlations. The R packages meta and rmeta are, as far as I can see, set up for analysis with effect sizes for differences (i.e. comparison of the means/odds-ratios of experimental and control group). Only the function metagen from the meta-package looks like it would work with correlations. The problem here: One would need to know the standard error of the correlation. The SE is not usually reported in the studies I have (only means, SDs and Alphas for the single variables). So the SE would have to be calculated somehow... But maybe metagen is the wrong function to start with in the first place? I'm wondering whether there might be anyone knowing how to conduct a meta-analysis based on correlations in R? Thanks in advance Sebastian P.S.: Of course, I'm dreaming of such a step-by-step-script like the absolutely marvellous ones provided by Bliese for multilevel-analysis in R :-) - Dipl.-Psych. Sebastian Stegmann Managing Editor, British Journal of Management Goethe University Institute of Psychology Department of Social Psychology Kettenhofweg 128 60054 Frankfurt am Main Germany http://www.sozialpsychologie.uni-Frankfurt.de/ Phone: +49 (0) 69 / 798-23078 Fax: +49 (0) 69 / 798-22384 __ 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] Running examples failed (but there are none).
Remko Duursma wrote: Dear R-helpers, making a package (windowsXP), that includes a bunch of functions, but none have examples (all example code is within \dontrun{} blocks). I do R CMD check Maeswrap, all bits get OK-ed, except: Running examples in 'Maeswrap-Ex.R' failed. When I run the 'Maeswrap-Ex.R' file myself, there are no problems. Any pointers? Hi Remko, There are a number of ways in which the example code can run in the current R interpreter but fail in the checking of a package. Quite often it is that a package has been loaded in the current R interpreter and that package is not explicitly loaded in the example section. Even when it is loaded explicitly, there can be problems making sure that the example won't run if the package is unavailable. I devised an example for the vector.field function that used the maps package and I was never able to work out how to get it to check properly. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Website, book, paper, etc. that shows example plots of distributions?
You can readily create a dynamic display for using qqplot and similar functions in conjunction with either the playwith or TeachingDemos packages. For example, to investigate the effect of the shape parameter in the skew normal distribution on its qqplot relative to the normal distribution: library(playwith) library(sn) playwith(qqnorm(rsn(100, shape = shape)), parameters = list(shape = seq(-3, 3, .1))) Now move the slider located at the bottom of the window that appears and watch the plot change in response to changing the shape value. You can find more distributions here: http://cran.r-project.org/web/views/Distributions.html On Thu, Feb 12, 2009 at 1:04 PM, Jason Rupert jasonkrup...@yahoo.com wrote: By any chance is any one aware of a website, book, paper, etc. or combinations of those sources that show plots of different distributions? After reading a pretty good whitepaper I became aware of the benefit of I the benefit of doing Q-Q plots and histograms to help assess a distribution. The whitepaper is called: Univariate Analysis and Normality Test Using SAS, Stata, and SPSS* , (c) 2002-2008 The Trustees of Indiana University Univariate Analysis and Normality Test: 1, Hun Myoung Park Unfortunately the white paper does not provide an extensive amount of example distributions plotted using Q-Q plots and histograms, so I am curious if there is a portfolio-type website or other whitepaper shows examples of various types of distributions. It would be helpful to see a bunch of Q-Q plots and their associated histograms to get an idea of how the distribution looks in comparison against the Gaussian. I think seeing the plot really helps. Thank you for any insights. [[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] Fwd: trunc/floor a number -- strange bahaviour
I'm glad you are happy with your solution. Just one inline comment below, expanding on my private reply to you: Žroutík wrote: Resolved. nchar(unlist(strsplit(as.character(n),\\.)))[2] in the function: NumberPrecision - function(n) { PocetCyklu - 0 if(n != round(n)) { PocetCyklu - nchar(unlist(strsplit(n,\\.)))[2] } else { while(n == round(n)) { n - n/10 PocetCyklu - PocetCyklu + 1 } PocetCyklu - PocetCyklu - 1 #} PocetCyklu } for 13 the precision of the given value is the last given digit -- 5, for 12.345 it gives 3. Perfect. Regards, Z Thank you for the thoughtful conversation. -- Forwarded message -- From: Žroutík zrou...@gmail.com Date: Fri, Feb 13, 2009 at 7:32 AM Subject: Re: [R] trunc/floor a number -- strange bahaviour To: Duncan Murdoch murd...@stats.uwo.ca Thank you Duncan, and Thierry, to you, too, for the quick responses. In the FAQ, there is a different example, IMO. The value sqrt(2) is created by some function and is irrational -- I do understand in never-ending numbers programs do have to cut some digits off, therefore a mismatch. But in my example the given value is fix (it is written into an input file by a user) and there is always a fix number of digits and the number is not irrational. I do not understand how can the given/fix number 0.0001 be abruptly represented as 0.9. You say it's about binary floating point. But this is way the binary floating point was created, for real ending values, isn't it so? 12.34 is represented as 1234 (integer) times ten (integer) to the minus 2 (integer). (n - floor(n))*10 Minus floor(12) (integer), times ten gives 34 (integer) times ten to the -1 (integer). No, that's not how standard floating point representations work. 12.34 is represented as a finite precision binary number between 1 and 2 (starting out as 1.10001 in binary notation) multiplied by 2^3. The problem is that there is no way to represent it exactly in this format. Only fractions with a power of 2 in the denominator can be represented that way, and 12.34 is not one of those. It's 1234/100, and 100 is not a power of 2. Duncan Murdoch Is there any way how can I check on not to crush in such a problems. I remind you, I do not count with irrational or other neverending numbers. Regrads, Zroutik On Thu, Feb 12, 2009 at 4:44 PM, Duncan Murdoch murd...@stats.uwo.cawrote: On 2/12/2009 10:20 AM, Žroutík wrote: Hi everybody, given a fresh rgui.exe load on winxp OS, I enter (a minimal exaple) n - 12.357531 Then the following command: n - (n - floor(n))*10; n gives the following outputs: [1] 3.57531 [1] 5.7531 [1] 7.531 [1] 5.31 [1] 3.1 [1] 1 === still as expected [1] 10=== not expected, count with me: 1 - floor(1) is zero, times 10 gives 0, not 10 You are assuming that when R prints 1, the value is exactly 1. But try this: 0.9 [1] 1 0.9 == 1 [1] FALSE R rounds values when it prints them, because people don't want to see ugly output like this: options(digits=18): n - 12.357531 n - (n - floor(n))*10; n [1] 3.5753100 n - (n - floor(n))*10; n [1] 5.753098 n - (n - floor(n))*10; n [1] 7.5309821 n - (n - floor(n))*10; n [1] 5.309821 n - (n - floor(n))*10; n [1] 3.0982117 n - (n - floor(n))*10; n [1] 0.9821171 And the reason you see such ugly output is because you are working with a number that can't be represented exactly in binary floating point. Duncan Murdoch [1] 10=== should stay forever zero (0) [1] 10 [1] 9.98 [1] 9.82 [1] 9.999821 [1] 9.998212 The sama happens with trunc(). e.g. (a minimal exaple) n - 0.245 n - (n - trunc(n))*10; n [1] 2.45 [1] 4.5 [1] 5 [1] 1.776357e-13 = zero expected!!! [1] 1.776357e-12 And I'm asking what the heck?! and where is the bug in my examples? Any suggestion well appreciated. p.s. The expression with floor() and trunc() are to be implemented in a function which gives a value equal precision order of the given number. e.g. 12.345 would have (-3), 12.1 would have (-1), 12 would have (0) and e.g. 12000 would have the order of the precision (4). Basically, it is the order of the last given non-zero digit. [[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
Re: [R] Meta-Analyisis on Correlations
Sebastian Stegmann schrieb: [...] The R packages meta and rmeta are, as far as I can see, set up for analysis with effect sizes for differences (i.e. comparison of the means/odds-ratios of experimental and control group). Only the function metagen from the meta-package looks like it would work with correlations. The problem here: One would need to know the standard error of the correlation. The SE is not usually reported in the studies I have (only means, SDs and Alphas for the single variables). So the SE would have to be calculated somehow... But maybe metagen is the wrong function to start with in the first place? Dear Sebastian, Have a look at the psychometric package which is capable of doing meta-analysis of correlations. In most cases you use Fisher-z transformed correlation coefficients. For that purpose, the psychometric package offers the function r2z(). Given that you know the number of cases N, the standard error can be easily computed as se_z = sqrt(1/(N-3)) (see also http://rss.acs.unt.edu/Rdoc/library/psychometric/html/SEz.html). Once you have computed Fisher's-z transformed r's and appropriate standard errors, it shouldn't be a problem to use the metagen-function. However be aware that the psychometric package does not use Fisher's-z transformed effect sizes when computing an overall effect size (as far as I have understood checking the source of rbar() ... which is somewhat strange... Mmmh). A quick replication of Hedges/Olkin's (1985) analysis (p. 231f; z_total = 0.469) revealed that metagen's computations are correct: library(meta) library(psychometric) ## table 2, p. 232 n - c(20,30,27,42,49,12,17,35,38,40) r - c(0.41,0.53,0.51,0.43,0.37,0.39,0.45,0.40,0.36,0.52) z - r2z(r) se.z - 1/sqrt((n-3)) metagen(TE = z, seTE = se.z) [... some output omitted ...] 95%-CI z p.value Fixed effect model 0.4686 [0.3515; 0.5857] 7.8415 0.0001 Random effects model 0.4686 [0.3515; 0.5857] 7.8415 0.0001 I'm wondering whether there might be anyone knowing how to conduct a meta-analysis based on correlations in R? Feel free to ask if you have any further questions. Bernd Hedges, Larry V., und Ingram Olkin, 1985: Statistical Methods for Meta-Analysis. Orlando: Academic Press. __ 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] summary of a list
?try -- David Winsemius On Feb 13, 2009, at 3:06 AM, lauramorg...@bluewin.ch wrote: Hello Dieter and everyone, Thank you for your advice... but I didn't manage to solve my problem... :-( I actually like the fact that R tells me which ones of my regressions didn't achieve convergence and gives me a warning saying that there was a false or singular convergence... the problem is that out of 35 regressions I do with my loop, only 5 don't achieve convergence and I would like to be able to get the summaries(or sigma, or coef, ...) of the 30 regressions that did achieve convergence... (I know from the start that some regression functions will work for some variable and not necessarily for others) At the moment I check which ones reach convergence by doing print(resultList) and then I extract the summary by doing the following loop: summaryList-list() for (i in c(1:8, 11:14, 16:24, 26:34)) { summaryList[[i]]-summary(resultList[[i]]) } But this is quite tedious, since I will have to repeat it for other rivers and also in the next years... Is there a way to tell R to show me the summary of all the results anyway? Cause right now if I do: summaryList-list() for (i in length(resultList)) { summaryList[[i]]-summary(resultList[[i]]) } R only shows me the first 8 summaries and then stops because the ninth didn't reach convergence... Any suggestion? P.S. I tried to use nls2 but I have the same problems... lauramorgana at bluewin.ch lauramorgana at bluewin.ch writes: Hello, I'm using the following for loop to find regression curves using a list of functions (formList), a list of .. long non-reproducible code removed And I got the following error message: Error in chol2inv(object$m$Rmat()) : l'elemento (3, 3) è zero, quindi l'inversa non può essere calcolata Which translated should be: Error in chol2inv(object$m$Rmat()): the element (3, 3) is zero (NULL?), that's why the inverse (inverse function?) can not be computed nls is rather nasty or nice in telling you when the result should not be trusted. Other software gives nonsense result without blinking. In package nlme, there is a function nlsList which does directly what you want, but there is little help besides revising the model for the cases without convergence. Also try check Gabor Grothendieks package nls2 which could help you finding better start values. Dieter __ 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] Meta-Analyisis on Correlations
Dear Sebastian, Many researchers may transform the Pearson coefficients into Fisher's z scores first by using z - 0.5*log((1+r)/(1-r)). The standard errors of the Fisher's z scores are z.SE - 1/sqrt(n-3) where n are the sample sizes (see http://en.wikipedia.org/wiki/Fisher_transformation). Either metagen {meta} or meta.summaries {rmeta} can be used to conduct a fixed- or a random-effects meta-analysis. -- - Mike W.L. Cheung Phone: (65) 6516-3702 Department of Psychology Fax: (65) 6773-1843 National University of Singapore http://courses.nus.edu.sg/course/psycwlm/internet/ - On Fri, Feb 13, 2009 at 7:11 PM, Sebastian Stegmann stegm...@psych.uni-frankfurt.de wrote: Dear R-Community, I'm currently trying to find a way to conduct a meta-analysis in R. I would like to analyze data from mostly-cross-sectional survey-studies. The effect sizes would be correlations. The R packages meta and rmeta are, as far as I can see, set up for analysis with effect sizes for differences (i.e. comparison of the means/odds-ratios of experimental and control group). Only the function metagen from the meta-package looks like it would work with correlations. The problem here: One would need to know the standard error of the correlation. The SE is not usually reported in the studies I have (only means, SDs and Alphas for the single variables). So the SE would have to be calculated somehow... But maybe metagen is the wrong function to start with in the first place? I'm wondering whether there might be anyone knowing how to conduct a meta-analysis based on correlations in R? Thanks in advance Sebastian P.S.: Of course, I'm dreaming of such a step-by-step-script like the absolutely marvellous ones provided by Bliese for multilevel-analysis in R :-) - Dipl.-Psych. Sebastian Stegmann Managing Editor, British Journal of Management Goethe University Institute of Psychology Department of Social Psychology Kettenhofweg 128 60054 Frankfurt am Main Germany http://www.sozialpsychologie.uni-Frankfurt.de/ Phone: +49 (0) 69 / 798-23078 Fax: +49 (0) 69 / 798-22384 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] r and c++ (Duncan Murdoch)
-- Message: 22 Date: Thu, 12 Feb 2009 09:38:10 -0600 From: Dirk Eddelbuettel e...@debian.org Subject: Re: [R] r and c++ To: JC new2st...@googlemail.com Cc: r-help@r-project.org Message-ID: 18836.16994.244794.92...@ron.nulle.part Content-Type: text/plain; charset=us-ascii Javier, On 12 February 2009 at 16:16, JC wrote: | is there a way to integrate R language within a c++ programme? That is, | is there something like an R library I can incorporate in my c++ code? I have two projects on R-Forge.R-Project.org that may be of interest: Rcpp which makes it easy to pass R objects to and from C++ routines, ie when you are building R packages, and the control resides in the R session; RInsidewhich provides C++ classes to make embedding R into your C++ applications easier, and which uses some of the Rcpp classes for conversion. RInside may be what you are looking for. The package is currently somewhat raw -- no configure logic, and the Makefile has the path that works for me (on Debian / Ubuntu) but if you know enough about C, C++, R, ... to be tempted by this you probably also know how to adapt this. The code itself is mature. I had used variants of RInside for quite some time, and the inner workings are the same as in our well-tested littler scripting frontend to R. And yes, I should put up a webpage for RInside as well ... Hth, Dirk -- Esta mensagem (incluindo quaisquer anexos) pode conter informação confidencial ou legalmente protegida para uso exclusivo do destinatário. Se não for o destinatário pretendido da mesma, não deverá fazer uso, copiar, distribuir ou revelar o seu conteúdo (incluindo quaisquer anexos) a terceiros, sem a devida autorização. Se recebeu esta mensagem por engano, por favor informe o emissor, por e-mail, e elimine-a imediatamente. Obrigado. This message may contain confidential information or privileged material, and is intended only for de individual(s) named. If you are not in the named addressee, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. __ 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] Odp: Odp: extracting parts of words or extraxting letter to use in ifelse-func.
Hi johan...@dsr.life.ku.dk napsal dne 13.02.2009 13:17:06: Hi I tried what you said, but i gives FALSE all the way down! And I think its because there are other words in phrases as well. So if there is 'San' in the phrase it has to be TRUE even thoug there are other words before and after 'San' in the phrase. I do not understand. test-c( San, san, SAN, San1, San) set.seed(111) sam-sample(test, 40, replace=T) sam==San [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE TRUE [26] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE sum(sam==San) [1] 3 gives me TRUE whenever item in test vector equals San Did you read what I wrote about ***exact*** match? Do you know how to do that? phrase - If you want to discover Sun from some phrase you has to use regular expressions regexpr(Sun, phrase) [1] 25 attr(,match.length) [1] 3 phrase1 - If you want to discover blah from some phrase you has to use regular expressions ph - c(phrase, phrase1) ph [1] If you want to discover Sun from some phrase you has to use regular expressions [2] If you want to discover blah from some phrase you has to use regular expressions regexpr(Sun, ph)0 [1] TRUE FALSE But I am not an expert in regular expressions. Regards Petr -Joe Petr Pikal wrote: Hi r-help-boun...@r-project.org napsal dne 13.02.2009 10:38:31: Hello I want to make some variables with the ifelse-function, but i don't know how to do it. I want to make these five variables; b2$PRRSvac - ifelse(b2$status=='A' | b2$status=='Aa',1,0) b2$PRRSdk - ifelse(b2$status=='B' | b2$status=='Bb',1,0) b2$sanVac - ifelse(b2$status=='C' | b2$status=='sanAa',1,0) b2$sanDk - ifelse(b2$status=='D' | b2$status=='sanBb',1,0) b2$totalvac - ifelse(b2$status=='San',1,0) Basically you do not need ifelse b2$status=='San' gives you logical vector and you can directly multiply it by 1 to get 1 for TRUE and 0 for FALSE 1*(b2$status=='San') However it is exact match so if in b2$status is San or san or SAN or San1 it will give 0 for all of these. Regards Petr And b2$UGT - ifelse(b2$status=='UGT',1,0) b2$KOM - ifelse(b2$status=='KOM',1,0) But, as one from this forum told me, it doesn't work because the words is in a wrong format or something like that. I have attached the text-file i've used, and the R-kode. Hope anyone can help me? text-file; http://www.nabble.com/file/p21993098/allesd%2528uden%2Bf%25C3%25B8r%2529060209.txt allesd%28uden+f%C3%B8r%29060209.txt R-kode (just run from line 1-22) ; http://www.nabble.com/file/p21993098/PRRS%2B%2528med%2Ballle%2BSD%2529.r PRRS+%28med+allle+SD%29.r -- View this message in context: http://www.nabble.com/extracting-parts-of-words- or-extraxting-letter-to-use-in-ifelse-func.-tp21993098p21993098.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. Quoted from: http://www.nabble.com/extracting-parts-of-words-or-extraxting-letter-to-use- in-ifelse-func.-tp21993098p21994462.html __ 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] ggobi install
On Thu, Feb 12, 2009 at 3:41 PM, Michael Bibo michael_b...@health.qld.gov.au wrote: Mark Ungrin mark.ungrin at utoronto.ca writes: * Installing *source* package 'RGtk2' ... checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for LIBGLADE... no configure: WARNING: libglade not found checking for INTROSPECTION... no checking for GTK... no configure: error: GTK version 2.8.0 required ERROR: configuration failed for package 'RGtk2' ** Removing '/home/mark/R/i486-pc-linux-gnu-library/2.6/RGtk2' * Installing *source* package 'rggobi' ... checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for GGOBI... configure: error: Package requirements (ggobi = 2.1.6) were not met: Package gtk+-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH environment variable Package 'gtk+-2.0', required by 'libggobi', not found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables GGOBI_CFLAGS and GGOBI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. Mark, The first thing I would look at is whether there are any *-dev packages in synaptic for the libraries etc that are 'missing'. These -dev packages contain the header files and are not necessary for running the application, but are necessary for installing other apps from source that interact with them. This is a surprisingly little-advertised issue with Linux packaging that I found out about from the R installation manual. Just to be a bit more specific, for building RGtk2 and rggobi you'll need gtk-dev(el?) and libxml2-devel which should install all the other devel dependencies. It's kind of strange that the GGobi package installs its header files (it is implicitly a devel package), but it does not bring in the devel packages of its dependencies. But aren't there binary Ubuntu/Debian packages on the repository for RGtk2 and rggobi? Michael Bibo __ 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 change auto.key colors in xyplot
Dear lettice gurus, the code below works just fine to produce a dotplot. However, I am not successful changing the color of the lines in the legend (auto.key). If I add col=..., it only changes the color of the letters in the legend, but not the color of the lines. Really appreciate any advice on that! Dimitri library(lattice) d=data.frame(xx=c(2.2,2.1,3.3),yy=c(0.1,0.2,0.3),zz=c(2.5,2.0,1.8)) d[[2]]-as.factor(d[[2]]) dotplot(c(d[[1]],d[[3]])~rep(d[[2]],2),groups=rep(c(Group 1,Group 2),each=nrow(d)),main=list(Chart Title,cex=1), xlab=list(Title for X,cex=.9,font=2), ylab=list(Title for Y,cex=.9,font=2), auto.key = list(space = top, points = T, lines = T,cex=.9), panel = function(y,x,...){ panel.grid(h = -1, v = -1, col = gray, lty =dotted, ltx=dotted) panel.superpose(x,y,..., type=b,col.line=c(blue,red),pch=20,cex=1.3, col=c(blue,red),bg=c(blue,red),lwd=2) ltext(x, y, labels=round(y,3), cex=.8,col=black,font=2,adj=c(-0.2,1)) # adds labels to those circles # pos=2, panel.abline(h=0) } ) -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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] Fwd: trunc/floor a number -- strange bahaviour
Thank you very much, Duncan! Now it is totally clear for me. Reading the 'R inferno' tract suggested to me in private by a user (nut one can google it), and wondering about heaven and hell Best regards, Z On Fri, Feb 13, 2009 at 1:05 PM, Duncan Murdoch murd...@stats.uwo.cawrote: I'm glad you are happy with your solution. Just one inline comment below, expanding on my private reply to you: No, that's not how standard floating point representations work. 12.34 is represented as a finite precision binary number between 1 and 2 (starting out as 1.10001 in binary notation) multiplied by 2^3. The problem is that there is no way to represent it exactly in this format. Only fractions with a power of 2 in the denominator can be represented that way, and 12.34 is not one of those. It's 1234/100, and 100 is not a power of 2. Duncan Murdoch [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding abline in Lattice graph
Sundar Dorai-Raj sdorairaj at gmail.com writes: Sorry, that was my lack of understanding on how coplot works. Try the following: coplot(lbxglu~lbxgh|eth, data = reg.dat.5, panel= function(...) { panel.smooth(...) abline(h = 126, col = red) abline(v = 6.5, col = blue) }, xlab=ABC, ylab=FBG) No, it was not your lack of understanding. Since the original poster did not provide sample data (too much work?), you had to provide untested code. Function coplot is standard graphics, not lattice, so panels do not work here. Dieter __ 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] Problem with lmer and wiki example
Philippe Grosjean wrote: James Widman wrote: I am trying to duplicate the example by Spencer Graves in the wiki, using lmer with the Nozzle data. http://wiki.r-project.org/rwiki/doku.php?id=guides:lmer-tests However the Chisq value and the fitAB values that are calculated are different compared to those in the example. I also get a warning message when I attempt the fitAB. Does anyone have any guidance as to why this might happen and how to correct it? I am using R on Kubutu in case that may be helpful. Thanks my code -- [Previously saved workspace restored] rm(list=ls(all=TRUE)) list=ls(all=TRUE) print(list) character(0) y - c(6,6,-15, 26,12,5, 11,4,4, 21,14,7, 25,18,25, + 13,6,13, 4,4,11, 17,10,17, -5,2,-5, 15,8,1, + 10,10,-11, -35,0,-14, 11,-10,-17, 12,-2,-16, -4,10,24) Nozzle - data.frame(Nozzle=rep(LETTERS[1:3], e=15),Operator=rep(letters[1:5], e=3), flowRate=y) summary(Nozzle) Nozzle Operator flowRate A:15 a:9 Min. :-35.000 B:15 b:9 1st Qu.: 0.000 C:15 c:9 Median : 7.000 d:9 Mean : 5.511 e:9 3rd Qu.: 13.000 Max. : 26.000 library(lme4) Loading required package: Matrix Loading required package: lattice fitAB - lmer(flowRate~Nozzle+(Nozzle|Operator),data=Nozzle, method=ML) Warning messages: 1: In .local(x, ..., value) : Estimated variance-covariance for factor ‘Operator’ is singular 2: In .local(x, ..., value) : nlminb returned message false convergence (8) fitB - lmer(flowRate~1+(1|Operator), data=Nozzle, method=ML) anova(fitAB, fitB) Data: Nozzle Models: fitB: flowRate ~ 1 + (1 | Operator) fitAB: flowRate ~ Nozzle + (Nozzle | Operator) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) fitB 2 359.36 362.98 -177.68 fitAB 9 362.13 378.39 -172.06 11.237 7 0.1286 -- Output from Spencer Graves example fitAB 9 359.88 376.14 -170.94 13.479 7 0.06126 Now, on a Mac OS X (using the unstable, development version of R 2.9.0, and recompiled version of lme4_0.999375-28... so caution of course!), I got this: First, the method = ML argument is deprecated and replaced by REML = TRUE/FALSE, but the doc at ?lmer does not tell exactly what is the equivalence to method = ML (and I don't know enough in this field to determine it by myself). Anyway, I tried both: fitAB - lmer(flowRate~Nozzle+(Nozzle|Operator),data=Nozzle, REML = TRUE) #Warning messages: #1: In .local(x, ..., value) : #Estimated variance-covariance for factor Operator is singular #2: In .local(x, ..., value) : #nlminb returned message false convergence (8) fitB - lmer(flowRate~1+(1|Operator), data=Nozzle, REML = TRUE) anova(fitAB, fitB) Data: Nozzle Models: fitB: flowRate ~ 1 + (1 | Operator) fitAB: flowRate ~ Nozzle + (Nozzle | Operator) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) fitB 3 361.36 366.78 -177.68 fitAB 10 362.10 380.17 -171.05 13.261 70.06601 . --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 fitAB - lmer(flowRate~Nozzle+(Nozzle|Operator),data=Nozzle, REML = FALSE) #Warning messages: #1: In .local(x, ..., value) : #Estimated variance-covariance for factor Operator is singular #2: In .local(x, ..., value) : #nlminb returned message false convergence (8) fitB - lmer(flowRate~1+(1|Operator), data=Nozzle, REML = FALSE) anova(fitAB, fitB) Data: Nozzle Models: fitB: flowRate ~ 1 + (1 | Operator) fitAB: flowRate ~ Nozzle + (Nozzle | Operator) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) fitB 3 361.36 366.78 -177.68 fitAB 10 361.96 380.03 -170.98 13.402 7 0.0629 . --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 So, I got same error messages as you. I got results closer to the one in the wiki page, BUT, I am puzzled by the degrees of freedom that are different 3/10 in my case, against 2/9 in yours and in the wiki page! Could the authors of lmer(), and/or of the wiki page, or the code cited in the wiki page (in CC) provide some explanation to this? Corrections/updates of the wiki page so that it reflects latest lmer() version would be also very much appreciated. All the best, Philippe Grosjean Just in case: R.Version() $platform [1] i386-apple-darwin8.11.1 $arch [1] i386 $os [1] darwin8.11.1 $system [1] i386, darwin8.11.1 $status [1] Under development (unstable) $major [1] 2 $minor [1] 9.0 $year [1] 2009 $month [1] 01 $day [1] 22 $`svn rev` [1] 47686 $language [1] R $version.string [1] R version 2.9.0 Under development (unstable) (2009-01-22 r47686) sessionInfo() R version 2.9.0 Under development (unstable) (2009-01-22 r47686) i386-apple-darwin8.11.1 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] tcltk stats graphics grDevices utils datasets methods [8] base other attached packages: [1] lme4_0.999375-28 Matrix_0.999375-18 lattice_0.17-20 [4] svGUI_0.9-44 svSocket_0.9-43svMisc_0.9-47 loaded via a namespace (and not attached): [1] grid_2.9.0
Re: [R] Website, book, paper, etc. that shows example plots of distributions?
Thank you very much. Thank you again regarding the suggestion below. I will give that a shot and I guess I've got my work counted out for me. I counted 45 different distributions. Is the best way to get a QQPlot of each, to run through producing a data set for each distribution and then using the qqplot function to get a QQplot of the distribution and then compare it with my data distribution? As you can tell I am not a trained statistician, so any guidance or suggested further reading is greatly appreciated. I guess I am pretty sure my data is not a normal distribution due to doing some of the empirical Goodness of Fit tests and comparing the QQplot of my data against the QQPlot of a normal distribution with the same number of points. I guess the next step is to figure out which distribution my data most closely matches. Also, I guess I could also fool around and take the log, sqrt, etc. of my data and see if it will then more closely resemble a normal distribution. Thank you again for assisting this novice data analyst who is trying to gain a better understanding of the techniques using this powerful software package. --- On Fri, 2/13/09, Gabor Grothendieck ggrothendi...@gmail.com wrote: From: Gabor Grothendieck ggrothendi...@gmail.com Subject: Re: [R] Website, book, paper, etc. that shows example plots of distributions? To: jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Friday, February 13, 2009, 5:43 AM You can readily create a dynamic display for using qqplot and similar functions in conjunction with either the playwith or TeachingDemos packages. For example, to investigate the effect of the shape parameter in the skew normal distribution on its qqplot relative to the normal distribution: library(playwith) library(sn) playwith(qqnorm(rsn(100, shape = shape)), parameters = list(shape = seq(-3, 3, .1))) Now move the slider located at the bottom of the window that appears and watch the plot change in response to changing the shape value. You can find more distributions here: http://cran.r-project.org/web/views/Distributions.html On Thu, Feb 12, 2009 at 1:04 PM, Jason Rupert jasonkrup...@yahoo.com wrote: By any chance is any one aware of a website, book, paper, etc. or combinations of those sources that show plots of different distributions? After reading a pretty good whitepaper I became aware of the benefit of I the benefit of doing Q-Q plots and histograms to help assess a distribution. The whitepaper is called: Univariate Analysis and Normality Test Using SAS, Stata, and SPSS* , (c) 2002-2008 The Trustees of Indiana University Univariate Analysis and Normality Test: 1, Hun Myoung Park Unfortunately the white paper does not provide an extensive amount of example distributions plotted using Q-Q plots and histograms, so I am curious if there is a portfolio-type website or other whitepaper shows examples of various types of distributions. It would be helpful to see a bunch of Q-Q plots and their associated histograms to get an idea of how the distribution looks in comparison against the Gaussian. I think seeing the plot really helps. Thank you for any insights. [[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] (no subject)
Very quick one please team; How do I return the number of possible unique subsets in a data set (not combinations i.e. not (1,2,3,4) and (4,3,2,1)) please ? e.g. In a list of integers 1 to 12, there is 495 sets with 4 elements in regards glenn [[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] (no subject)
do you mean: combn(12, 4) Best, Dimitris glenn wrote: Very quick one please team; How do I return the number of possible unique subsets in a data set (not combinations i.e. not (1,2,3,4) and (4,3,2,1)) please ? e.g. In a list of integers 1 to 12, there is 495 sets with 4 elements in regards glenn [[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. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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] Website, book, paper, etc. that shows example plots of distributions?
You might also want to look at the idealized situation: library(playwith) library(sn) playwith(qqnorm(qsn(1:99/100, shape = shape)), parameters = list(shape = seq(-3, 3, .1))) On Fri, Feb 13, 2009 at 6:43 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: You can readily create a dynamic display for using qqplot and similar functions in conjunction with either the playwith or TeachingDemos packages. For example, to investigate the effect of the shape parameter in the skew normal distribution on its qqplot relative to the normal distribution: library(playwith) library(sn) playwith(qqnorm(rsn(100, shape = shape)), parameters = list(shape = seq(-3, 3, .1))) Now move the slider located at the bottom of the window that appears and watch the plot change in response to changing the shape value. You can find more distributions here: http://cran.r-project.org/web/views/Distributions.html On Thu, Feb 12, 2009 at 1:04 PM, Jason Rupert jasonkrup...@yahoo.com wrote: By any chance is any one aware of a website, book, paper, etc. or combinations of those sources that show plots of different distributions? After reading a pretty good whitepaper I became aware of the benefit of I the benefit of doing Q-Q plots and histograms to help assess a distribution. The whitepaper is called: Univariate Analysis and Normality Test Using SAS, Stata, and SPSS* , (c) 2002-2008 The Trustees of Indiana University Univariate Analysis and Normality Test: 1, Hun Myoung Park Unfortunately the white paper does not provide an extensive amount of example distributions plotted using Q-Q plots and histograms, so I am curious if there is a portfolio-type website or other whitepaper shows examples of various types of distributions. It would be helpful to see a bunch of Q-Q plots and their associated histograms to get an idea of how the distribution looks in comparison against the Gaussian. I think seeing the plot really helps. Thank you for any insights. [[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] copy directory command
Hi, I was trying to copy a directory from one location to another. Is there a command to do this (similar to the file.copy command)? thanks! [[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] directory manipulation
Hi all, I was trying to copy a directory from one location to another. Is there a command (similar to file copy command) that will let me do this? thanks. [[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] Efficent way to create an nxn upper triangular matrix of one's
The other solutions offered are perfectly workable. Here is a strategy that is generalizable to other matrix designs (and on checking the source of upper.tri and lower.tri, it's not surprising that they use precisely the same strategy): n - 9 dm - matrix(0, nrow=n, ncol=n) dm[col(dm) = row(dm)] - 1 If you wanted only upper off-diagonal -1's, for instance, you could use instead: dm[col(dm) == (row(dm)+1) ] - -1 -- David Winsemius On Feb 11, 2009, at 4:22 PM, Dale Steele wrote: The code below create an nxn upper triangular matrix of one's. I'm stuck on finding a more efficient vectorized way - Thanks. --Dale n - 9 data - matrix(data=NA, nrow=n, ncol=n) data for (i in 1:n) { data[,i] - c(rep(1,i), rep(0,n-i)) } data __ 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] Making plot with sub-X values
Hello I have a big dataset where i have pulled out some periods of time acording to a herd-number (see below): CHR_NR DATO_TEST SALMO_INDEX didiffdatoperiode 113772003-06-20 7.929 113772003-09-01 4.359 113772004-02-24 5.178 where the variable 'diffdatoperiode' is the period in days and represents the x-value and 'CHR_NR' is the herd number. These periods corresponds to a sum of periods in the variable 'diffdato1', and each of these periods have an y-value represented by the variable 'SALMO_INDEX': CHR_NR DATO_TEST SALMO_INDEX diffdatodiffdato1 113772003-05-2217.0 14 15 113772003-06-0618.8 15 14 113772003-07-0420.1 14 17 113772003-07-2132.9 17 14 113772003-08-0419.9 14 14 113772003-08-1810.5 14 14 113772003-12-0820.5 27 29 113772004-01-0628.6 298 113772004-01-1428.6 8 8 113772004-01-2219.0 8 7 113772004-01-2919.0 7 7 113772004-02-0514.4 7 7 113772004-02-1214.4 712 So, 29 = 15 +14, 59 = 17 + 14 + 14 +14 and 78 = 29 + 8 + 8+ +7 +7 +7 + 12. So i need a plot where the y-axis is the 'SALMO_INDEX' corresponding to the values in 'diffdato1', and the x-axis is the 'diffdato' and 'difdato1' at the same time. So the periods in 'diffdato1' is kind of like sub-x values to the periods in 'diffdato'. So the plot should be created like if the three values 29, 59 and 78 each had a x-axis, but together in one x-axis. It's a little bit hard to expalin. Hope you can help me -- View this message in context: http://www.nabble.com/Making-plot-with-%22sub%22-X-values-tp21996730p21996730.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] Aggregrate function
Hi again, Thanks a lot for all the suggestions. It will take me a little bit to wrap my head around to understand what is what, though! This will help me quite a bit. One difference in the result output between you're solution and Mark's solution is this: loc sp tot L1L1 b 60 L2.5 L2 d 25 L2.7 L2 e 25 L3L3 b 68 And Mark's solution: loc sp tot L1 L1 b 60 L2 L2 d,e 25 L3 L3 b 68 I will probably use both type of solutions depending what else i need to do with the data. Thank you all for your help, Monica Date: Thu, 12 Feb 2009 14:05:44 -0800 From: spec...@stat.berkeley.edu To: pisican...@hotmail.com CC: christos.hat...@nuverabio.com; r-help@r-project.org; markle...@verizon.net Subject: Re: [R] Aggregrate function Monica - Here's a more compact version of the same idea: do.call(rbind,by(xveg,xveg['loc'],function(x)x[x$tot == max(x$tot),])) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Thu, 12 Feb 2009, Monica Pisica wrote: Hi, Thanks for the solution. Mark Leeds sent me privately a very similar solution. My next question to him was: Suppose that for a certain location 2 species have the same maximum total ... (there are ties in the data for a particular location). How do i get all species that have that max. total?? For this case i have changed the tot as follows: tot - c(20, 60, 40, 15, 25, 15, 25, 20, 68, 32) His sollution is (and does work): temp - lapply(split(xveg,loc), function(.df) { maxindices - which(.df$tot == .df$tot[which.max(.df$tot)]) data.frame(loc=.df$loc[1],sp=paste(.df$sp[maxindices],collapse=,),tot=max(.df$tot)) }) result - do.call(rbind,temp) print(result) Thanks so much again, Monica From: christos.hat...@nuverabio.com To: pisican...@hotmail.com; r-help@r-project.org Subject: RE: [R] Aggregrate function Date: Thu, 12 Feb 2009 15:56:38 -0500 I don't have an easy solution with aggregate, because the function in aggregate needs to return a scalar. But the following should work: do.call(rbind, lapply(split(xveg, xveg$loc), function(x) x[which.max(x$tot), ])) loc sp tot L1 L1 b 60 L2 L2 e 30 L3 L3 b 68 -Christos -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Monica Pisica Sent: Thursday, February 12, 2009 1:58 PM To: R help project Subject: [R] Aggregrate function Hi, I have to recognize that i don't fully understand the aggregate function, but i think it should help me with what i want to do. xveg is a data.frame with location, species, and total for the species. Each location is repeated, once for every species present at that location. For each location i want to find out which species has the maximum total ... so i've tried different ways to do it using aggregate. loc - c(rep(L1, 3), rep(L2, 5), rep(L3, 2)) sp - c(a, b, c, a, d, b, e, c, b, d) tot - c(20, 60, 40, 15, 25, 10, 30, 20, 68, 32) xveg - data.frame(loc, sp, tot) result desired: L1 b L2 e L3 b sp_maj - aggregate(xveg[,2], list(xveg[,1], function(x) levels(x)[which.max(table(x))]) This is wrong because it gives the first species name in each level of location, so i get a, a, b, as species instead of b, e, b. I've tried other few aggregate commands, all with wrong results. I will appreciate any help, Thanks, Monica _ the go. __ 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. _ of your life. __ 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. _ . 50F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008 __ 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] Difference MNP-package and rmnpGibbs from bayesm-package
Hi all, For my research I have to use a Multinomial Probit model. I saw that there are two packages, that include a method to estimate my parameters. The first one is the MNP-package of Imai and van Dyk. The second one is part of the bayesm-package of Rossi. The results for both packages are not the same using the same data. Does anybody know what the difference is between these two approaches? Kind regards, Tryntsje __ 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] variable values
Step 1: Read the R-FAQ 7.31: Step 2: Ask yourself whether it is likely that such a small value can be sensibly distinguished from zero using a program that stores values in double precision. Step 3: Consider alternate methods, perhaps logarithms or programs that are equipped to deal with arbitrary precision. There have been threads on such strategies. I got on-topic results with an r-search on : very small log probabilit* -- David Winsemius On Feb 12, 2009, at 2:09 PM, Tim Smith wrote: Hi all, I was working with some probabilities and wanted to store some small values. For example: x = 2e-250 x [1] 2e-250 y = 2e-300 y [1] 2e-300 z = 2e-350 z [1] 0 Is there any way to store a small value (e.g. 2e-350) in R? thanks! [[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] Looping multiple output values to dataframe
?list files ... in particular the pattern argument -- David Winsemius On Feb 12, 2009, at 3:38 PM, Stropharia wrote: Thanks a lot Levi. Your code was much shorter and more elegant. With a few minor alterations I got this (see below) to work. Does anyone know if there is a way to automate getting only the csv filenames in a folder (rather than the whole file path)? Or to automate extracting the file names from the file paths, once they have been extracted using Sys-glob? Thanks. Steve # START R-CODE--- filenames - Sys.glob(/Users/Desktop/Test/*.csv) # get names of files to process # use * to get all variables - data.frame(1:length(filenames)) # preallocate assuming multiple values from each file # creates a dataframe with the same length of rows as the number of .csv files to process docalc - function(filenames){ input - read.csv(filenames, header=TRUE, na.strings=NA) attach(input) result.A - x[2]*y[1] result.B - y[2]-x[1] result.C - x[3]+y[1] results - c(result.A, result.B, result.C) # concatenate result vectors names(results) - c(ResultA, ResultB, ResultC) # set names for result vectors return(results) } variables - t(sapply(filenames, docalc)) # transpose and sapply filenames # export to csv file write.csv(variables, file=/Users/Desktop/Test.csv) # END R-CODE--- Levi Waldron-3 wrote: Stropharia wrote: # START R-CODE--- filenames - Sys.glob(/Users/Desktop/Test/*.csv) # get names of files to process # use * to get all variables - data.frame(1:length(filenames)) # preallocate assuming multiple values from each file # creates a dataframe with the same length of rows as the number of .csv files to process for (i in seq_along(filenames)){ input - read.csv(filenames[i], header=TRUE, na.strings=NA) data.frame(input) attach(input) result.A - x[2]*y[1] result.B - y[2]-x[1] result.C - x[3]+y[1] results - c(result.A, result.B, result.C) # concatenate result vectors variables[i] - results } variables - as.data.frame(t(as.matrix(variables))) # turn result vectors into a matrix, then transpose it and output as a data frame # add column and row names c.names - c(ResultA, ResultB, ResultC) # set names for result vectors colnames(variables) - c.names rownames(variables) - filenames # export to csv file write.csv(variables, file=/Users/Desktop/Test.csv) # END R-CODE--- I think something like this should work better: docalc - function(thisfile){ input - read.csv(filenames[i], header=TRUE, na.strings=NA) attach(input) result.A - x[2]*y[1] result.B - y[2]-x[1] result.C - x[3]+y[1] results - c(result.A, result.B, result.C) # concatenate result vectors names(results) - c(ResultA, ResultB, ResultC) return(results) } variables - sapply(filenames,docalc) -- Levi Waldron post-doctoral fellow Jurisica Lab, Ontario Cancer Institute Division of Signaling Biology IBM Life Sciences Discovery Centre TMDT 9-304D 101 College Street Toronto, Ontario M5G 1L7 (416)581-7453 __ 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. -- View this message in context: http://www.nabble.com/Looping-multiple-output-values-to-dataframe-tp21981108p21984499.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] R crashes when using the RODBC Package
Hi, Ive written some code that fetches data from an Access Database (2003), processes the data, then saves the modified data back into a table in the Access database. It works if I only pass through the code once, but if I put a loop around the code so that I fetch data from a different source table, and then save it again to a different destination table, the code crashes. It is either the final sqlQuery or sqlSave queries. I have no idea why it is crashing. As an aside, I also have trouble with the odbcCloseAll() command R tends to crash with that, also. Im running this on Windows XP, Access 2003, R version 2.7.2 Any insights would be greatly appreciated! The condensed version of the code is below. # import the libraries library(RODBC) # Close any existing connections odbcCloseAll() # Connect to database channel - odbcConnect(database, uid=, pwd=) for ( i in 1:2 ) { # 1. Weekly 2. Monthly if (i == 1) { bWeekly - TRUE } else { bWeekly - FALSE } # Get Prices if ( bWeekly ) { tblName - qryDataWeekly_Crosstab } else { tblName - qryDataMonthly_Crosstab } prices - sqlFetch(channel, tblName, colnames = FALSE, rownames = TRUE) # Get Weightings sql - SELECT BbSecurity, Weighting FROM qryWeightingsUse sWeights - sqlQuery(channel, sql) # Copy Data to Database if ( bWeekly ) { tblName - tblIndexWeekly } else { tblName - tblIndexMonthly } sqlQuery(channel, paste(DELETE * FROM , tblName)) sqlSave(channel, indexDf, tablename = tblName, append=TRUE, rownames=FALSE) } odbcClose(channel) __ 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] directory manipulation
Tim Smith wrote: Hi all, I was trying to copy a directory from one location to another. Is there a command (similar to file copy command) that will let me do this? I suggest to make a system() (or shell, if you are under Windows) call to the OS in order to copy recursively. Uwe Ligges thanks. [[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] Write and Load functions from an external file
Hi All, Would be grateful,if anyone can answer my queries. I need to share code. For example, if I am working in C/C++, I would put some function declarations in .h files that you would include. In PHP, I would create files with the common functions in them and then include() them. So far, I haven't been able to figure out what the standard practice is in R. The two options are: 1. Write everything in one file. No sharing of functions. 2. Write libraries - but you *have to package it* first to use it. Neither is a good option. how you I share functions across two scripts? there is source() But are there any other way? For example, in python, what I do is create common functions in a separate file (say, called A), use those functions from file B by including it like I would any other library. Then when I'm ready to 'release' it, I can package the library and the script... I did find something:- http://www.ma.hw.ac.uk/~stan/R/Rnotes.pdfhttp://www.ma.hw.ac.uk/%7Estan/R/Rnotes.pdfsays :-- To create and edit functions, use the (built-in) R function edit. (As usual, type ?edit at the command prompt for details|see Section 10.) Alternatively the function source|also available via the File menu|can be used to input lengthy function denitions from an externally edited le. (The function dump will write an existing function denition to a file.) But then source() also ,not only loads but parses the file too. https://stat.ethz.ch/pipermail/r-help/2007-October/142938.html You can save one or more functions and datasets to a file (see ?save) then on starting another session attach that file (see ?attach). The process is like:--- foo - function(x) mean(as.numeric(x), trim = 0.3) save(foo, file = myproject/rfunctions/saved.rda) then, when starting a new session, use attach(myproject/rfunctions/saved.rda) The .rda extension on the filename is commonly used for saved R data sets but you can also have function definitions in a saved file. Are these the only ways,and the best ways,to do what I want? *-- Thanks Moumita* -- Thanks Moumita [[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] copy directory command
On Fri, 13 Feb 2009, Tim Smith wrote: I was trying to copy a directory from one location to another. Is there a command to do this (similar to the file.copy command)? file.copy() does this in the development version of R. Most people use system(paste(cp -r, from, to)) in earlier versions (needs a Unix-alike or Rtools). [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] Website, book, paper, etc. that shows example plots of distributions?
This is probably the right time to issue a warning about the error of making transformations on the dependent variable before doing your analysis. The classic error that newcomers to statistics commit is to decide that they want to make their data normal. The assumptions of most regression methods is that the *errors* need to have the desired relationship between means and variance, and not that the dependent variable be normal. Many times the apparent non-normality will be explained or captured by the regression model. Other methods of modeling non-linear dependence are also available. I found Harrell's book Regression Modeling Strategies to be an excellent source for alternatives. My copy of VR's MASS is only the second edition but chapters 5 6 in that edition on linear models also had examples of using QQ plots on residuals. Checking that text's website I see that chapters 6 at least is probably similar. They include the scripts from their chapters along with the MASS package (installed as part of the VR bundle). My copy is entitled ch06.r and resides in the scripts subdirectory: /Library/Frameworks/R.framework/Versions/2.8/Resources/library/MASS/ scripts/ch06.R -- David Winsemius On Feb 13, 2009, at 8:11 AM, Jason Rupert wrote: Thank you very much. Thank you again regarding the suggestion below. I will give that a shot and I guess I've got my work counted out for me. I counted 45 different distributions. Is the best way to get a QQPlot of each, to run through producing a data set for each distribution and then using the qqplot function to get a QQplot of the distribution and then compare it with my data distribution? As you can tell I am not a trained statistician, so any guidance or suggested further reading is greatly appreciated. I guess I am pretty sure my data is not a normal distribution due to doing some of the empirical Goodness of Fit tests and comparing the QQplot of my data against the QQPlot of a normal distribution with the same number of points. I guess the next step is to figure out which distribution my data most closely matches. Also, I guess I could also fool around and take the log, sqrt, etc. of my data and see if it will then more closely resemble a normal distribution. Thank you again for assisting this novice data analyst who is trying to gain a better understanding of the techniques using this powerful software package. --- On Fri, 2/13/09, Gabor Grothendieck ggrothendi...@gmail.com wrote: From: Gabor Grothendieck ggrothendi...@gmail.com Subject: Re: [R] Website, book, paper, etc. that shows example plots of distributions? To: jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Friday, February 13, 2009, 5:43 AM You can readily create a dynamic display for using qqplot and similar functions in conjunction with either the playwith or TeachingDemos packages. For example, to investigate the effect of the shape parameter in the skew normal distribution on its qqplot relative to the normal distribution: library(playwith) library(sn) playwith(qqnorm(rsn(100, shape = shape)), parameters = list(shape = seq(-3, 3, .1))) Now move the slider located at the bottom of the window that appears and watch the plot change in response to changing the shape value. You can find more distributions here: http://cran.r-project.org/web/views/Distributions.html On Thu, Feb 12, 2009 at 1:04 PM, Jason Rupert jasonkrup...@yahoo.com wrote: By any chance is any one aware of a website, book, paper, etc. or combinations of those sources that show plots of different distributions? After reading a pretty good whitepaper I became aware of the benefit of I the benefit of doing Q-Q plots and histograms to help assess a distribution. The whitepaper is called: Univariate Analysis and Normality Test Using SAS, Stata, and SPSS* , (c) 2002-2008 The Trustees of Indiana University Univariate Analysis and Normality Test: 1, Hun Myoung Park Unfortunately the white paper does not provide an extensive amount of example distributions plotted using Q-Q plots and histograms, so I am curious if there is a portfolio-type website or other whitepaper shows examples of various types of distributions. It would be helpful to see a bunch of Q-Q plots and their associated histograms to get an idea of how the distribution looks in comparison against the Gaussian. I think seeing the plot really helps. Thank you for any insights. [[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
[R] Distinguishing variables from functions with the same name
guRus: I have a variable beta as an argument to R's beta function. So essentially I have a case of beta(alpha, beta). What surprises me is that R doesn't barf on this stupid programming practice. R gets the right answer. How does R know beta the variable from beta the function? Joseph F. Lucke Senior Statistician Research Institute on Addictions University at Buffalo SUNY [[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] equivalent to SAS genmod code in R?
Hello, I have to run a general linear mixed model which looks at 2 dependent variables at the same time (var1 divided by var2). I have tryed to search for such a kind of model structure but since I just started using R my search was not successful. Especielly since I only have an old SAS GENMOD code structure from my project supervisor as an indication. My question is no, does there exist a code in R which is equivalent to the SAS code below? PROC GENMOD DATA=X; CLASS FLH; MODEL BS/OCCUPANCY = distcrop distfor flh distcrop*flh /D=B LINK=LOGIT TYPE3; RUN; Thanks for answers! Nick [[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] copy directory command
Hi Tim, This is what i usually try and do (see ?file.copy) ## R Start... src.dir - 'PFO-SBS001\\Redirected\\tonyb\\Desktop\\folderA\\' dest.dir - 'PFO-SBS001\\Redirected\\tonyb\\Desktop\\folderB\\' file.names - dir(src.dir) sapply(file.names, function(x) { + file.copy(from=paste(src.dir, x, sep=''), + to=paste(dest.dir, x, sep=''), + overwrite = FALSE) }) example.txt TRUE ## R end. Hope that helps a like, Tony On 13 Feb, 12:42, Tim Smith tim_smith_...@yahoo.com wrote: Hi, I was trying to copy a directory from one location to another. Is there a command to do this (similar to the file.copy command)? thanks! [[alternative HTML version deleted]] __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ 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] select on letter
one way is: index - c(1, 2, 3) let - c(CCTTGGAA, NNTTGGAAT, AACCTTNN) z - data.frame(index, let) index[-grep(N, let)] # or z[-grep(N, let), ] I hope it helps. Best, Dimitris naomi.duijveste...@ipg.nl wrote: Hi, I was wondering if anybody can help me. In the small data set below I would like to select the index which doesn't contain the letter 'N' in the variable 'letters'. How can I discard these rows when the letter has a different position everytime (but the same letter for the whole column)? index-c(1,2,3) letters-c(CCTTGGAA, NNTTGGAAT, AACCTTNN) z-data.frame(index,letters) index letters 1 1 CCTTGGAA 2 2 NNTTGGAAT 3 3 AACCTTNN Thanks in advance! Naomi __ 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 Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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] Problems with Histogram
Hello Currently i'm working on a paper for my study and, on advice of my tutor, i'm using R. But now i'm stuck on something. I've used the bootstrap method to determine if a found value was significant. Lets say this found value is x, the collection of random samples is y (n=1e+06) I've compared x to y and found that x is smaller then 963482 samples of y (so p=0.037) I wanted to show this in a graph and figured a histogram would suit best. But I dont get what is expected to get. http://www.nabble.com/file/p21998165/example.bmp What I expect http://www.nabble.com/file/p21998165/found.jpg What I found Can someone please help me with finding a way to make this significance visable in some sort of graph? Thanks a lot! Jeroen -- View this message in context: http://www.nabble.com/Problems-with-Histogram-tp21998165p21998165.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] odfWeave prettyR
Hello, I've been trying to use odfWeave and prettyR packages to create documents with both text and graphs, but so far I haven't been very lucky... With the function R2html () in prettyR package, when I try to use a source file, which works perfectly if I run it directly form R using source(file), it works for the first part and then it makes a mess, i guess something might be wrong in my formatting or the function R2html doesnt recognize the function if() because i get errors like this one Error in parse(cmdcon) : unexpected 'if' at 1: for (i in 1:length(resultList)){tempSummary - try(summary(resultList[[i]]), silent = TRUE)if everytime there is a if. I tried with the function htmlize and it works for the text (like summaries) but I didn't manage to get the plots on the html file I tried to use the funcion HTMLgraph but I couldn't understand what it does and what its arguments are (listfile, graphfile) With odfWeave I tried to download it, and saw that it depends on XML package. If I try to load the odfWeave package with library(odfWeave) I get this message: Loading: XML Error: package 'XML' not loaded Warning message: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : there is no 'XML' package The problem is that on the CRAN web site the XML package is not available for windows... Any suggestions? Thanks and sorry for bothering you all again with this subject... __ 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] Write and Load functions from an external file
Moumita Das wrote: Hi All, Would be grateful,if anyone can answer my queries. I need to share code. For example, if I am working in C/C++, I would put some function declarations in .h files that you would include. In PHP, I would create files with the common functions in them and then include() them. So far, I haven't been able to figure out what the standard practice is in R. The two options are: 1. Write everything in one file. No sharing of functions. 2. Write libraries - but you *have to package it* first to use it. What you probably want is 2: Write a *package*. Packaging it does not take ages once you have tried it ... Uwe Ligges Neither is a good option. how you I share functions across two scripts? there is source() But are there any other way? For example, in python, what I do is create common functions in a separate file (say, called A), use those functions from file B by including it like I would any other library. Then when I'm ready to 'release' it, I can package the library and the script... I did find something:- http://www.ma.hw.ac.uk/~stan/R/Rnotes.pdfhttp://www.ma.hw.ac.uk/%7Estan/R/Rnotes.pdfsays :-- To create and edit functions, use the (built-in) R function edit. (As usual, type ?edit at the command prompt for details|see Section 10.) Alternatively the function source|also available via the File menu|can be used to input lengthy function denitions from an externally edited le. (The function dump will write an existing function denition to a file.) But then source() also ,not only loads but parses the file too. https://stat.ethz.ch/pipermail/r-help/2007-October/142938.html You can save one or more functions and datasets to a file (see ?save) then on starting another session attach that file (see ?attach). The process is like:--- foo - function(x) mean(as.numeric(x), trim = 0.3) save(foo, file = myproject/rfunctions/saved.rda) then, when starting a new session, use attach(myproject/rfunctions/saved.rda) The .rda extension on the filename is commonly used for saved R data sets but you can also have function definitions in a saved file. Are these the only ways,and the best ways,to do what I want? *-- Thanks Moumita* __ 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] lists on a script
Dear R experts, I have a problem with a function I wrote. The fuction looks like this: series-function(x,s){ foo-list(); ind3-integer(); for (j in diff){ for (i in 1:(n-12)){ if (!(x[i,j]==0)!(x[i+1,j]==0)!(x[i+2,j]==0)!(x[i+3,j]==0)!(x[i+4,j]==0)!(x[i+5,j]==0)!(x[i+6,j]==0) !(x[i+7,j]==0)!(x[i+8,j]==0)!(x[i+9,j]==0)!(x[i+10,j]==0)!(x[i+11,j]==0)!(x[i+12,j]==0)){cont-i; break} else cont-i }; if (cont92) {ind3-c(ind3,j); foo[[j]]-NULL;next} else { año-floor(cont/12); mes-(cont-12*año); a-(1999+año); foo[[j]]-ts(x[(cont):nrow(x),j],frequency=12,start=c(a,mes))}}; That's the first part, then ind4-integer(); for (m in setdiff(diff,ind3)){ nn-length(foo[[m]]); prinf-median(foo[[m]][1:12]); prsup-median(foo[[m]][(nn-12):nn]); if (xor((prsup/prinf)s,(prinf/prsup)s)) {ind4-c(ind4,m)}}; crit3-ind4; So far so good (aparently). I mean, the crit3 set it's ok. But, the next paragraph: ind5-integer(); for (k in ind4){ print(k);#to know when the error happens dife-numeric(); l-length(foo[[k]]); print(l); print(foo[[K]]) #to know why the error happens for (i in 9:(l-8)){ minf-median(foo[[k]][(i-8):(i-1)]); msup-median(foo[[k]][(i+1):(i+8)]); dife[i]-abs(ceiling((msup-minf)))}; st-which(dife==max(abs(dife),na.rm=T)); if (length(st)1){st-st[length(st)]}; if ((l-st)24){ind5-c(ind5,m);foo[[k]]-NULL} else{ agno-(start(foo[[k]])[1]+floor(st/12)); mes-(start(foo[[k]])[2]+ (st-12*floor(st/12))); if (mes12){ agno-(agno+1);mes-(mes%%12)}; ss-foo[[k]][(st+1):l]; foo[[k]]-ts(ss,frequency=12,start=c(agno,mes))}} When the code access the series foo[[k]] it does not match the series foo[[k]] outside the loop. I know this because the I've checked it out. I've noticed this because the function throws me an error that says : Error en median.default(foo[[k]][(i - 8):(i - 1)]) : need numeric data The error occurs when m=550, because IN the loop foo[[550]]=NULL, but outside the loop foo[[550]] is a normal time series. I know this because I printed foo[[550]] before entering the loop. My surprise did not stop there, because from the second index on none of the internal loop series match the outer loop series... Please don't ask me why I'm doing this, I just need it solved. Please someone help me!!! [[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] Distinguishing variables from functions with the same name
See ?get and try: sin - 1 get(sin, mode = numeric) get(sin, mode = function) On Fri, Feb 13, 2009 at 10:20 AM, jlu...@ria.buffalo.edu wrote: guRus: I have a variable beta as an argument to R's beta function. So essentially I have a case of beta(alpha, beta). What surprises me is that R doesn't barf on this stupid programming practice. R gets the right answer. How does R know beta the variable from beta the function? Joseph F. Lucke Senior Statistician Research Institute on Addictions University at Buffalo SUNY [[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] Problem with loading rJava in R
Thank you everyone for the help. Dieter's advice resolved the issue. charis Dieter Menne wrote: charis charis at kaskiris.com writes: Thank you for helping. I am running the 32-bit version of R on a 64-bit Windows XP machine. After reinstalling the rJava package I started getting a windows pop up with the message: Rgui.exe - Unable to Locate Component This application has failed to start because jvm.dll was not found. Re-installing the application may fix this problem I have installed the 32-bit version of Java, added the jvm.dll to the Windows PATH environment variable I have also reinstalled R. http://markmail.org/thread/mtvbuieprgbsut4h I thought we had tracked this down; it occurs when you have a path that approaches 1024 character. Duncan Murdoch has made the require changes, but the changes are not in the package, so you have to download the development version (r47752 above). http://cran.at.r-project.org/bin/windows/base/rdevel.html Works without problems for me now. Dieter __ 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. -- View this message in context: http://www.nabble.com/Problem-with-loading-rJava-in-R-tp21968371p21999120.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] select on letter
You really should not assign a new value to letters since it is a very useful constant vector that allows working with lowercase letters. Notice that Domitris did not copy your code exactly. Next time you start R type letters at the R prompt. You cannot do so now, since you overwrote that constant with your own construction. LETTERS would still work. -- David Winsemius On Feb 13, 2009, at 10:18 AM, naomi.duijveste...@ipg.nl wrote: Hi, I was wondering if anybody can help me. In the small data set below I would like to select the index which doesn't contain the letter 'N' in the variable 'letters'. How can I discard these rows when the letter has a different position everytime (but the same letter for the whole column)? index-c(1,2,3) letters-c(CCTTGGAA, NNTTGGAAT, AACCTTNN) z-data.frame(index,letters) index letters 1 1 CCTTGGAA 2 2 NNTTGGAAT 3 3 AACCTTNN Thanks in advance! Naomi __ 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] Distinguishing variables from functions with the same name
On Fri, Feb 13, 2009 at 10:47 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: See ?get and try: Interesting. I hadn't paid attention to the 'mode' argument before. Where would it be advisable to use anything but mode='any' or mode='function'? -s __ 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] analogue to lines commant in plot when using boxplot
No example and I find the specification unclear, but perhaps you can follow the steps outlined in this earlier posting to get closer what you want. or, as always, provide a base example and description of what is needed. http://finzi.psych.upenn.edu/R/Rhelp08/archive/154176.html -- David Winsemius On Feb 12, 2009, at 3:06 PM, Dimitri Liakhovitski wrote: Hello! I am finding dotplot really useful in generating the graph I need. I was able to make it work for one vector (data series in Excel language). However, I want to add the secon line to my graph - based on another vector (data series). What command should I use for this purpose in dotplot? I am looking for a subcommand that would be analogous to the subcommand lines when one is using plot. Thanks a lot! -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with Histogram
One possibility is something along the lines of: plot(density(bootstraps)) abline(v=original.value) Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of The R Inferno and A Guide for the Unwilling S User) TomPoes wrote: Hello Currently i'm working on a paper for my study and, on advice of my tutor, i'm using R. But now i'm stuck on something. I've used the bootstrap method to determine if a found value was significant. Lets say this found value is x, the collection of random samples is y (n=1e+06) I've compared x to y and found that x is smaller then 963482 samples of y (so p=0.037) I wanted to show this in a graph and figured a histogram would suit best. But I dont get what is expected to get. http://www.nabble.com/file/p21998165/example.bmp What I expect http://www.nabble.com/file/p21998165/found.jpg What I found Can someone please help me with finding a way to make this significance visable in some sort of graph? Thanks a lot! Jeroen __ 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] tapply bug? - levels of a factor in a data frame after tapply are intermixed
Hello! I have encountered a really weird problem. Maybe you've encountered it before? I have a large data frame importances. It has one factor ($A) with 3 levels: 3, 9, and 15. $B is a regular numeric variable. Below I am picking a really small sub-frame (just 3 rows) based on indices. indices were chosen so that all 3 levels of A are present: indices=c(14329,14209,14353) test=data.frame(yy=importances[[B']][indices],xx=importances[[A]][indices]) Here is what the new data frame test looks like: yyxx 1 -0.009984006 9 2 -2.339904131 3 3 -0.008427385 15 Here is the structure of test: str(test) 'data.frame': 3 obs. of 2 variables: $ yy: num -0.00998 -2.3399 -0.00843 $ xx: Factor w/ 3 levels 3,9,15: 2 1 3 Notice - the order of factor levels for xx is not 1 2 3 as it should be but 2 1 3. How come? Or also look at this: test$xx [1] 9 3 15 Levels: 3 9 15 Same thing. Do you know what might be the reason? Thank you very much! -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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] odfWeave prettyR
lauramorgana at bluewin.ch lauramorgana at bluewin.ch writes: Hello, I've been trying to use odfWeave and prettyR packages to create documents with both text and graphs, but so far I haven't been very lucky... ... library(odfWeave) I get this message: Loading: XML Error: package 'XML' not loaded The problem is that on the CRAN web site the XML package is not available for windows... I just checked, and it is available for Windows from my mirror (Austria) and from ETH (assuming you are CH). However, there was a problem when using XML with Umlauts and the like in a more recent version of XML on Windows (and on Windows only). So after you installed XML (a must), first try with the odfWeave standard examples. If these work, add an äü somewhere, try again. Dieter __ 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] need help with errors in betareg analysis
Hi I'm trying to fit a model in betareg and I'm getting errors, but have no idea what they mean or how to solve them. Does anyone have experience with this? model - betareg(ACT ~ ST*SoilT, data = actDL_F) Warning messages: 1: In sqrt(W) : NaNs produced 2: In sqrt(W) : NaNs produced 3: In sqrt(1 + phihat) : NaNs produced data summaries don't give any na's or problems I can see summary(actDL_F$ACT) Min. 1st Qu.Median Mean 3rd Qu. Max. 0.0006227 0.0505600 0.2163000 0.2643000 0.4084000 0.9994000 summary(actDL_F$ST) Min. 1st Qu. MedianMean 3rd Qu.Max. 8.085 29.560 34.760 33.870 39.430 49.610 summary(actDL_F$SoilT) Min. 1st Qu. MedianMean 3rd Qu.Max. 17.42 20.95 24.18 24.26 27.21 31.19 Thanks Ken -- View this message in context: http://www.nabble.com/need-help-with-errors-in-betareg-analysis-tp22000860p22000860.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] tapply bug? - levels of a factor in a data frame after tapply are intermixed
on 02/13/2009 11:09 AM Dimitri Liakhovitski wrote: Hello! I have encountered a really weird problem. Maybe you've encountered it before? I have a large data frame importances. It has one factor ($A) with 3 levels: 3, 9, and 15. $B is a regular numeric variable. Below I am picking a really small sub-frame (just 3 rows) based on indices. indices were chosen so that all 3 levels of A are present: indices=c(14329,14209,14353) test=data.frame(yy=importances[[B']][indices],xx=importances[[A]][indices]) Here is what the new data frame test looks like: yyxx 1 -0.009984006 9 2 -2.339904131 3 3 -0.008427385 15 Here is the structure of test: str(test) 'data.frame': 3 obs. of 2 variables: $ yy: num -0.00998 -2.3399 -0.00843 $ xx: Factor w/ 3 levels 3,9,15: 2 1 3 Notice - the order of factor levels for xx is not 1 2 3 as it should be but 2 1 3. How come? Or also look at this: test$xx [1] 9 3 15 Levels: 3 9 15 Same thing. Do you know what might be the reason? Thank you very much! The output of str() is showing you the factor levels of test$xx, followed by the internal integer codes for the three actual values of test$xx, 9, 3, and 15: str(test$xx) Factor w/ 3 levels 3,9,15: 2 1 3 levels(test$xx) [1] 3 9 15 as.integer(test$xx) [1] 2 1 3 9 is the second level, hence the 2 3 is the first level, hence the 1 15 is the third level, hence the 3. No problems, just clarification needed on what you are seeing. Note that you do not reference anything above regarding tapply() as per your subject line, though I suspect that I have an idea as to why you did... HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Distinguishing variables from functions with the same name
G'day Stavros, On Fri, 13 Feb 2009 11:11:28 -0500 Stavros Macrakis macra...@alum.mit.edu wrote: On Fri, Feb 13, 2009 at 10:47 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: See ?get and try: Interesting. I hadn't paid attention to the 'mode' argument before. Where would it be advisable to use anything but mode='any' or mode='function'? I guess the answer to this question is more often than not in the source. :) On my machine: ber...@berwin-nus1:/opt/src/R-devel-src/src/library$ find . -name *.R -type f | xargs grep get( \ | grep mode | grep -v function | grep -v all ./tools/R/QC.R:al - get(al, envir = code_env, mode = list) ./tools/R/QC.R:al - get(al, envir = ns_env, mode = list) ./tools/R/QC.R:al - get(al, envir = data_env, mode = list) ./utils/R/Sweave.R:syntax - get(syntax, mode=list) ./utils/R/Sweave.R:syntax - get(sname, mode = list) ./utils/R/Sweave.R:s - get(sname, mode=list) ./utils/R/str.R:str(get(nam, envir = E, mode = M), ./stats/R/model.tables.R: tables[[i]] - tapply(data, model[model.cols[[i]]], get(fun)) ./stats/R/models.R:## get(contr.funs[1 + isOF[nn]])(nlevels(data[[nn]])) ./base/R/get.R:.Internal(get(x, envir, mode, inherits)) ./base/R/get.R: .Internal(mget(x, envir, mode, ifnotfound, inherits)) ./base/R/match.fun.R:FUN - get(as.character(FUN), mode = any, envir = envir) The first few hits seem to indicate examples where it is necessary to look specifically for a list. Cheers, Berwin __ 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] tapply bug? - levels of a factor in a data frame after tapply are intermixed
On Fri, Feb 13, 2009 at 12:24 PM, Marc Schwartz marc_schwa...@comcast.net wrote: on 02/13/2009 11:09 AM Dimitri Liakhovitski wrote: Hello! I have encountered a really weird problem. Maybe you've encountered it before? I have a large data frame importances. It has one factor ($A) with 3 levels: 3, 9, and 15. $B is a regular numeric variable. Below I am picking a really small sub-frame (just 3 rows) based on indices. indices were chosen so that all 3 levels of A are present: indices=c(14329,14209,14353) test=data.frame(yy=importances[[B']][indices],xx=importances[[A]][indices]) Here is what the new data frame test looks like: yyxx 1 -0.009984006 9 2 -2.339904131 3 3 -0.008427385 15 Here is the structure of test: str(test) 'data.frame': 3 obs. of 2 variables: $ yy: num -0.00998 -2.3399 -0.00843 $ xx: Factor w/ 3 levels 3,9,15: 2 1 3 Notice - the order of factor levels for xx is not 1 2 3 as it should be but 2 1 3. How come? Or also look at this: test$xx [1] 9 3 15 Levels: 3 9 15 Same thing. Do you know what might be the reason? Thank you very much! The output of str() is showing you the factor levels of test$xx, followed by the internal integer codes for the three actual values of test$xx, 9, 3, and 15: str(test$xx) Factor w/ 3 levels 3,9,15: 2 1 3 levels(test$xx) [1] 3 9 15 as.integer(test$xx) [1] 2 1 3 9 is the second level, hence the 2 3 is the first level, hence the 1 15 is the third level, hence the 3. No problems, just clarification needed on what you are seeing. Note that you do not reference anything above regarding tapply() as per your subject line, though I suspect that I have an idea as to why you did... HTH, Marc Schwartz Marc (and everyone), I expected it to show: $ xx: Factor w/ 3 levels 3,9,15: 1 2 3 rather than what I am seeing: $ xx: Factor w/ 3 levels 3,9,15: 2 1 3 Because 3 is level 1, 9 is level 2 and 15 is level 3. I have several other factors in my original data frame. And I've done that tapply for all of them (for the same dependent variable) - and in all of them the first level was 1, the second 2, etc. Why I am concerned about the problem? Because I am plotting the means of the numeric variable against the levels of the factor and it's important to me that the factor levels are correct (in the right order)... Dimitri -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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] problem with mediation
Dear friends, i've a little problem with a study about mediation. I will call my dependent variable Y, the independent X and Z will be my mediator variable... Using a linear regression, i can say that there isn't a direct effect of X on Y because the coefficient of X isn't significative, but i've tried to use anyway the Sobel's test to find a mediation relation. The result was positive, and with a p-value of 0.03 i can say that Z have a mediator effect on the relation between X and Y. Now my question: is right think about a mediator effect of Z on the relation between X and Y, also if there isn't a direct effect Waiting for your opinion, thank you so much. Costantino Milanese [[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] Extending each element in a list, or rbind()-ing arrays of different length without recycling
Combining the various approaches on the list, here's a simple one-liner that puts the NAs at the end: t(apply(mat,1,function(r) { dr-duplicated(r); c( r[!dr], rep(NA,sum(dr)) ) )) If you don't care where the NAs are, the following is a tad shorter and perhaps clearer: mat[ t(apply(mat,1,duplicated)) ] -NA # modifies mat -s __ 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] Distinguishing variables from functions with the same name
On Fri, Feb 13, 2009 at 12:25 PM, Berwin A Turlach ber...@maths.uwa.edu.au wrote: On Fri, 13 Feb 2009 11:11:28 -0500 Stavros Macrakis macra...@alum.mit.edu wrote: Where would it be advisable to use anything but mode='any' or mode='function'? I guess the answer to this question is more often than not in the source. :) ... The first few hits seem to indicate examples where it is necessary to look specifically for a list. Well, the presence of a construction in code is interesting, but doesn't answer the question of whether it is *advisable* to write code this way...! -s __ 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] Distinguishing variables from functions with the same name
Stavros Macrakis wrote: On Fri, Feb 13, 2009 at 12:25 PM, Berwin A Turlach ber...@maths.uwa.edu.au wrote: On Fri, 13 Feb 2009 11:11:28 -0500 Stavros Macrakis macra...@alum.mit.edu wrote: Where would it be advisable to use anything but mode='any' or mode='function'? I guess the answer to this question is more often than not in the source. :) ... The first few hits seem to indicate examples where it is necessary to look specifically for a list. Well, the presence of a construction in code is interesting, but doesn't answer the question of whether it is *advisable* to write code this way...! ... it doesn't even say if it really made sense in those cases, i.e., whether there was no better solution. vQ __ 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] Hollander's test of bivariate symmetry
Perhaps you could look at the coin package's symmetry tests and see if they satisfy: http://finzi.psych.upenn.edu/R/library/coin/html/SymmetryTests.html -- David Winsemius On Feb 11, 2009, at 11:26 AM, joseph.g.bo...@gsk.com wrote: Does anyone know if any R package has a function that will conduct Hollander's test of bivariate symmetry? (Hollander, Biometrika, 1971) Either the exact test or an asymptotic version would be sufficient for my purposes. Thanks. Joe Boyer Statistical Sciences Renaissance Bldg 510, 3233-D Mail Stop RN0320 8-275-3661 cell: (610) 209-8531 [[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] tapply bug? - levels of a factor in a data frame after tapply are intermixed
It comes down to 2 simple rules: 1. If you don't care about the order of the factor levels, then it doesn't matter how R codes the relationship 2. If you do care about the order, then tell R what order you want. Consider the following: x - c(9,3,15,9,15,9,3) factor(x) [1] 9 3 15 9 15 9 3 Levels: 3 9 15 factor(as.character(x)) [1] 9 3 15 9 15 9 3 Levels: 15 3 9 factor(x, levels=unique(x)) [1] 9 3 15 9 15 9 3 Levels: 9 3 15 The last looks most like what you want, but for many uses, all 3 will give equivalent results. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Dimitri Liakhovitski Sent: Friday, February 13, 2009 10:54 AM To: marc_schwa...@comcast.net Cc: R-Help List Subject: Re: [R] tapply bug? - levels of a factor in a data frame after tapply are intermixed Sorry - one clarification: When I run: test$xx - the what I am currently seeing is: [1] 9 3 15 Levels: 3 9 15 But what I am expecting to be seeing is: [1] 9 3 15 Levels: 9 3 15 Or maybe: Levels: 2 1 3 On Fri, Feb 13, 2009 at 12:38 PM, Dimitri Liakhovitski ld7...@gmail.com wrote: On Fri, Feb 13, 2009 at 12:24 PM, Marc Schwartz marc_schwa...@comcast.net wrote: on 02/13/2009 11:09 AM Dimitri Liakhovitski wrote: Hello! I have encountered a really weird problem. Maybe you've encountered it before? I have a large data frame importances. It has one factor ($A) with 3 levels: 3, 9, and 15. $B is a regular numeric variable. Below I am picking a really small sub-frame (just 3 rows) based on indices. indices were chosen so that all 3 levels of A are present: indices=c(14329,14209,14353) test=data.frame(yy=importances[[B']][indices],xx=importances[[A]][in dices]) Here is what the new data frame test looks like: yyxx 1 -0.009984006 9 2 -2.339904131 3 3 -0.008427385 15 Here is the structure of test: str(test) 'data.frame': 3 obs. of 2 variables: $ yy: num -0.00998 -2.3399 -0.00843 $ xx: Factor w/ 3 levels 3,9,15: 2 1 3 Notice - the order of factor levels for xx is not 1 2 3 as it should be but 2 1 3. How come? Or also look at this: test$xx [1] 9 3 15 Levels: 3 9 15 Same thing. Do you know what might be the reason? Thank you very much! The output of str() is showing you the factor levels of test$xx, followed by the internal integer codes for the three actual values of test$xx, 9, 3, and 15: str(test$xx) Factor w/ 3 levels 3,9,15: 2 1 3 levels(test$xx) [1] 3 9 15 as.integer(test$xx) [1] 2 1 3 9 is the second level, hence the 2 3 is the first level, hence the 1 15 is the third level, hence the 3. No problems, just clarification needed on what you are seeing. Note that you do not reference anything above regarding tapply() as per your subject line, though I suspect that I have an idea as to why you did... HTH, Marc Schwartz Marc (and everyone), I expected it to show: $ xx: Factor w/ 3 levels 3,9,15: 1 2 3 rather than what I am seeing: $ xx: Factor w/ 3 levels 3,9,15: 2 1 3 Because 3 is level 1, 9 is level 2 and 15 is level 3. I have several other factors in my original data frame. And I've done that tapply for all of them (for the same dependent variable) - and in all of them the first level was 1, the second 2, etc. Why I am concerned about the problem? Because I am plotting the means of the numeric variable against the levels of the factor and it's important to me that the factor levels are correct (in the right order)... Dimitri -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.com -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Distinguishing variables from functions with the same name
Berwin A Turlach wrote: G'day Stavros, On Fri, 13 Feb 2009 11:11:28 -0500 Stavros Macrakis macra...@alum.mit.edu wrote: On Fri, Feb 13, 2009 at 10:47 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: See ?get and try: Interesting. I hadn't paid attention to the 'mode' argument before. Where would it be advisable to use anything but mode='any' or mode='function'? I guess the answer to this question is more often than not in the source. :) On my machine: ber...@berwin-nus1:/opt/src/R-devel-src/src/library$ find . -name *.R -type f | xargs grep get( \ | grep mode | grep -v function | grep -v all hmm, looks like you can do it with just one call to grep: grep -R -P --include=*.R 'get\(.*mode\s*=\s*(?!function|any)' . # ./src/library/utils/R/Sweave.R:syntax - get(syntax, mode=list) # ./src/library/utils/R/Sweave.R:syntax - get(sname, mode = list) # ./src/library/utils/R/Sweave.R:s - get(sname, mode=list) # ./src/library/tools/R/QC.R:al - get(al, envir = code_env, mode = list) # ./src/library/tools/R/QC.R:al - get(al, envir = ns_env, mode = list) # ./src/library/tools/R/QC.R:al - get(al, envir = data_env, mode = list) (you'll need grep compiled with --enable-perl-regexpr for this) note this fancy comment in ?get: 'mode' here is a mixture of the meanings of 'typeof' and 'mode' vQ ./tools/R/QC.R:al - get(al, envir = code_env, mode = list) ./tools/R/QC.R:al - get(al, envir = ns_env, mode = list) ./tools/R/QC.R:al - get(al, envir = data_env, mode = list) ./utils/R/Sweave.R:syntax - get(syntax, mode=list) ./utils/R/Sweave.R:syntax - get(sname, mode = list) ./utils/R/Sweave.R:s - get(sname, mode=list) ./utils/R/str.R:str(get(nam, envir = E, mode = M), ./stats/R/model.tables.R: tables[[i]] - tapply(data, model[model.cols[[i]]], get(fun)) ./stats/R/models.R:## get(contr.funs[1 + isOF[nn]])(nlevels(data[[nn]])) ./base/R/get.R:.Internal(get(x, envir, mode, inherits)) ./base/R/get.R: .Internal(mget(x, envir, mode, ifnotfound, inherits)) ./base/R/match.fun.R:FUN - get(as.character(FUN), mode = any, envir = envir) The first few hits seem to indicate examples where it is necessary to look specifically for a list. Cheers, Berwin __ 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] Extending each element in a list, or rbind()-ing arrays of different length without recycling
(typos corrected) Combining the various approaches on the list, here's a simple one-liner that puts the NAs at the end: t(apply(mat,1,function(r) { dr-duplicated(r); c( r[!dr], rep(NA,sum(dr)) ) })) If you don't care where the NAs are, the following is a tad shorter and perhaps clearer: mat[ t(apply(mat,1,duplicated)) ] - NA # modifies mat -s On Fri, Feb 13, 2009 at 12:49 PM, Stavros Macrakis macra...@alum.mit.edu wrote: Combining the various approaches on the list, here's a simple one-liner that puts the NAs at the end: t(apply(mat,1,function(r) { dr-duplicated(r); c( r[!dr], rep(NA,sum(dr)) ) )) If you don't care where the NAs are, the following is a tad shorter and perhaps clearer: mat[ t(apply(mat,1,duplicated)) ] -NA # modifies mat -s __ 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] npindex: specifying manual bandwiths
Dear R-users, I am very enthusiastic about the capacities offered by the np package and pretty fond of it. Nevertheless, trying to estimate Ichimura and Klein and Spady models on my data, I would like to be able to provide the npindex function with my guesses for the bandwidth (eventually computed by other means). The fact that the option 'bandwidth.compute' in the function npindexbw exists and seems to be switchable (TRUE/FALSE) makes be believe that it might be possible, but i couldn't manage so far; could you help ? For instance, #Simulation n - 200 x1 - runif(n, min=-1, max=1) x2 - runif(n, min=-1, max=1) y - ifelse(x1 + x2 + rnorm(n) 0, 1, 0) #Klein and Spady estimation, letting np compute the bandwidth npindexbw(bws=c(1,1,.5),xdat=cbind(x1,x2),ydat=y,bandwidth.compute=TRUE,method=kleinspady) #Works fine! #Klein and Spady estimation, attempting to constrain the bandwidth to .5 npindexbw(bws=c(1,1,.5),xdat=cbind(x1,x2),ydat=y,bandwidth.compute=FALSE,method=kleinspady) #Returns a result with the starting values: no estimation has been done... Do you know how (or whether) constraining the bandwidth to a given value is possible. Many thanks, Cheers. Roland -- -- View this message in context: http://www.nabble.com/npindex%3A-specifying-manual-bandwiths-tp2268p2268.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] tapply bug? - levels of a factor in a data frame after tapply are intermixed
on 02/13/2009 11:38 AM Dimitri Liakhovitski wrote: On Fri, Feb 13, 2009 at 12:24 PM, Marc Schwartz marc_schwa...@comcast.net wrote: on 02/13/2009 11:09 AM Dimitri Liakhovitski wrote: Hello! I have encountered a really weird problem. Maybe you've encountered it before? I have a large data frame importances. It has one factor ($A) with 3 levels: 3, 9, and 15. $B is a regular numeric variable. Below I am picking a really small sub-frame (just 3 rows) based on indices. indices were chosen so that all 3 levels of A are present: indices=c(14329,14209,14353) test=data.frame(yy=importances[[B']][indices],xx=importances[[A]][indices]) Here is what the new data frame test looks like: yyxx 1 -0.009984006 9 2 -2.339904131 3 3 -0.008427385 15 Here is the structure of test: str(test) 'data.frame': 3 obs. of 2 variables: $ yy: num -0.00998 -2.3399 -0.00843 $ xx: Factor w/ 3 levels 3,9,15: 2 1 3 Notice - the order of factor levels for xx is not 1 2 3 as it should be but 2 1 3. How come? Or also look at this: test$xx [1] 9 3 15 Levels: 3 9 15 Same thing. Do you know what might be the reason? Thank you very much! The output of str() is showing you the factor levels of test$xx, followed by the internal integer codes for the three actual values of test$xx, 9, 3, and 15: str(test$xx) Factor w/ 3 levels 3,9,15: 2 1 3 levels(test$xx) [1] 3 9 15 as.integer(test$xx) [1] 2 1 3 9 is the second level, hence the 2 3 is the first level, hence the 1 15 is the third level, hence the 3. No problems, just clarification needed on what you are seeing. Note that you do not reference anything above regarding tapply() as per your subject line, though I suspect that I have an idea as to why you did... HTH, Marc Schwartz Marc (and everyone), I expected it to show: $ xx: Factor w/ 3 levels 3,9,15: 1 2 3 rather than what I am seeing: $ xx: Factor w/ 3 levels 3,9,15: 2 1 3 Because 3 is level 1, 9 is level 2 and 15 is level 3. I have several other factors in my original data frame. And I've done that tapply for all of them (for the same dependent variable) - and in all of them the first level was 1, the second 2, etc. Why I am concerned about the problem? Because I am plotting the means of the numeric variable against the levels of the factor and it's important to me that the factor levels are correct (in the right order)... Dimitri Dimitri, The above examples that you have are the expected output given the data that you provided, including the ordering of the explicit row indices that you used. If we create some sample data, using something along the lines of your original description: set.seed(1) A - sample(factor(c(3, 9, 15)), 100, replace = TRUE) set.seed(2) B - rnorm(100) DF - data.frame(A = A, B = B) head(DF) A B 1 3 -0.89691455 2 9 0.18484918 3 9 1.58784533 4 15 -1.13037567 5 3 -0.08025176 6 15 0.13242028 str(DF) 'data.frame': 100 obs. of 2 variables: $ A: Factor w/ 3 levels 3,9,15: 1 2 2 3 1 3 3 2 2 1 ... $ B: num -0.8969 0.1848 1.5878 -1.1304 -0.0803 ... I then use tapply() to get the means: tapply(DF$B, list(A = DF$A), mean) A 3 9 15 0.10620274 0.08577537 -0.26276438 The output is in the order one would expect. If you want something else, then you may have to check the factor levels for 'A' and alter them to the ordering that you actually want. For example: DF$A - factor(DF$A, levels = c(9, 3, 15)) or levels(DF$A) - c(9, 3, 15) str(DF) 'data.frame': 100 obs. of 2 variables: $ A: Factor w/ 3 levels 9,3,15: 2 1 1 3 2 3 3 1 1 2 ... $ B: num -0.8969 0.1848 1.5878 -1.1304 -0.0803 ... which would then adjust the ordering of the tapply() output to: tapply(DF$B, list(A = DF$A), mean) A 9 3 15 0.08577537 0.10620274 -0.26276438 Is that perhaps what you are looking for? Marc __ 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] Website, book, paper, etc. that shows example plots of distributions?
Jason, Just to answer your direct question, there is Mathowrld.wolfram.com, where there are 87 continuous distributions listed. I have also used the book Statistical Distributions, 2nd ed, Merran Evans, et al. which has most of the usual distributions with pictures and relationships. Of course all of the advice about really thinking about what you are trying to accomplish is right on target. HTH, -- David -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jason Rupert Sent: Friday, February 13, 2009 7:12 AM To: Gabor Grothendieck Cc: R-help@r-project.org Subject: Re: [R] Website, book, paper,etc. that shows example plots of distributions? Thank you very much. Thank you again regarding the suggestion below. I will give that a shot and I guess I've got my work counted out for me. I counted 45 different distributions. Is the best way to get a QQPlot of each, to run through producing a data set for each distribution and then using the qqplot function to get a QQplot of the distribution and then compare it with my data distribution? As you can tell I am not a trained statistician, so any guidance or suggested further reading is greatly appreciated. I guess I am pretty sure my data is not a normal distribution due to doing some of the empirical Goodness of Fit tests and comparing the QQplot of my data against the QQPlot of a normal distribution with the same number of points. I guess the next step is to figure out which distribution my data most closely matches. Also, I guess I could also fool around and take the log, sqrt, etc. of my data and see if it will then more closely resemble a normal distribution. Thank you again for assisting this novice data analyst who is trying to gain a better understanding of the techniques using this powerful software package. --- On Fri, 2/13/09, Gabor Grothendieck ggrothendi...@gmail.com wrote: From: Gabor Grothendieck ggrothendi...@gmail.com Subject: Re: [R] Website, book, paper, etc. that shows example plots of distributions? To: jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Friday, February 13, 2009, 5:43 AM You can readily create a dynamic display for using qqplot and similar functions in conjunction with either the playwith or TeachingDemos packages. For example, to investigate the effect of the shape parameter in the skew normal distribution on its qqplot relative to the normal distribution: library(playwith) library(sn) playwith(qqnorm(rsn(100, shape = shape)), parameters = list(shape = seq(-3, 3, .1))) Now move the slider located at the bottom of the window that appears and watch the plot change in response to changing the shape value. You can find more distributions here: http://cran.r-project.org/web/views/Distributions.html On Thu, Feb 12, 2009 at 1:04 PM, Jason Rupert jasonkrup...@yahoo.com wrote: By any chance is any one aware of a website, book, paper, etc. or combinations of those sources that show plots of different distributions? After reading a pretty good whitepaper I became aware of the benefit of I the benefit of doing Q-Q plots and histograms to help assess a distribution. The whitepaper is called: Univariate Analysis and Normality Test Using SAS, Stata, and SPSS* , (c) 2002-2008 The Trustees of Indiana University Univariate Analysis and Normality Test: 1, Hun Myoung Park Unfortunately the white paper does not provide an extensive amount of example distributions plotted using Q-Q plots and histograms, so I am curious if there is a portfolio-type website or other whitepaper shows examples of various types of distributions. It would be helpful to see a bunch of Q-Q plots and their associated histograms to get an idea of how the distribution looks in comparison against the Gaussian. I think seeing the plot really helps. Thank you for any insights. [[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] how to obtain p values from an ANOVA result
Hi all, I'm tryint to turn my ANOVA result from anova(model) in to p values. The default output is: term ; Df ; Deviance ; resid Df; Resid. Dev Is there a way to add p values to this output so the significance of the terms can be easily determined? Thanks in advance. Richie [[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] Extending each element in a list, or rbind()-ing arrays of different length without recycling
That is very nice. Maybe just one slight improvement so to express it in a non-destructive form: replace(mat, t(apply(mat,1,duplicated)), NA) On Fri, Feb 13, 2009 at 12:58 PM, Stavros Macrakis macra...@alum.mit.edu wrote: (typos corrected) Combining the various approaches on the list, here's a simple one-liner that puts the NAs at the end: t(apply(mat,1,function(r) { dr-duplicated(r); c( r[!dr], rep(NA,sum(dr)) ) })) If you don't care where the NAs are, the following is a tad shorter and perhaps clearer: mat[ t(apply(mat,1,duplicated)) ] - NA # modifies mat -s On Fri, Feb 13, 2009 at 12:49 PM, Stavros Macrakis macra...@alum.mit.edu wrote: Combining the various approaches on the list, here's a simple one-liner that puts the NAs at the end: t(apply(mat,1,function(r) { dr-duplicated(r); c( r[!dr], rep(NA,sum(dr)) ) )) If you don't care where the NAs are, the following is a tad shorter and perhaps clearer: mat[ t(apply(mat,1,duplicated)) ] -NA # modifies mat -s __ 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] SAS Institute Adding Support for R
It seems that SAS is willing to offer this interface if you are willing to purchase one of their expensive add-on packages. Not surprising. Gerard Smits [[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] tapply bug? - levels of a factor in a data frame after tapply are intermixed
Both Greg and Marc - thank you so much! It helped a lot. What I just discovered also works (similar to Greg's suggestions) is to make it first a character and THEN to do: as.factor(as.numeric(original character vector))). Wow! R never stops surprizing one - and I am just in the beginning of the journey! Thank you! Dimitri On Fri, Feb 13, 2009 at 1:13 PM, Greg Snow greg.s...@imail.org wrote: It comes down to 2 simple rules: 1. If you don't care about the order of the factor levels, then it doesn't matter how R codes the relationship 2. If you do care about the order, then tell R what order you want. Consider the following: x - c(9,3,15,9,15,9,3) factor(x) [1] 9 3 15 9 15 9 3 Levels: 3 9 15 factor(as.character(x)) [1] 9 3 15 9 15 9 3 Levels: 15 3 9 factor(x, levels=unique(x)) [1] 9 3 15 9 15 9 3 Levels: 9 3 15 The last looks most like what you want, but for many uses, all 3 will give equivalent results. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Dimitri Liakhovitski Sent: Friday, February 13, 2009 10:54 AM To: marc_schwa...@comcast.net Cc: R-Help List Subject: Re: [R] tapply bug? - levels of a factor in a data frame after tapply are intermixed Sorry - one clarification: When I run: test$xx - the what I am currently seeing is: [1] 9 3 15 Levels: 3 9 15 But what I am expecting to be seeing is: [1] 9 3 15 Levels: 9 3 15 Or maybe: Levels: 2 1 3 On Fri, Feb 13, 2009 at 12:38 PM, Dimitri Liakhovitski ld7...@gmail.com wrote: On Fri, Feb 13, 2009 at 12:24 PM, Marc Schwartz marc_schwa...@comcast.net wrote: on 02/13/2009 11:09 AM Dimitri Liakhovitski wrote: Hello! I have encountered a really weird problem. Maybe you've encountered it before? I have a large data frame importances. It has one factor ($A) with 3 levels: 3, 9, and 15. $B is a regular numeric variable. Below I am picking a really small sub-frame (just 3 rows) based on indices. indices were chosen so that all 3 levels of A are present: indices=c(14329,14209,14353) test=data.frame(yy=importances[[B']][indices],xx=importances[[A]][in dices]) Here is what the new data frame test looks like: yyxx 1 -0.009984006 9 2 -2.339904131 3 3 -0.008427385 15 Here is the structure of test: str(test) 'data.frame': 3 obs. of 2 variables: $ yy: num -0.00998 -2.3399 -0.00843 $ xx: Factor w/ 3 levels 3,9,15: 2 1 3 Notice - the order of factor levels for xx is not 1 2 3 as it should be but 2 1 3. How come? Or also look at this: test$xx [1] 9 3 15 Levels: 3 9 15 Same thing. Do you know what might be the reason? Thank you very much! The output of str() is showing you the factor levels of test$xx, followed by the internal integer codes for the three actual values of test$xx, 9, 3, and 15: str(test$xx) Factor w/ 3 levels 3,9,15: 2 1 3 levels(test$xx) [1] 3 9 15 as.integer(test$xx) [1] 2 1 3 9 is the second level, hence the 2 3 is the first level, hence the 1 15 is the third level, hence the 3. No problems, just clarification needed on what you are seeing. Note that you do not reference anything above regarding tapply() as per your subject line, though I suspect that I have an idea as to why you did... HTH, Marc Schwartz Marc (and everyone), I expected it to show: $ xx: Factor w/ 3 levels 3,9,15: 1 2 3 rather than what I am seeing: $ xx: Factor w/ 3 levels 3,9,15: 2 1 3 Because 3 is level 1, 9 is level 2 and 15 is level 3. I have several other factors in my original data frame. And I've done that tapply for all of them (for the same dependent variable) - and in all of them the first level was 1, the second 2, etc. Why I am concerned about the problem? Because I am plotting the means of the numeric variable against the levels of the factor and it's important to me that the factor levels are correct (in the right order)... Dimitri -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.com -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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. -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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,
Re: [R] how to obtain p values from an ANOVA result
Richie - There is a test= argument that can be set to Chisq, F or Cp, for various different tests. See the help file for anova.glm for details (or look at anova.xxx if your model is of class xxx). - Phil On Fri, 13 Feb 2009, R User R User wrote: Hi all, I'm tryint to turn my ANOVA result from anova(model) in to p values. The default output is: term ; Df ; Deviance ; resid Df; Resid. Dev Is there a way to add p values to this output so the significance of the terms can be easily determined? Thanks in advance. Richie [[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] how to obtain p values from an ANOVA result
It depends on what type of model model is. In some cases you can do something like anova(model, test='Chisq') See the appropriate help to find out the options, but note that if the p-values are not provided by default, it could be because there is doubt about the accuracy of the approximation and you should use them with caution (or use simulation to verify the quality of the approximation). Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of R User R User Sent: Friday, February 13, 2009 10:53 AM To: r-help@r-project.org Subject: [R] how to obtain p values from an ANOVA result Hi all, I'm tryint to turn my ANOVA result from anova(model) in to p values. The default output is: term ; Df ; Deviance ; resid Df; Resid. Dev Is there a way to add p values to this output so the significance of the terms can be easily determined? Thanks in advance. Richie [[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] weighted-ML estimates
Hi, We are trying to calculate ML-parameter estimates of a mixed effects models where the observations are weighted. The weights option in lmer() with RELM=FALSE seems attractive. Does anyone know the mechanism it uses to calculate weighted ML estimates? (Is there a paper?). Also, our model includes a serial correlation structure(e.g. AR(1)) among the residuals. As far as I know, no such cor option is available in lmer() unlike in nlme. Is this correct and if so, any suggestions on how to proceed? thanks, Harlan Campbell McGill University [[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 with reshaping
hi Im having some problems reshaping Ive managed to apply it but have some problems the attached document will explain any help is appreciated __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with reshaping (no file attached)
MCI A1 A2 A13 A14 A23 A24 A33 A34 Grouped together 56766 N/A N/A N/A N/A N/A N/A N/A N/A N/A 6459 N/A N/A N/A N/A N/A N/A N/A N/A N/A 31233 N/A N/A N/A N/A N/A N/A 71280.7 N/A N/A 16790 N/A N/A N/A N/A N/A N/A N/A N/A N/A 13392 284699.6 N/A N/A N/A N/A N/A N/A N/A N/A 1575 N/A 1196152 1236735 1322735 1100289 887130.2 N/A N/A N/A Figure 1 - Takeda2_nas.csv Trying to get data in suitable format for Genstat #clear console rm(list=ls())  install.packages(reshape) library(reshape)  #Read in data #Takeda - read.table(Takeda2_nas.csv, sep = ,, header = TRUE, row.names = 1) #Takedastack - cbind(Takeda[gl(nrow(Takeda), 1, 40*nrow(Takeda)), 1], stack(Takeda[, 1:41]))   zz - read.csv(Takeda2_nas.csv,strip.white = TRUE) #zzz - cbind(zz[gl(nrow(zz), 1, 40*nrow(zz)), 1], stack(zz[, 2:41])) #Use reshape function to change data zzz - reshape(zz,varying=list(c(A1,A2,A13,A14,A23,A24,A33,A34,A39,A40,B9,B10,B5,B6,B15,B16,B27,B28,B31,B32,C3,C4,C7,C8,C11,C12,C17,C18,C21,C22,V19,V20,V25,V26,V29,V30,V35,V36,V37,V38)),direction=long) #not ideal result i wanted #write a table to excel write.table(zzz, Takedashift.csv, sep=,) Script 1 - datashift.r              The result with above commands MCI (NONSENSE) Time (Actually MCI) A1 (1 = A1 and so on) Id (Intensity) (COUNT) 1.1 56766 1 N/A 1 2.1 6459 1 N/A 2 3.1 31233 1 N/A 3   Want the data to be MCI ID(sample) Intensity 56766 A1 N/A 6459 A1 N/A 31233 A1 N/A  [[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] Add columns to data frame automatically
Hello fellows: I've een trying to set up a function that performs 100 loops producing the coresponding 100 series. I want to save all those datasets in a dataframe, so I wrote this... prep - function() # Clase[1]/Categoria[2]/Phi[3]/Rf[4] peso - c(.0,.03,.3,.6) # Extension del calculo for (i in 1:100) { # Calculos de todas las curvas # Variables (Valor Base) abase - AlicuotaBruta clase - llmcc$Clase as.numeric(peso) df.clases - data.frame() df.clases[,i] - (abase/llmcc$Clase)*peso[1] peso[1] - peso[1]+(.01) cat(Modelos de Alicuotas:, i, peso[1], \n) } return (df.clases) Problem is: the function does not work, and I just cant seem to understand how to save the results for every iteration where the value of i and peso[1] changes. Any ideas? Hágale un favor a alguien y le tendrá que hacer muchos mas. Ley de Pinto. -- Jesús Guillermo Andrade (Abg.) Gerente de Litigios y Corporativo. EDM. AC. API. Andrade Moreno S.C. (http://amlegal.wordpress.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] help change auto.key colors in xyplot
Dimitri Liakhovitski ld7631 at gmail.com writes: the code below works just fine to produce a dotplot. However, I am not successful changing the color of the lines in the legend (auto.key). If I add col=..., it only changes the color of the letters in the legend, but not the color of the lines. I prefer to set pch and friends outside the panel function to avoid clutter, and to set the parameters globally, thus forcing my plots to be similar. This is a matter of taste, though. On Windows, the key looks a bit ugly now. Group 1 o Group 2 o- I am not very happy that the lwd is not honored by the key. Lines in lwd 2 (plot) and in lwd 1 (default key) do have a quite different subjective color hue. Any way around this, Deepayan? (Besides using ggplot2, as Hadley would argue ??) Dieter library(lattice) d=data.frame(xx=c(2.2,2.1,3.3),yy=c(0.1,0.2,0.3),zz=c(2.5,2.0,1.8)) d[[2]]-as.factor(d[[2]]) sp = trellis.par.get(superpose.line) sp$col=c(blue,red) trellis.par.set(superpose.line,sp) dotplot(c(d[[1]],d[[3]])~rep(d[[2]],2),groups=rep(c(Group 1,Group 2),each=nrow(d)),main=list(Chart Title,cex=1), type=b,pch=20,cex=1.3,lwd=2, xlab=list(Title for X,cex=.9,font=2), ylab=list(Title for Y,cex=.9,font=2), auto.key = list(space = top, points = T, lines = T,cex=.9), panel = function(y,x,...) { panel.grid(h = -1, v = -1, col = gray, lty =dotted, ltx=dotted) panel.superpose(x,y,... ) ltext(x, y, labels=round(y,3),cex=.8,col=black,font=2, adj=c(-0.2,1)) } ) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] I want axes that cross
Hello, everybody. A student asked me a howto question I can't answer. We want the length of the drawn axes to fill the full width and height of the plot, like so: | | * | * | * ---|- However, when we use plot with axes=F and then use the axis commands to add the axes, they do not cross over each other. We get | * | * * -- The axes are not wide enough to cover the entire range of the data. We do not want to add a box() command, which is a usual answer for this, because we don't want to draw on top or the side. Here's my test case: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green) axis(2, col=red, col.axis=red) Can I cause the 2 axes to cross as desired? The axis help says the axis is clipped at the plot region, but it seems to get clipped even more narrowly thanthat. I've been searching in r-help quite a bit and am a little surprised how difficult this is -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ 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 axes that cross
Try defining the argument 'pos' in the axis command-line, like: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green, pos=0) axis(2, col=red, col.axis=red, pos=-2) Daniel Moreira, MD Research Associate Duke University Medical Center DUMC 2626, MSRB-I Room 455 571 Research Drive Durham, North Carolina 27710 Telephone: (919) 681-7132 Fax: (919) 668-7093 E-mail: daniel.more...@duke.edu Paul Johnson pauljoh...@gmail.com Sent by: r-help-boun...@r-project.org 02/13/2009 02:25 PM To R-help r-h...@stat.math.ethz.ch cc Subject [R] I want axes that cross Hello, everybody. A student asked me a howto question I can't answer. We want the length of the drawn axes to fill the full width and height of the plot, like so: | | * | * | * ---|- However, when we use plot with axes=F and then use the axis commands to add the axes, they do not cross over each other. We get | * | * * -- The axes are not wide enough to cover the entire range of the data. We do not want to add a box() command, which is a usual answer for this, because we don't want to draw on top or the side. Here's my test case: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green) axis(2, col=red, col.axis=red) Can I cause the 2 axes to cross as desired? The axis help says the axis is clipped at the plot region, but it seems to get clipped even more narrowly thanthat. I've been searching in r-help quite a bit and am a little surprised how difficult this is -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ 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 axes that cross
on 02/13/2009 01:25 PM Paul Johnson wrote: Hello, everybody. A student asked me a howto question I can't answer. We want the length of the drawn axes to fill the full width and height of the plot, like so: | | * | * | * ---|- However, when we use plot with axes=F and then use the axis commands to add the axes, they do not cross over each other. We get | * | * * -- The axes are not wide enough to cover the entire range of the data. We do not want to add a box() command, which is a usual answer for this, because we don't want to draw on top or the side. Here's my test case: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green) axis(2, col=red, col.axis=red) Can I cause the 2 axes to cross as desired? The axis help says the axis is clipped at the plot region, but it seems to get clipped even more narrowly thanthat. I've been searching in r-help quite a bit and am a little surprised how difficult this is Paul, I am guessing that you want: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green) axis(2, col=red, col.axis=red) # Draw the box like an L on the bottom and left only box(bty = l) Note that you can specify which sides the 'box' is created upon by using the 'bty' argument. See ?box for more information. Also, by default, the axes extend the range of 'x' and 'y' by 4%. You can use 'xaxs = i' and 'yaxs = i' in the plot() call to restrict the axes to the true ranges of 'x' and 'y'. This would be important, for example, when you want the lower left hand corner of the plot to be at exact coordinates such as 0,0. See ?par for more information. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Add columns to data frame automatically
Something like this might work where you are using 'lapply' to create a list of values from the equivalent of the 'for' loop that you had. You can then 'cbind' them to create a return matrix, or you can convert it to a dataframe: prep - function() { # Clase[1]/Categoria[2]/Phi[3]/Rf[4] peso - c(.0,.03,.3,.6) # Extension del calculo result - lapply(1:100, function(){ # Calculos de todas las curvas # Variables (Valor Base) abase - AlicuotaBruta clase - llmcc$Clase as.numeric(peso) retValue - (abase/llmcc$Clase)*peso[1] peso[1] - peso[1]+(.01) cat(Modelos de Alicuotas:, i, peso[1], \n) retValue }) return (do.call(cbind, result)) } On Fri, Feb 13, 2009 at 2:23 PM, Jesús Guillermo Andrade jgandra...@mac.com wrote: Hello fellows: I've een trying to set up a function that performs 100 loops producing the coresponding 100 series. I want to save all those datasets in a dataframe, so I wrote this... prep - function() # Clase[1]/Categoria[2]/Phi[3]/Rf[4] peso - c(.0,.03,.3,.6) # Extension del calculo for (i in 1:100) { # Calculos de todas las curvas # Variables (Valor Base) abase - AlicuotaBruta clase - llmcc$Clase as.numeric(peso) df.clases - data.frame() df.clases[,i] - (abase/llmcc$Clase)*peso[1] peso[1] - peso[1]+(.01) cat(Modelos de Alicuotas:, i, peso[1], \n) } return (df.clases) Problem is: the function does not work, and I just cant seem to understand how to save the results for every iteration where the value of i and peso[1] changes. Any ideas? Hágale un favor a alguien y le tendrá que hacer muchos mas. Ley de Pinto. -- Jesús Guillermo Andrade (Abg.) Gerente de Litigios y Corporativo. EDM. AC. API. Andrade Moreno S.C. (http://amlegal.wordpress.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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] equivalent to SAS genmod code in R?
Nicole Schneider wrote: Hello, I have to run a general linear mixed model which looks at 2 dependent variables at the same time (var1 divided by var2). I have tryed to search for such a kind of model structure but since I just started using R my search was not successful. Especielly since I only have an old SAS GENMOD code structure from my project supervisor as an indication. My question is no, does there exist a code in R which is equivalent to the SAS code below? PROC GENMOD DATA=X; CLASS FLH; MODEL BS/OCCUPANCY = distcrop distfor flh distcrop*flh /D=B LINK=LOGIT TYPE3; RUN; Something like glm(bs/occupancy ~ distcrop*flh+distcrop, family=binomial(logit), weights=occupancy) where flh needs to be a factor. You do need to read up on the details of glm(), model formulas and such, though. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ 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 axes that cross
On Fri, Feb 13, 2009 at 1:51 PM, Marc Schwartz marc_schwa...@comcast.net wrote: on 02/13/2009 01:25 PM Paul Johnson wrote: Hello, everybody. A student asked me a howto question I can't answer. We want the length of the drawn axes to fill the full width and height of the plot, like so: Paul, I am guessing that you want: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green) axis(2, col=red, col.axis=red) # Draw the box like an L on the bottom and left only box(bty = l) Note that you can specify which sides the 'box' is created upon by using the 'bty' argument. See ?box for more information. Thanks, I did not find bty under ?box, but found it under par after you pointed it out. That does not get the correct output, however, because the black box covers over my 2 different colored axes. Even if I weren't color-conscious, it gives me this: | | |___ not crossed axes, which I want: | | _|__ | I'm putting in a seed so we will both see the same things in this example. set.seed(1233240) x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green) axis(2, col=red, col.axis=red) # MS recomends: # Draw the box like an L on the bottom and left only box(bty = l) Also, by default, the axes extend the range of 'x' and 'y' by 4%. You can use 'xaxs = i' and 'yaxs = i' in the plot() call to restrict the axes to the true ranges of 'x' and 'y'. This would be important, for example, when you want the lower left hand corner of the plot to be at exact coordinates such as 0,0. I would be delighted if the axes really did reach 4% outside the data. But they don't. I've seen that same thing you are referring to in the documentation, but there's something wrong about it, In my example code, we should see the same thing now I've put in a seed. The axes are smaller than the data range, not equal to 1.04 times the data range. I see several observations in the graph that are off the charts, they are above the highest value of the y axis, or below the lowest axis value. Similarly, there are observations smaller than the low end of the x axis and bigger than the largest x axis value. The 4% may be the plot region's size, but it is surely not the length of the axis that is drawn? See ?par for more information. HTH, Marc Schwartz -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ 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 axes that cross
On Fri, Feb 13, 2009 at 1:42 PM, Daniel Moreira daniel.more...@duke.edu wrote: Try defining the argument 'pos' in the axis command-line, like: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green, pos=0) axis(2, col=red, col.axis=red, pos=-2) Daniel Moreira, MD If you actually ran that code and still suggest it as the fix, then I think you must be joking. Pushing the axes into the middle of the data cloud in order to make them cross is certainly not making a very nice looking plot. Not only are there observations outside the area framed by the axes, but there are axis labels that are overlapped by observations and by the axes themselves. PJ -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ 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 axes that cross
On Fri, 13 Feb 2009, Paul Johnson wrote: On Fri, Feb 13, 2009 at 1:51 PM, Marc Schwartz marc_schwa...@comcast.net wrote: on 02/13/2009 01:25 PM Paul Johnson wrote: Hello, everybody. A student asked me a howto question I can't answer. We want the length of the drawn axes to fill the full width and height of the plot, like so: Paul, I am guessing that you want: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green) axis(2, col=red, col.axis=red) # Draw the box like an L on the bottom and left only box(bty = l) Note that you can specify which sides the 'box' is created upon by using the 'bty' argument. See ?box for more information. Thanks, I did not find bty under ?box, but found it under par after you pointed it out. That does not get the correct output, however, because the black box covers over my 2 different colored axes. Paul, If you use axis( ... , at = c(low,high), xpd=TRUE, col='green', labels=FALSE, lwd.tick=0) for suitably chosen values of low and high (and ... ), I think you can get what you want. It will overwrite your axis, but if you choose the same color, this won't be noticed. HTH, Chuck Even if I weren't color-conscious, it gives me this: | | |___ not crossed axes, which I want: | | _|__ | I'm putting in a seed so we will both see the same things in this example. set.seed(1233240) x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green) axis(2, col=red, col.axis=red) # MS recomends: # Draw the box like an L on the bottom and left only box(bty = l) Also, by default, the axes extend the range of 'x' and 'y' by 4%. You can use 'xaxs = i' and 'yaxs = i' in the plot() call to restrict the axes to the true ranges of 'x' and 'y'. This would be important, for example, when you want the lower left hand corner of the plot to be at exact coordinates such as 0,0. I would be delighted if the axes really did reach 4% outside the data. But they don't. I've seen that same thing you are referring to in the documentation, but there's something wrong about it, In my example code, we should see the same thing now I've put in a seed. The axes are smaller than the data range, not equal to 1.04 times the data range. I see several observations in the graph that are off the charts, they are above the highest value of the y axis, or below the lowest axis value. Similarly, there are observations smaller than the low end of the x axis and bigger than the largest x axis value. The 4% may be the plot region's size, but it is surely not the length of the axis that is drawn? See ?par for more information. HTH, Marc Schwartz -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ 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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error with make
Hi, I am trying to compile the R-dev version on a unix Suse machine and got errors. Would someone be able to help me determine what to do to fix these errors: make[1]: Entering directory `/lustre/people/schaffer/R-devel/m4' make[1]: Nothing to be done for `R'. make[1]: Leaving directory `/lustre/people/schaffer/R-devel/m4' make[1]: Entering directory `/lustre/people/schaffer/R-devel/tools' make[1]: Nothing to be done for `R'. make[1]: Leaving directory `/lustre/people/schaffer/R-devel/tools' make[1]: Entering directory `/lustre/people/schaffer/R-devel/doc' make[2]: Entering directory `/lustre/people/schaffer/R-devel/doc/html' make[3]: Entering directory `/lustre/people/schaffer/R-devel/doc/html/search' make[3]: Leaving directory `/lustre/people/schaffer/R-devel/doc/html/search' make[2]: Leaving directory `/lustre/people/schaffer/R-devel/doc/html' make[2]: Entering directory `/lustre/people/schaffer/R-devel/doc/manual' make[2]: Nothing to be done for `R'. make[2]: Leaving directory `/lustre/people/schaffer/R-devel/doc/manual' make[1]: Leaving directory `/lustre/people/schaffer/R-devel/doc' make[1]: Entering directory `/lustre/people/schaffer/R-devel/etc' make[1]: Leaving directory `/lustre/people/schaffer/R-devel/etc' make[1]: Entering directory `/lustre/people/schaffer/R-devel/share' make[1]: Leaving directory `/lustre/people/schaffer/R-devel/share' make[1]: Entering directory `/lustre/people/schaffer/R-devel/src' make[2]: Entering directory `/lustre/people/schaffer/R-devel/src/scripts' creating src/scripts/R.fe make[3]: Entering directory `/lustre/people/schaffer/R-devel/src/scripts' mkdir -p -- ../../bin make[3]: Leaving directory `/lustre/people/schaffer/R-devel/src/scripts' make[2]: Leaving directory `/lustre/people/schaffer/R-devel/src/scripts' make[2]: Entering directory `/lustre/people/schaffer/R-devel/src/include' mkdir -p -- ../../include cp: getting attribute `trusted.lov' of `Rmath.h0': Operation not permitted make[2]: *** [Rmath.h] Error 1 make[2]: Leaving directory `/lustre/people/schaffer/R-devel/src/include' make[1]: *** [R] Error 1 make[1]: Leaving directory `/lustre/people/schaffer/R-devel/src' make: *** [R] Error 1 Lana Schaffer Biostatistics/Informatics The Scripps Research Institute DNA Array Core Facility La Jolla, CA 92037 (858) 784-2263 (858) 784-2994 schaf...@scripps.edu __ 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 axes that cross
I think you ought to worry a bit about who might be laughing at whom. You are asking for a plot with rather unnatural behavior and potentially very misleading to the audience. Here it is, but you bear full responsibility for any consequences: plot(x,y,type=n, axes=F, xlim=c(min(x)-1, max(x)), ylim=c(min(y)-1,max(y))) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green,pos=-1) axis(2, col=red, col.axis=red, pos=-2.5) -- David Winsemius On Feb 13, 2009, at 3:22 PM, Paul Johnson wrote: On Fri, Feb 13, 2009 at 1:42 PM, Daniel Moreira daniel.more...@duke.edu wrote: Try defining the argument 'pos' in the axis command-line, like: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green, pos=0) axis(2, col=red, col.axis=red, pos=-2) Daniel Moreira, MD If you actually ran that code and still suggest it as the fix, then I think you must be joking. Pushing the axes into the middle of the data cloud in order to make them cross is certainly not making a very nice looking plot. Not only are there observations outside the area framed by the axes, but there are axis labels that are overlapped by observations and by the axes themselves. PJ -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ 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] odfWeave prettyR
The problem is that on the CRAN web site the XML package is not available for windows... I just checked, and it is available for Windows from my mirror (Austria) and from ETH (assuming you are CH). I would use XML ~ v1.90 for windows to use with odfWeave. You can get it at: http://cran.us.r-project.org/bin/windows/contrib/2.5/ Max __ 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 axes that cross
Another alternative is: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green,xaxp=c(-6, 3, 9),xpd=T) axis(2, col=red, col.axis=red, yaxp=c(-6, 6, 12),xpd=T) Daniel Moreira, MD Research Associate Duke University Medical Center DUMC 2626, MSRB-I Room 455 571 Research Drive Durham, North Carolina 27710 Telephone: (919) 681-7132 Fax: (919) 668-7093 E-mail: daniel.more...@duke.edu David Winsemius dwinsem...@comcast.net 02/13/2009 03:47 PM To Paul Johnson pauljoh...@gmail.com cc Daniel Moreira daniel.more...@duke.edu, R-help r-h...@stat.math.ethz.ch Subject Re: [R] I want axes that cross I think you ought to worry a bit about who might be laughing at whom. You are asking for a plot with rather unnatural behavior and potentially very misleading to the audience. Here it is, but you bear full responsibility for any consequences: plot(x,y,type=n, axes=F, xlim=c(min(x)-1, max(x)), ylim=c(min(y)-1,max(y))) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green,pos=-1) axis(2, col=red, col.axis=red, pos=-2.5) -- David Winsemius On Feb 13, 2009, at 3:22 PM, Paul Johnson wrote: On Fri, Feb 13, 2009 at 1:42 PM, Daniel Moreira daniel.more...@duke.edu wrote: Try defining the argument 'pos' in the axis command-line, like: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green, pos=0) axis(2, col=red, col.axis=red, pos=-2) Daniel Moreira, MD If you actually ran that code and still suggest it as the fix, then I think you must be joking. Pushing the axes into the middle of the data cloud in order to make them cross is certainly not making a very nice looking plot. Not only are there observations outside the area framed by the axes, but there are axis labels that are overlapped by observations and by the axes themselves. PJ -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ 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 axes that cross
on 02/13/2009 02:19 PM Paul Johnson wrote: On Fri, Feb 13, 2009 at 1:51 PM, Marc Schwartz marc_schwa...@comcast.net wrote: on 02/13/2009 01:25 PM Paul Johnson wrote: Hello, everybody. A student asked me a howto question I can't answer. We want the length of the drawn axes to fill the full width and height of the plot, like so: Paul, I am guessing that you want: x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green) axis(2, col=red, col.axis=red) # Draw the box like an L on the bottom and left only box(bty = l) Note that you can specify which sides the 'box' is created upon by using the 'bty' argument. See ?box for more information. Thanks, I did not find bty under ?box, but found it under par after you pointed it out. 'bty' is referenced in ?box as a '...' argument, though the detailed options are defined in ?par. That does not get the correct output, however, because the black box covers over my 2 different colored axes. Even if I weren't color-conscious, it gives me this: | | |___ not crossed axes, which I want: | | _|__ | OK...so if I am reading this more clearly, you don't want them to simply join in the corner, but to actually cross for some length? I'm putting in a seed so we will both see the same things in this example. set.seed(1233240) x - rnorm(100) z - gl(2,50) y - rnorm(100, mean= 1.8*as.numeric(z)) plot(x,y,type=n, axes=F) points(x,y, pch=$,cex=0.7, col=z) axis(1, col=green, col.axis=green) axis(2, col=red, col.axis=red) # MS recomends: # Draw the box like an L on the bottom and left only box(bty = l) Also, by default, the axes extend the range of 'x' and 'y' by 4%. You can use 'xaxs = i' and 'yaxs = i' in the plot() call to restrict the axes to the true ranges of 'x' and 'y'. This would be important, for example, when you want the lower left hand corner of the plot to be at exact coordinates such as 0,0. I would be delighted if the axes really did reach 4% outside the data. But they don't. I've seen that same thing you are referring to in the documentation, but there's something wrong about it, In my example code, we should see the same thing now I've put in a seed. The axes are smaller than the data range, not equal to 1.04 times the data range. I see several observations in the graph that are off the charts, they are above the highest value of the y axis, or below the lowest axis value. Similarly, there are observations smaller than the low end of the x axis and bigger than the largest x axis value. The 4% may be the plot region's size, but it is surely not the length of the axis that is drawn? Yes, strictly speaking it is the plot region's dimensions that are extended by 4%, when these two parameters are set to 'r', which is the default. However, the actual drawn axes *may* be affected by this, since the data range has been extended and this will affect the default calculation of the axis tick marks, which is dependent upon the resultant range. From ?par for 'xaxs': ... Style r (regular) first extends the data range by 4 percent at each end and then finds an axis with pretty labels that fits within the extended range. Style i (internal) just finds an axis with pretty labels that fits within the original data range. ... OK, so given all of the above, something like the following should work: set.seed(1233240) x - rnorm(100) z - gl(2,50) y - rnorm(100, mean = 1.8 * as.numeric(z)) # Calculate a new range, subtracting a definable value # from the min of each vector for the new minimum # Adust the 0.25 as may be needed X - c(min(x) - 0.25, max(x)) Y - c(min(y) - 0.25, max(y)) # Use 'X' and Y' here, not 'x' and 'y' # So that the plot region is extended appropriately plot(X, Y, type = n, axes = F, xlab = x, ylab = y) points(x, y, pch = $, cex = 0.7, col = z) # DO use 'pos'... axis(1, pos = Y[1], col = green, col.axis = green) axis(2, pos = X[1], col = red, col.axis = red) # get the plot region boundaries usr - par(usr) segments(X[1], usr[3], X[1], usr[4], col = red) segments(usr[1], Y[1], usr[2], Y[1], col = green) HTH, Marc __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error with make
Lana Schaffer wrote: Hi, I am trying to compile the R-dev version on a unix Suse machine and got errors. Would someone be able to help me determine what to do to fix these errors: . make[2]: Entering directory `/lustre/people/schaffer/R-devel/src/include' mkdir -p -- ../../include cp: getting attribute `trusted.lov' of `Rmath.h0': Operation not permitted A Valentines Day bug? (Fiancee not Faithful) :-) Seriously, this looks like it could be related to http://osdir.com/ml/file-systems.lustre.user/2007/msg01107.html If so, then it is probably something very specific to SLES and the Lustre file system, and you need to use their support. You could try building in a separate directory though (mkdir ../BUILD ; cd ../BUILD ; ../R/configure make). make[2]: *** [Rmath.h] Error 1 make[2]: Leaving directory `/lustre/people/schaffer/R-devel/src/include' make[1]: *** [R] Error 1 make[1]: Leaving directory `/lustre/people/schaffer/R-devel/src' make: *** [R] Error 1 Lana Schaffer Biostatistics/Informatics The Scripps Research Institute DNA Array Core Facility La Jolla, CA 92037 (858) 784-2263 (858) 784-2994 schaf...@scripps.edu __ 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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ 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.