[R] (lme4: lmer) mcmcsamp: Error in if (var(y) == 0)
I've got a problem with mcmcsamp used with glmer objects produced with lmer from the lme4 package. When calling mcmcsamp, I get the error Error in if (var(y) == 0) { : missing value where TRUE/FALSE needed This does not occur with all models, but I can't find anything wrong with the dataset. If the error is in my data, can someone tell me what I am looking for? (Can I print the source code of the mcmcsamp method for glmer objects? I'd like to know what y stands for.) Many thanks for your advice! === sessionInfo() R version 2.6.1 (2007-11-26) i686-pc-linux-gnu locale: LC_CTYPE = en_GB .UTF -8 ;LC_NUMERIC = C ;LC_TIME = en_GB .UTF -8 ;LC_COLLATE = en_GB .UTF -8 ;LC_MONETARY = en_GB .UTF -8 ;LC_MESSAGES = en_GB .UTF -8 ;LC_PAPER = en_GB .UTF -8 ;LC_NAME = C ;LC_ADDRESS =C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] languageR_0.4 coda_0.13-1 lme4_0.99875-9 Matrix_0.999375-4 [5] zipfR_0.6-0 lattice_0.17-2 loaded via a namespace (and not attached): [1] grid_2.6.1 rcompgen_0.1-17 emnlp.m1 - lmer(primed ~ (role * derivation)/(log(dist.time) * log(rule.freq)) + (1 + log(dist.time) | target.utt), family=binomial, data=data.utts ) summary(emnlp.m1) Error: cannot allocate vector of size 120.3 Mb emnlp.m1 Generalized linear mixed model fit using Laplace Formula: primed ~ (role * derivation)/(log(dist.time) * log(rule.freq)) + (1 + log(dist.time) | target.utt) Data: data.utts Family: binomial(logit link) AIC BIC logLik deviance 1145907 1146131 -572935 1145869 ... Pr(|z|) ... rolei:derivationI:log(dist.time) 2e-16 *** roler:derivationI:log(dist.time) 2e-16 *** rolei:derivationN:log(dist.time) 2e-16 *** roler:derivationN:log(dist.time)0.000187 *** ... class(emnlp.m1) [1] glmer attr(,package) [1] lme4 mc - mcmcsamp(emnlp.m1) summary(mc) Error in if (var(y) == 0) { : missing value where TRUE/FALSE needed Error in if (var(y) == 0) { : missing value where TRUE/FALSE needed Error in if (var(y) == 0) { : missing value where TRUE/FALSE needed Error in if (var(y) == 0) { : missing value where TRUE/FALSE needed Error in if (var(y) == 0) { : missing value where TRUE/FALSE needed ... 2. Quantiles for each variable: Mean SD Naive SE ( rolei:derivationI:log(dist.time)-2.19615 NA NA roler:derivationI:log(dist.time)-1.36876 NA NA ... 2.5% 25% 50% rolei:derivationI:log(dist.time)-2.19615 -2.19615 -2.19615 roler:derivationI:log(dist.time)-1.36876 -1.36876 -1.36876 traceback() 11: asMethod(object) 10: as(object, superClass) 9: validityMethod(as(object, superClass)) 8: identical(x, TRUE) 7: anyStrings(validityMethod(as(object, superClass))) 6: validObject(.Object) 5: initialize(value, ...) 4: initialize(value, ...) 3: new(if (is(object, glmer)) summary.glmer else { if (is(object, lmer)) summary.lmer else summary.mer }, object, isG = glz, methTitle = methTitle, logLik = llik, ngrps = sapply([EMAIL PROTECTED], function(x) length(levels(x))), sigma = .Call(mer_sigma, object, REML), coefs = coefs, vcov = vcov, REmat = REmat, AICtab = AICframe) 2: summary(emnlp.m1) 1: summary(emnlp.m1) -- David Reitter ICCS/HCRC, Informatics, University of Edinburgh http://www.david-reitter.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] package manual in pdf
Duncan Murdoch a écrit : On 23/01/2008 7:37 PM, [EMAIL PROTECTED] wrote: Hi all, I am trying to write a pdf manual for my package. I create a file inst\doc\myDoc.tex. I taught that R CMD build will call latex on this file (like it is said in Writing R extension), but it does not happen. I don't see this in Writing R Extensions, other than in the Writing package vignettes section, where it says this happens for vignettes in Sweave format. You can force it to happen to .tex files by including a Makefile. Ok, thanks The usual one is produced from your .Rd documentation files. I don't know why the lines would be too long, I don't usually see that. On the package r2lUniv, page 8, section examples: the line step outside the page. I saw that in other manual to. Is it possible to change the Topic Documented order ? And I also would like to add a visual example section, it is why I would prefer to access to the source file that produce the pdf instead fo rewriting all... Christophe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] features boxplot
Hallo, I just made a boxplot with the following command: boxplot(vsnrg$M~col(vsnrg$M)) When I now look at the plot. On the x-axis I just find numbers 1-6 because I have 6 datasets plotted. Now I want to add there the corresponding names which can be found in colnames(qrg). How can I realize this the online help does not help me. Thanks Corinna __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] hello
hello, happy new year. I want to know if it's possible to send a bar chart from the software R to an directory. 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] store variable as tab-del. txt-file
Hallo, how can I store a variable as a tab-delimited txt-file? I crated a variable with the following commands: fit12-lmFit(qrg[,1:2]) t12-toptable(fit12,adjust=fdr,number=25,genelist=qrg$genes[,1]) t12 ID logFC t P.Value adj.P.ValB 522PLAU_OP -6.836144 -8.420414 5.589416e-05 0.01212520 2.054965 1555 CD44_WIZ -6.569622 -8.227938 6.510169e-05 0.01212520 1.944046 767 CD44_WIZ -8.164317 -8.201678 6.648556e-05 0.01212520 1.928622 1234 EMP1_WIZ -6.822609 -8.145985 6.953146e-05 0.01212520 1.895674 445 EMP1_WIZ -6.796011 -8.079979 7.334676e-05 0.01212520 1.856207 1310 PLAU_OP -6.361645 -7.955721 8.118607e-05 0.01212520 1.780656 1460 FOSL1_WIZ -6.265342 -7.841959 8.919795e-05 0.01212520 1.710025 1459 FOSL1_WIZ -6.132684 -7.692912 1.010747e-04 0.01212520 1.615319 1326 RAC2_WIZ -6.130817 -7.648676 1.049345e-04 0.01212520 1.586728 768 CD44_WIZ -6.054628 -7.592040 1.101204e-04 0.01212520 1.549795 537 RAC2_WIZ -6.447683 -7.577670 1.114816e-04 0.01212520 1.540365 1418 FOSL1_OP -6.022508 -7.556906 1.134820e-04 0.01212520 1.526697 1210 EMP1_OP -5.997289 -7.502210 1.189472e-04 0.01212520 1.490452 672 FOSL1_WIZ -6.060602 -7.491438 1.200581e-04 0.01212520 1.483272 446 EMP1_WIZ -6.211220 -7.461834 1.231715e-04 0.01212520 1.463470 545 PLAU_WIZ -5.931195 -7.429649 1.266597e-04 0.01212520 1.441824 630 FOSL1_OP -5.877253 -7.368262 1.336248e-04 0.01212520 1.400193 671 FOSL1_WIZ -5.870755 -7.325227 1.387642e-04 0.01212520 1.370736 1417 FOSL1_OP -5.813254 -7.294160 1.426123e-04 0.01212520 1.349331 422EMP1_OP -6.013347 -7.286186 1.436191e-04 0.01212520 1.343819 546 PLAU_WIZ -6.030866 -7.282026 1.441477e-04 0.01212520 1.340939 369 PLAUR_OP -6.054368 -7.209710 1.536923e-04 0.01212520 1.290546 538 RAC2_WIZ -5.959863 -7.147772 1.624334e-04 0.01212520 1.246868 1325 RAC2_WIZ -5.811128 -7.144946 1.628454e-04 0.01212520 1.244864 1309 PLAU_OP -6.028117 -7.075208 1.733917e-04 0.01239404 1.195081 Now I want to store t12 as a tab-delimited txt-file to use it in other programm. How can I realize this? Thanks, Corinna __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R help?
Hey does anyone know how to do t.test for beta1 and beta0, which are the slope and intercept of the linear regression 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] store variable as tab-del. txt-file
See ?write.table On 24/01/2008, Schmitt, Corinna [EMAIL PROTECTED] wrote: Hallo, how can I store a variable as a tab-delimited txt-file? I crated a variable with the following commands: fit12-lmFit(qrg[,1:2]) t12-toptable(fit12,adjust=fdr,number=25,genelist=qrg$genes[,1]) t12 ID logFC t P.Value adj.P.ValB 522PLAU_OP -6.836144 -8.420414 5.589416e-05 0.01212520 2.054965 1555 CD44_WIZ -6.569622 -8.227938 6.510169e-05 0.01212520 1.944046 767 CD44_WIZ -8.164317 -8.201678 6.648556e-05 0.01212520 1.928622 1234 EMP1_WIZ -6.822609 -8.145985 6.953146e-05 0.01212520 1.895674 445 EMP1_WIZ -6.796011 -8.079979 7.334676e-05 0.01212520 1.856207 1310 PLAU_OP -6.361645 -7.955721 8.118607e-05 0.01212520 1.780656 1460 FOSL1_WIZ -6.265342 -7.841959 8.919795e-05 0.01212520 1.710025 1459 FOSL1_WIZ -6.132684 -7.692912 1.010747e-04 0.01212520 1.615319 1326 RAC2_WIZ -6.130817 -7.648676 1.049345e-04 0.01212520 1.586728 768 CD44_WIZ -6.054628 -7.592040 1.101204e-04 0.01212520 1.549795 537 RAC2_WIZ -6.447683 -7.577670 1.114816e-04 0.01212520 1.540365 1418 FOSL1_OP -6.022508 -7.556906 1.134820e-04 0.01212520 1.526697 1210 EMP1_OP -5.997289 -7.502210 1.189472e-04 0.01212520 1.490452 672 FOSL1_WIZ -6.060602 -7.491438 1.200581e-04 0.01212520 1.483272 446 EMP1_WIZ -6.211220 -7.461834 1.231715e-04 0.01212520 1.463470 545 PLAU_WIZ -5.931195 -7.429649 1.266597e-04 0.01212520 1.441824 630 FOSL1_OP -5.877253 -7.368262 1.336248e-04 0.01212520 1.400193 671 FOSL1_WIZ -5.870755 -7.325227 1.387642e-04 0.01212520 1.370736 1417 FOSL1_OP -5.813254 -7.294160 1.426123e-04 0.01212520 1.349331 422EMP1_OP -6.013347 -7.286186 1.436191e-04 0.01212520 1.343819 546 PLAU_WIZ -6.030866 -7.282026 1.441477e-04 0.01212520 1.340939 369 PLAUR_OP -6.054368 -7.209710 1.536923e-04 0.01212520 1.290546 538 RAC2_WIZ -5.959863 -7.147772 1.624334e-04 0.01212520 1.246868 1325 RAC2_WIZ -5.811128 -7.144946 1.628454e-04 0.01212520 1.244864 1309 PLAU_OP -6.028117 -7.075208 1.733917e-04 0.01239404 1.195081 Now I want to store t12 as a tab-delimited txt-file to use it in other programm. How can I realize this? Thanks, Corinna __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] hello
Hi, I want to know if it's possible to send a bar chart from the software R to an directory. Do you mean saving your figure to a file ? If so, you can take a look at the device functions, which allow you to generate your figure to a file in different formats, especially pdf or postscript. For example, to generate your plot into a pdf file, you can use : pdf(file=filename.pdf) plot(...) dev.off() Hope that helps, Julien -- Julien Barnier Groupe de recherche sur la socialisation ENS-LSH - Lyon, France __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] store variable as tab-del. txt-file
Hi, Now I want to store t12 as a tab-delimited txt-file to use it in other programm. How can I realize this? Did you take a look at the write.table() function ? You can supply «\t» as «sep» argument to get a tab-delimited file. Hope that helps, Julien -- Julien Barnier Groupe de recherche sur la socialisation ENS-LSH - Lyon, France __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] features boxplot
Try this: boxplot(vsnrg$M~col(vsnrg$M), xaxt=n) axis(1, at=1:length(colnames(qrg)), labels=colnames(qrg)) On 24/01/2008, Schmitt, Corinna [EMAIL PROTECTED] wrote: Hallo, I just made a boxplot with the following command: boxplot(vsnrg$M~col(vsnrg$M)) When I now look at the plot. On the x-axis I just find numbers 1-6 because I have 6 datasets plotted. Now I want to add there the corresponding names which can be found in colnames(qrg). How can I realize this the online help does not help me. Thanks Corinna __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plot help
Try this: #some data y1=rnorm(1:3) y2=rnorm(1:3) #draw two plots on the same screen par(mfrow=c(2,1),oma = c(6, 0, 5, 0)) par(mar=c(0, 5.1, 0, 5.1)) plot(y1,xaxt=n,type=n) #1st plot par(mar=c(0, 5.1, 0, 5.1)) plot(y2,xaxt=n,type=n) #2nd plot #try to draw lines onto each plot on the screen lines(y2) #draws a line in the 2nd plot par(mfg=c(1, 1)) lines(y1,col=2) #also draws a line in the 2nd plot, but that's not what I On 24/01/2008, tom soyer [EMAIL PROTECTED] wrote: Hi, Suppose I already have two plots on the same screen, and I want to draw lines in each of them. Is that possible in R? It seems that once you have two plots on the screen, you can only draw lines in the the last plot, never the 1st. Here is what I mean: #some data y1=rnorm(1:3) y2=rnorm(1:3) #draw two plots on the same screen par(mfrow=c(2,1),oma = c(6, 0, 5, 0)) par(mar=c(0, 5.1, 0, 5.1)) plot(y1,xaxt=n,type=n) #1st plot par(mar=c(0, 5.1, 0, 5.1)) plot(y2,xaxt=n,type=n) #2nd plot #try to draw lines onto each plot on the screen lines(y2) #draws a line in the 2nd plot lines(y1,col=2) #also draws a line in the 2nd plot, but that's not what I want. I want to draw the line in the 1st plot instead. Does anyone know if after more than one plot were drawn, can I still call the 1st plot and draw a line in it? Thanks, -- Tom [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] png to html
hello, to display my histogram from a png file to a html file I use this syntax myplot2 - png(file=file.path(directory,myplot2.png), bg=transparent) plot(1:10) rect(1, 5, 3, 7, col=white) dev.off() png:C:/Documents and Settings/melyakhlifi/Bureau/myplot.png 2 HTMLInsertGraph(myplot2,file=HTMLoutput,caption=Sample discrete distribution plot) [1] TRUE but when I open HTMLoutput I don't find my histogram. Can you help me please? 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] png to html
On Thu, 24 Jan 2008, elyakhlifi mustapha wrote: hello, to display my histogram from a png file to a html file I use this syntax myplot2 - png(file=file.path(directory,myplot2.png), bg=transparent) Please re-read ?png: myplot2 will be NULL. plot(1:10) rect(1, 5, 3, 7, col=white) dev.off() png:C:/Documents and Settings/melyakhlifi/Bureau/myplot.png 2 HTMLInsertGraph(myplot2,file=HTMLoutput,caption=Sample discrete distribution plot) [1] TRUE but when I open HTMLoutput I don't find my histogram. This must be in some package you haven't mentioned (R2HTML?) and which is not giving an error message when passed NULL as the first argument. Try passing it file.path(directory,myplot2.png). [[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. ^ Please follow this request. -- Brian D. Ripley, [EMAIL PROTECTED] 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] plot help
Thanks Henrique! On 1/24/08, Henrique Dallazuanna [EMAIL PROTECTED] wrote: Try this: #some data y1=rnorm(1:3) y2=rnorm(1:3) #draw two plots on the same screen par(mfrow=c(2,1),oma = c(6, 0, 5, 0)) par(mar=c(0, 5.1, 0, 5.1)) plot(y1,xaxt=n,type=n) #1st plot par(mar=c(0, 5.1, 0, 5.1)) plot(y2,xaxt=n,type=n) #2nd plot #try to draw lines onto each plot on the screen lines(y2) #draws a line in the 2nd plot par(mfg=c(1, 1)) lines(y1,col=2) #also draws a line in the 2nd plot, but that's not what I On 24/01/2008, tom soyer [EMAIL PROTECTED] wrote: Hi, Suppose I already have two plots on the same screen, and I want to draw lines in each of them. Is that possible in R? It seems that once you have two plots on the screen, you can only draw lines in the the last plot, never the 1st. Here is what I mean: #some data y1=rnorm(1:3) y2=rnorm(1:3) #draw two plots on the same screen par(mfrow=c(2,1),oma = c(6, 0, 5, 0)) par(mar=c(0, 5.1, 0, 5.1)) plot(y1,xaxt=n,type=n) #1st plot par(mar=c(0, 5.1, 0, 5.1)) plot(y2,xaxt=n,type=n) #2nd plot #try to draw lines onto each plot on the screen lines(y2) #draws a line in the 2nd plot lines(y1,col=2) #also draws a line in the 2nd plot, but that's not what I want. I want to draw the line in the 1st plot instead. Does anyone know if after more than one plot were drawn, can I still call the 1st plot and draw a line in it? Thanks, -- Tom [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O -- Tom [[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] store variable as tab-del. txt-file
Hallo Julien, thanks for the hint. It works now. Corinna -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Julien Barnier Sent: Thursday, January 24, 2008 11:08 AM To: [EMAIL PROTECTED] Subject: Re: [R] store variable as tab-del. txt-file Hi, Now I want to store t12 as a tab-delimited txt-file to use it in other programm. How can I realize this? Did you take a look at the write.table() function ? You can supply \t as sep argument to get a tab-delimited file. Hope that helps, Julien -- Julien Barnier Groupe de recherche sur la socialisation ENS-LSH - Lyon, France __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] package manual in pdf
christophe.genolini wrote: Duncan Murdoch a écrit : On 23/01/2008 7:37 PM, [EMAIL PROTECTED] wrote: Hi all, I am trying to write a pdf manual for my package. I create a file inst\doc\myDoc.tex. I taught that R CMD build will call latex on this file (like it is said in Writing R extension), but it does not happen. I don't see this in Writing R Extensions, other than in the Writing package vignettes section, where it says this happens for vignettes in Sweave format. You can force it to happen to .tex files by including a Makefile. Ok, thanks The usual one is produced from your .Rd documentation files. I don't know why the lines would be too long, I don't usually see that. On the package r2lUniv, page 8, section examples: the line step outside the page. I saw that in other manual to. Those lines are reproduced as you typed them. If you want line breaks, you need to put them in the .Rd file. Is it possible to change the Topic Documented order ? You can't control the order of the standard sections, but you can use your own custom sections. And I also would like to add a visual example section, it is why I would prefer to access to the source file that produce the pdf instead fo rewriting all... The .Rd is the source file. Unfortunately that format doesn't support figures. You can include URLs that point to web pages containing figures, and some of the output formats will generate links. Duncan Murdoch Christophe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rcom package
Hi, I have R 2.5.1 installed in my system and have installed rcom package 1.5-2.2 vesion. I don't see the following reference RCOM 1.0 Type Library in the VBA IDE. Please help. Also, after installing when I type comRegisterRegistry(), it return NULL. Is that ok? Same with comRegisterServer(). Regards, Uma This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Sliding Window Time Series Analysis - hourly rainfall
I have a time series of rainfall in a dataframe. I would like to be able to aggregate this using a sliding window approach- i.e. a new 24 hourly total is calculated for each hours rainfall. I'm struggling to understand how this might be achieved - currently I've tried looping a sum function to re-calculate a new total at every stage of the loop. for (inp[[9]] in 1:length(inp[[9]])){data.frame(x-sum(inp[y:y+24,9]))} where inp is the data frame object and [[9]] is the column containing rainfall. y is used to try and get the previous 24 hours total however in it's current state it seems useless. If anyone could give me some pointers i'd be very pleased, I'm a bit new to the R language so any help appreciated. Thanks Jamie Ledingham __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Why I cannot get the intervals from Rails data ?
Dear R users, I would like to know where I'm wrong doing the following. lmList(Rail) is working fine, since it gives back the ouput. But on intervals(lmList(Rail)) I'm getting the following error Errore in out[, est., ] - coeff[, Estimate, ] : numero di indici non corretto that translated should sounds like Error in out[, est., ] - coeff[, Estimate, ] : not correct indexes number What is that I'm not considering here ? Thanks -- Ottorino-Luca Pantani, Università di Firenze Dip. Scienza del Suolo e Nutrizione della Pianta P.zle Cascine 28 50144 Firenze Italia Tel 39 055 3288 202 (348 lab) Fax 39 055 333 273 [EMAIL PROTECTED] http://www4.unifi.it/dssnp/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] adjustment on the x-axis scale width
Hi, I have sucessfully plotted the graph by using the following command: ec-rep(0,length(e)) fc-rep(0,length(f)) plot(e,ec,type=p,col=1,pch=19) points(f,fc,col=2,pch=20) legend(1.0e+08,1.0,c(dog, human),text.col=green4,pch=c(19,20),col=c(1,2)) Below are the values for e and f...the questions is how am i going to adjust the scale width of my x-axis and my y-axis will start at 0?? Any suggestion?? thanks in advance!! e: [1] 17358865 17966995 21306539 27880531 34166504 36111044 36266288 [8] 36854306 43786190 44322336 45529444 46302360 53479132 58567262 [15] 60564442 72637088 79875476 93155112 94372260 96643396 103123936 [22] 116908456 131781664 132968364 135945080 141788832 149924864 156539568 [29] 157817896 162399496 168344072 173146584 176302744 182878168 183946152 [36] 185068720 190791232NA f-[1] 17906353 21295547 27880531 34118702 35395488 36132622 37916920 [8] 43786190 44322336 46302360 53494622 62105336 63817440 72637088 [15] 79875476 94545992 96506368 103123936 116908456 126190072 127446552 [22] 131781664 154658264 176302744 181670472 182625272 182878168 183946152 [29]NA cheers, Anisah - [[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] Stationarity of a Time Series
This is a little far afield but I will be back with R/analysis questions as things progress: I am working with a dissolve oxygen signal, so there is defiantly seasonality, There are local changes in mean and variability (with a graphical investigation on the order of around seven days). I am working in a river and we are monitoring over two hundred miles. I am trying to get a hold on the cycles that make up the dissolved oxygen signal, and then link those things back to the biology (photosynthesis and respiration), chemistry (chemical oxygen demand), and the physics (advection (transport of oxygen to the next downstream station) etc.) We are measuring a suit of chemical, biological, and physical parameters. Can the spectral density be valid if there is departure from stationarity? if not can I then break the signal up into its seasonal components and then run spec.pgram on those parts? Admittedly, I have never delved into signal processing before, so I am learning, and I work at a nonprofit without access to a university full of wonderful statisticians- so you guys are it. Sometimes you have to jump head first into something to learn. I'll keep asking questions and by the grace of inquisitiveness and a little help from my friends I can figure this out. thanks to everyone who has helped and anyone who will help in the future. Stephen Sefick On Jan 23, 2008 5:48 AM, David Jones [EMAIL PROTECTED] wrote: Prof Brian Ripley wrote: On Tue, 22 Jan 2008, Pfaff, Bernhard Dr. wrote: Hello Stephen, stationarity tests as well as unit root tests have been implemented in a couple of packages. For instance, as already mentioned: tseries, but also uroot, fUnitRoots and urca. See the annotated task view Econemtrics and Finance for further information. But note that these tests apply to just a few ways in which a series might be non-stationary: they all seem an econmetrician's view of possible non-stationarity. In the end stationarity is a modelling assumption: it depends on what might have happened but did not. E.g. a sine wave process is stationary if and only if it has a random (uniform) phase, and you cannot tell that from a single realization. 'Anna Karenina applies'[*] (as to most pure significance tests). [*] Google it if you need elucidation. Apart from the drift type of nonstationarity, other types would be .. (i) seasonality; (ii) local changes in mean-level; (iii) local changes in correlation; (iv) local changes in variability. Some of these might be made formally stationary as above. David Jones __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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{Hmisc} cannot find xdvi on MAC OS X
Charles C. Berry wrote: On Wed, 23 Jan 2008, Kevin E. Thorpe wrote: Frank E Harrell Jr wrote: Charles C. Berry wrote: On Wed, 23 Jan 2008, Frank E Harrell Jr wrote: Kevin E. Thorpe wrote: Kevin E. Thorpe wrote: Gabor Grothendieck wrote: It eliminates Hmisc and R by giving you a tex file. Now its up to you to figure out how to handle tex files on your system. I have suggested the student try options(xdvicmd=fullpathtoxdvi) to see what happens. Here is the result of trying the above. latex(describe(ps1d)) This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) %-line parsing enabled. entering extended mode (/tmp/RtmpMi0s95/file10d63af1.tex LaTeX2e 2005/12/01 Babel v3.8h and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, arabic, basque, bulgarian, coptic, welsh, czech, slovak, german, ng erman, danish, esperanto, spanish, catalan, galician, estonian, farsi, finnish, french, greek, monogreek, ancientgreek, croatian, hungarian, interlingua, ibyc us, indonesian, icelandic, italian, latin, mongolian, dutch, norsk, polish, por tuguese, pinyin, romanian, russian, slovenian, uppersorbian, serbian, swedish, turkish, ukenglish, ukrainian, loaded. (/usr/local/texlive/2007/texmf-dist/tex/latex/base/report.cls Document Class: report 2005/09/16 v1.4f Standard LaTeX document class (/usr/local/texlive/2007/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2007/texmf-dist/tex/latex/setspace/setspace.sty Package: `setspace' 6.7 2000/12/01 ) (/usr/local/texlive/2007/texmf-dist/tex/latex/ltxmisc/relsize.sty) (/usr/local/texlive/2007/texmf-dist/tex/latex/geometry/geometry.sty (/usr/local/texlive/2007/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2007/texmf-dist/tex/xelatex/xetexconfig/geometry.cfg)) No file file10d63af1.aux. [1] [2] (./file10d63af1.aux) ) Output written on file10d63af1.dvi (2 pages, 1 bytes). Transcript written on file10d63af1.log. /usr/texbin/xdvi: line 1: kpsewhich: command not found /usr/texbin/xdvi: line 46: exec: xdvi-xaw.bin: not found So, it appears to that something about the MAC environment is not being passed to the shell that is invoked when latex() is called in this way. That's exactly what it looks like. Shame on Mac -) On my linux systems xdvi is in /usr/bin On my leopard, it is in /usr/texbin (as seen above) and Sys.setenv( PATH=paste(Sys.getenv(PATH),usr/texbin,sep=:) ) allows system(xdvi) and Excellent. I much prefer solutions to workarounds. A .profile or .bashrc type of file can also extend the PATH this way. Thanks Chuck Frank My student tried this but had the same result (failed) result. What exactly is 'this'? The Sys.setenv() command or the .profile/.bashrc approach? Sorry, I should have been explicit. It was the Sys.setenv() command. What does list.files( tail( strsplit(Sys.getenv(PATH),: )[[1]],1)) reveal after 'this' is done? I get [1] T1Wrap a2ping afm2pl [4] afm2tfm aleph allcm [deleted] [109] kpsepathkpsereadlinkkpsestat [112] kpsetoolkpsewhere kpsewhich [115] kpsexpand lacheck lambda [more deleted] If s/he does not get something very much like the above after Sys.setenv, then either s/he mistyped the Sys.setenv() line, or something is different (wrong?) in his/her local setup. HTH, Chuck I will obtain the information you have requested from her. Thank you for your help. It IS appreciated. Kevin p.s. FWIW latex(describe(as.data.frame(diag(10 seems to run just fine iff I run the Sys.setenv() as above. I do have to zoom out, 'though. -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Department of Public Health Sciences Faculty of Medicine, University of Toronto email: [EMAIL PROTECTED] Tel: 416.864.5776 Fax: 416.864.6057 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Memory problem
Hi All, There is something I don't quite understand about R memory management. I have the following function function (AdGroupId) { print(memory.size()) channel - odbcConnect(RDsn, uid = , case = tolower, pwd = xx) Tree1 - sqlQuery(channel, exec SelectAdgroups 20,0, as.is = c(FALSE, FALSE, FALSE, FALSE, TRUE)) Tree2 - sqlQuery(channel, exec SelectAdgroups 200337,0, as.is = c(FALSE, FALSE, FALSE, FALSE, TRUE)) gc() print(memory.size()) odbcClose(channel) rm(channel);rm(Tree1);rm(Tree2); gc() print(memory.size()) return(NULL) } I ran the function twice and I got the following results: prop(1000) [1] 11.0589 [1] 15.97034 [1] 13.43737 NULL prop(1000) [1] 13.43737 [1] 17.97294 [1] 17.42295 NULL As you can see the size of the memory is being increased with each call to the function. When I call the function using apply the memory usage keeps growing until I get out of memory error. It was tested on 4 different environments: R: 2.4.0 and 2.6.1 OS: WinXp 64/32 Any ideas? Thanks, Yoni. [[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{Hmisc} cannot find xdvi on MAC OS X
Kevin E. Thorpe wrote: Charles C. Berry wrote: On Wed, 23 Jan 2008, Kevin E. Thorpe wrote: Frank E Harrell Jr wrote: Charles C. Berry wrote: On Wed, 23 Jan 2008, Frank E Harrell Jr wrote: Kevin E. Thorpe wrote: Kevin E. Thorpe wrote: Gabor Grothendieck wrote: It eliminates Hmisc and R by giving you a tex file. Now its up to you to figure out how to handle tex files on your system. I have suggested the student try options(xdvicmd=fullpathtoxdvi) to see what happens. Here is the result of trying the above. latex(describe(ps1d)) This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) %-line parsing enabled. entering extended mode (/tmp/RtmpMi0s95/file10d63af1.tex LaTeX2e 2005/12/01 Babel v3.8h and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, arabic, basque, bulgarian, coptic, welsh, czech, slovak, german, ng erman, danish, esperanto, spanish, catalan, galician, estonian, farsi, finnish, french, greek, monogreek, ancientgreek, croatian, hungarian, interlingua, ibyc us, indonesian, icelandic, italian, latin, mongolian, dutch, norsk, polish, por tuguese, pinyin, romanian, russian, slovenian, uppersorbian, serbian, swedish, turkish, ukenglish, ukrainian, loaded. (/usr/local/texlive/2007/texmf-dist/tex/latex/base/report.cls Document Class: report 2005/09/16 v1.4f Standard LaTeX document class (/usr/local/texlive/2007/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2007/texmf-dist/tex/latex/setspace/setspace.sty Package: `setspace' 6.7 2000/12/01 ) (/usr/local/texlive/2007/texmf-dist/tex/latex/ltxmisc/relsize.sty) (/usr/local/texlive/2007/texmf-dist/tex/latex/geometry/geometry.sty (/usr/local/texlive/2007/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2007/texmf-dist/tex/xelatex/xetexconfig/geometry.cfg)) No file file10d63af1.aux. [1] [2] (./file10d63af1.aux) ) Output written on file10d63af1.dvi (2 pages, 1 bytes). Transcript written on file10d63af1.log. /usr/texbin/xdvi: line 1: kpsewhich: command not found /usr/texbin/xdvi: line 46: exec: xdvi-xaw.bin: not found So, it appears to that something about the MAC environment is not being passed to the shell that is invoked when latex() is called in this way. That's exactly what it looks like. Shame on Mac -) On my linux systems xdvi is in /usr/bin On my leopard, it is in /usr/texbin (as seen above) and Sys.setenv( PATH=paste(Sys.getenv(PATH),usr/texbin,sep=:) ) allows system(xdvi) and Excellent. I much prefer solutions to workarounds. A .profile or .bashrc type of file can also extend the PATH this way. Thanks Chuck Frank My student tried this but had the same result (failed) result. What exactly is 'this'? The Sys.setenv() command or the .profile/.bashrc approach? Sorry, I should have been explicit. It was the Sys.setenv() command. What does list.files( tail( strsplit(Sys.getenv(PATH),: )[[1]],1)) reveal after 'this' is done? I get [1] T1Wrap a2ping afm2pl [4] afm2tfm aleph allcm [deleted] [109] kpsepathkpsereadlinkkpsestat [112] kpsetoolkpsewhere kpsewhich [115] kpsexpand lacheck lambda [more deleted] If s/he does not get something very much like the above after Sys.setenv, then either s/he mistyped the Sys.setenv() line, or something is different (wrong?) in his/her local setup. HTH, Chuck I will obtain the information you have requested from her. Thank you for your help. It IS appreciated. Kevin p.s. FWIW latex(describe(as.data.frame(diag(10 seems to run just fine iff I run the Sys.setenv() as above. I do have to zoom out, 'though. I was comparing what my student did with what was posted for the Sys.setenv() (which agree) and I noticed that the initial / is missing from usr/texbin Kevin -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Department of Public Health Sciences Faculty of Medicine, University of Toronto email: [EMAIL PROTECTED] Tel: 416.864.5776 Fax: 416.864.6057 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Printing large number
Dear R users, Just a quick question, how do I prevent 10 printed as 1e+05 when I print it into a file? Thanks, Alex Alex C. Lam Roslin Institute (Edinburgh) Midlothian EH25 9PS United Kingdom Tel: +44 131 5274471 Roslin Institute is a company limited by guarantee, registered in Scotland (registered number SC157100) and a Scottish Charity (registered number SC023592). Our registered office is at Roslin, Midlothian, EH25 9PS. VAT registration number 847380013. The information contained in this e-mail (including any attachments) is confidential and is intended for the use of the addressee only. The opinions expressed within this e-mail (including any attachments) are the opinions of the sender and do not necessarily constitute those of Roslin Institute (Edinburgh) (the Institute) unless specifically stated by a sender who is duly authorised to do so on behalf of the Institute __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] vector generation
Dear Contributors: I have the next vector: Z z = (526, 0.1, 110, 0.2, 34, 0.4, 614, 0.5, 1, 14, 15) I want to generate a vector containing the values higher than 1 corresponding to the z vector, wich in this case will mean to generate the next vector: (526, 110, 34, 614, 14, 15) If you have any clue on how to do that, I will be very glad to hear it!! Thanks in advance again, [[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] surface plot
Hi, there is following issue, which I encounter when doing data analysis. Say we have data in form of the matrix x: x [,1] [,2] [,3] [1,] 0.14 10 [2,] 0.25 11 [3,] 0.15 12 [4,] 0.16 13 [5,] 0.24 14 [6,] 0.35 16 now I want to do surface plot of x[,3] with respect to axes OX:x[,1] and OY: x[,2] in ascending orders of course. Thanks in advance, best rob -- View this message in context: http://www.nabble.com/surface-plot-tp15064443p15064443.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] save a plot from R graphics window (in Windows)
Dear R users since R 2.6.0 when I try to save a graph from the Rgraphic device I find that the system becomes so slow that I'm forced to kill the process. This usually does not happen at the beginning of the session. The problem seems to arise when the system opens the dialog window to choose the directory and file name. (R version 2.6.1 under Windows XP) Thank you all Giovanni -- Giovanni M. Marchetti Dipartimento di Statistica, G. Parenti, University of Florence viale Morgagni, 59 Phone: +39 055 4237 261 I 50134 Firenze, Italy Fax:+39 055 4223 560 [[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] Calculating sum of squares from density estimates
Hi I have some density estimates obtained from density(). I would like to calculate the sum of squares of these. As the x values of the estimates are not the same, and I would prefer not to restrict the estiomate to a certain range of x values, how can I do the calculation? Lets say: d1 - density(Data1) d2 - density(Data2) If the x values would be the same, I would: ssq - sum( (d1$y - d2$y)^2 ) but as it isn't, I can't do that. is there an easy way to get the sum of squares? Thanks, Rainer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] surface plot
On 24/01/2008 8:59 AM, threshold wrote: Hi, there is following issue, which I encounter when doing data analysis. Say we have data in form of the matrix x: x [,1] [,2] [,3] [1,] 0.14 10 [2,] 0.25 11 [3,] 0.15 12 [4,] 0.16 13 [5,] 0.24 14 [6,] 0.35 16 now I want to do surface plot of x[,3] with respect to axes OX:x[,1] and OY: x[,2] in ascending orders of course. How do you want to make a surface out of x[,3]? You've got 6 points. There are lots of ways to make a surface out of those, but you haven't said which one you want to use. The interp() function from the akima package might work, but you don't have much data for it to work with. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] vector generation
z[z 1] regards, Albert Am Donnerstag, den 24.01.2008, 10:54 -0300 schrieb Juan Pablo Fededa: Dear Contributors: I have the next vector: Z z = (526, 0.1, 110, 0.2, 34, 0.4, 614, 0.5, 1, 14, 15) I want to generate a vector containing the values higher than 1 corresponding to the z vector, wich in this case will mean to generate the next vector: (526, 110, 34, 614, 14, 15) If you have any clue on how to do that, I will be very glad to hear it!! Thanks in advance again, [[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] singular.ok in lm
On Thu, 24 Jan 2008, Martin Eklund wrote: Dear R users, I'm wondering about the singular.ok option in lm. If singular.ok is set to TRUE does it mean that we allow the generalized inverse of (X'X)^-1 (where X are the independent variables and ' denotes the transpose)? Or is the singularity handled in some other way? Pivoting is used: singular.ok=TRUE is the default in R. I don't think you can say *the* generalized inverse: there are many. In any case, R does not solve the normal equations let alone invert X'X to fit a regression. Martin Eklund PhD Student Department of Pharmaceutical Biosciences Uppsala University, Sweden Ph: +46-18-4714281 -- Brian D. Ripley, [EMAIL PROTECTED] 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] save a plot from R graphics window (in Windows)
On 24/01/2008 9:00 AM, Giovanni Maria Marchetti wrote: Dear R users since R 2.6.0 when I try to save a graph from the Rgraphic device I find that the system becomes so slow that I'm forced to kill the process. This usually does not happen at the beginning of the session. The problem seems to arise when the system opens the dialog window to choose the directory and file name. (R version 2.6.1 under Windows XP) You'll need to be more specific before I could investigate this. Find a sequence of actions that almost (or at least most of the time) leads to the problem, and write it out in detail. If I can't reproduce it, I can't fix it. Please do it with the R-patched version; we're gearing up for a 2.6.2 release, and it would be really helpful to catch bugs before that. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice on FreeBSD
-- X-USF-Spam-Status: hits=-2.5 tests=BAYES_00,FORGED_RCVD_HELO X-USF-Spam-Flag: NO Armin Goralczyk, I am working with FreeBSD 8.0-CURRENT, R-2.6.1 and lattice() installs fine. I think you have to update your FreeBSD ports tree. Afterwards you can install R-2.6.0. The newest version R-2.6.1 is not yet available on ports, because the ports tree is semi frozen for months now (forthcoming of FreeBSD version 7.0). This could remain at least until february. I personally prefer not to use the ports tree to install R. Even the actual version R-2.6.1 builds and installs fine on FreeBSD without any port. There are two steps you have to pay attention of: 1. On actual versions of FreeBSD you have to ensure, that gfortran is accessible. For that you must first install lang/gcc42. 2. Before installing the new R, you have to deinstall the old R-port. Take care of making a list of your installed and preferred R-packages. You have to install them again on the new version (other path, other fortran and other R version ...). There should be no more difficulties ;-) Hope this helps, Rainer Hurling Am 23.01.2008 20:14 (UTC+1) schrieb Armin Goralczyk: On Jan 23, 2008 1:59 PM, Gabor Csardi [EMAIL PROTECTED] wrote: Which R version do you use? You chose mirror #21, that is Germany (Muenchen) to me. The same to you? Btw. Muenchen works for me. Maybe you have an old version of R, survival works with =2.0.0, but lattice only with =2.5.0. (The current version is 2.6.1.) I've no other idea what could've gone wrong G. Thank you Gabor. Mirror München ist correct. The problem is indeed the version. I've installed 2.3.1 (just two weeks ago with pkg_add). I guess I have to update. Shouldn't this information be included in the error message?! This would make things a lot easier. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] two histograms in the same graph
Dear Contributors: I have two vectors x and z, and I want to display the histograms of both vectors in the same graph, x in red bars, z in blue bars. If you have any clue on how to do that, I will be very glad to hear it!! Thanks in advance again, Juan Pablo Fededa [[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] Parametric survival models with left truncated, right censored data
Bill Meeker's programs for reliability analysis can fit this, they are part of his SPLIDA package for Splus. I'm not sure that anyone has ported these to R however. The survreg routine does not handle this case, and psm call survreg to do the actual work. Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Maximum entropy spectral analysis
Hi, Is there on R a package containing Maximum entropy spectral analysis function? Thanks in advance, Nuno Prista __ Instituto de Oceanografia - FCUL, Portugal Center for Quantitative Fisheries Ecology - ODU, USA [[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] possible inconsistency in nlme logLik or me
Hello, I am comparing 2 nonlinear models one with a correlation structure. I used the gnls command in the nlme package to fit model 1 and then the update(mod1,corr=corExp(form=~lat+lon,nugget=T) to fit the same model but with a correlation structure. I am comparing models using AIC, but I am getting results that don't seem to match. I get matching results for the model with no correlation structure, but non corresponding results for the model with a correlation structure. Below are logLik for the models along with additional information. Am I doing something wrong? Information for model 1 rss=sum(resid(mod1)^2)=1318.645 var=rss/n=1.654511 n=797 number of parameters (K) = 10 (this does include the variance estimate) if I use logLik(mod1) I get -1331.541 with 10 d.f. if I use the formula: (-.5*n*log(var))-(797/2*log(2*pi))-(n/2) from Burnham and Anderson 2002 page 12, I get the same result as above:-1331.541 Information for model 2 with a correlation structure corr=corExp(form=~lat+lon,nugget=T) rss=1338.92 n=797 var=rss/n=1.679950 K=12 logLik(mod2)=-1313.65 with 12 d.f. If I use the equation from Burnham and Anderson I get:-1337.621 different than the logLik result?? Dan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 .svg
Dear everybody, I still didn't manage to install the RSvgDevice-Package. Please, note the attached file: The server cannot seriousely be the problem. I would be glad if you could find the mistake. Thank you in advance. Yours, Mag. Ferri Leberl Am Sonntag, den 20.01.2008, 18:29 + schrieb Prof Brian Ripley: On Sun, 20 Jan 2008, Mag. Ferri Leberl wrote: The program does not open the interface again to select am mirror. Neither works install.packages(RSvgDevice, dependencies = TRUE, repos=http://cran.r-project.org,contriburl=http://cran.r-project.org;) the feedback here is Warnung in install.packages(RSvgDevice, dependencies = TRUE, repos = http://cran.r-project.org;, : argument 'lib' is missing: using '/home/nemo/R/i486-pc-linux-gnu-library/2.5' Warnung: unable to access index for repository http://cran.r-project.org Warning message: package ‘RSvgDevice’ is not available in: install.packages(RSvgDevice, dependencies = TRUE, repos = http://cran.r-project.org;, What is going wrong? You incorrectly specified contriburl: you only need repos, and giving contriburl incorrectly is the reason for the message you got. I suspect chooseCRAN mirror() failed because the CRAN master was inaccessible: it has been from here on and off all day. In which case you will need to select a different mirror. Yours, Leberl Am Sonntag, den 20.01.2008, 16:34 +0100 schrieb Gabor Csardi: Yes, try another mirror. Austria should work. Or go to http://cran.at.r-project.org/src/contrib/PACKAGES.html and download the package directly and install it via R CMD INSTALL package_file You might need to give the '-l' options for where to install to. G. On Sun, Jan 20, 2008 at 03:49:22PM +0100, Mag. Ferri Leberl wrote: Thank you so far. install.packages(RSvgDevice, dependencies = TRUE) returns Warnung in install.packages(RSvgDevice, dependencies = TRUE) : argument 'lib' is missing: using '/usr/local/lib/R/site-library' Warnung in install.packages(RSvgDevice, dependencies = TRUE) : 'lib = /usr/local/lib/R/site-library' is not writable Would you like to create a personal library '~/R/i486-pc-linux-gnu-library/2.5' to install packages into? (y/n) y --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done Warning message: package ‘RSvgDevice’ is not available in: install.packages(RSvgDevice, dependencies = TRUE) When asked I chose for the Bamberg-mirror. Can you recognize a mistake? Should I chose for a different mirror? Thank you in advance. Yours, Mag. Ferri Leberl Am Montag, den 14.01.2008, 19:21 +0100 schrieb Gabor Csardi: Are you sure this is an R problem? I guess it is not, but rather a pstoedit problem. You can use the RSVGDevice package, or the Cairo package to export your graphics directly into SVG from R. Gabor On Mon, Jan 14, 2008 at 07:10:13PM +0100, Mag. Ferri Leberl wrote: Dear everybody! I am making a graph in R and employ pstoedit to expot the .pdf-output to .svg. When I open the .svg with firefox I get the .svg-code shown wit the following header: Mit dieser XML-Datei sind anscheinend keine Style-Informationen verknüpft. Nachfolgend wird die Baum-Ansicht des Dokuments angezeigt. Which information should how be included? Thank you in advance. Yours, Mag. Ferri Leberl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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]] -- Brian D. Ripley, [EMAIL PROTECTED] 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 version 2.5.1 (2007-06-27) Copyright (C) 2007 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R ist freie Software und kommt OHNE JEGLICHE GARANTIE. Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten. Tippen Sie 'license()' or 'licence()' für Details dazu. R ist ein Gemeinschaftsprojekt mit vielen Beitragenden. Tippen Sie 'contributors()' für mehr Information und 'citation()', um zu erfahren, wie R oder R packages in Publikationen zitiert werden können. Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder 'help.start()' für eine HTML Browserschnittstelle zur Hilfe. Tippen Sie 'q()', um R zu verlassen. install.packages(RSvgDevice, dependencies = TRUE, + repos=http://cran.r-project.org;) Warnung in install.packages(RSvgDevice,
Re: [R] two histograms in the same graph
That's an easy one with ggplot2. library(ggplot2) dataset - data.frame(variable = gl(2, 50, labels = c(x, z)), value = c(runif(50), rnorm(50))) ggplot(data = dataset, aes(x = value, fill = variable)) + geom_histogram(position = dodge) + scale_fill_manual(values = c(red, blue), guide = tile) But I don't prefer to put two histograms into the same graphs. Making a seperate histogram for each variable makes is easier to compare them. Or you could use a density plot. ggplot(data = dataset, aes(x = value, fill = variable)) + geom_histogram() + facet_grid(variable ~ .) + scale_fill_manual(values = c(red, blue), guide = tile) ggplot(data = dataset, aes(x = value, colour = variable)) + geom_density() + scale_colour_manual(values = c(red, blue), guide = line) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Juan Pablo Fededa Verzonden: donderdag 24 januari 2008 15:44 Aan: r-help Onderwerp: [R] two histograms in the same graph Dear Contributors: I have two vectors x and z, and I want to display the histograms of both vectors in the same graph, x in red bars, z in blue bars. If you have any clue on how to do that, I will be very glad to hear it!! Thanks in advance again, Juan Pablo Fededa [[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] save a plot from R graphics window (in Windows)
Hi Are you sure this is an R problem? The Choose dialog can be very slow if you have networked directories that cannot be connected to. Windows tries to connect repeatedly and each time waits for a timeout. Suggest you check your mapped network drives. Regards JS --- Dear R users since R 2.6.0 when I try to save a graph from the Rgraphic device I find that the system becomes so slow that I'm forced to kill the process. This usually does not happen at the beginning of the session. The problem seems to arise when the system opens the dialog window to choose the directory and file name. (R version 2.6.1 under Windows XP) Thank you all Giovanni __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] two histograms in the same graph
On 1/24/2008 9:43 AM, Juan Pablo Fededa wrote: Dear Contributors: I have two vectors x and z, and I want to display the histograms of both vectors in the same graph, x in red bars, z in blue bars. If you have any clue on how to do that, I will be very glad to hear it!! It's hard to design a graph like this that looks good, but it's easy to draw using add=TRUE: x - rnorm(1000) y - rnorm(1000, mean=1) breaks - pretty(range(c(x,y)), 20) hist(x, breaks=breaks, col='red', main=Hist of x and y) hist(y, breaks=breaks, add=TRUE, border='blue') Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Ryacas behaving weird
There is either something wrong with either me or is Yacas/Ryacas doing odd things. See below I ask to simpify an expression and the there's output! If this is a simplification.. well.. Do you think there is something set wrong somewhere. Thanks. library(Ryacas) Loading required package: XML a=Sym(a) N=Sym(N) b=Sym(b) E=Sym(E) Simplify( + a * ((1/(b + E) - b/(b + E)^2)/(b/(b + E))) - N * ((1/(b + E) - + b/(b + E)^2)/(1 - (b/(b + E + ) [1] Starting Yacas! expression((a * b^5 * E^2 + 5 * (a * b^4 * E^3) + 10 * (a * b^3 * E^4) + 10 * (a * b^2 * E^5) + 5 * (a * b * E^6) + a * E^7 + (-5 * (b^5 * E^2 * N) - b^6 * E * N - 10 * (b^4 * E^3 * N) - 10 * (b^3 * E^4 * N) - 5 * (b^2 * E^5 * N) - b * E^6 * N))/(b^7 * E + 6 * (b^6 * E^2) + 15 * (b^5 * E^3) + 20 * (b^4 * E^4) + 15 * (b^3 * E^5) + 6 * (b^2 * E^6) + b * E^7)) -- View this message in context: http://www.nabble.com/Ryacas-behaving-weird-tp15065744p15065744.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] Calculating sum of squares from density estimates
Rainer M Krug [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Hi I have some density estimates obtained from density(). I would like to calculate the sum of squares of these. As the x values of the estimates are not the same, and I would prefer not to restrict the estiomate to a certain range of x values, how can I do the calculation? Lets say: d1 - density(Data1) d2 - density(Data2) If the x values would be the same, I would: ssq - sum( (d1$y - d2$y)^2 ) but as it isn't, I can't do that. is there an easy way to get the sum of squares? Presumably there is a common domain for these densities. Consider forcing the x values to be the same by identically specifying n=, from=, and to=? ?density x - rnorm(200,1,1) x2 - rnorm(200,1,1) d1 - density(x, n=512, from=-1, to= 4) d2 - density(x2, n=512, from=-1, to= 4) ssq - sum( (d1$y - d2$y)^2 ) ssq [1] 0.4722924 x - rnorm(200,1,1) x2 - rnorm(200,1.5,1) d1 - density(x, n=512, from=-1, to= 4) d2 - density(x2, n=512, from=-1, to= 4) ssq - sum( (d1$y - d2$y)^2 ) ssq [1] 2.111498 -- David Winsemius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] image question
Here is another approach that may or may not be easier: library(TeachingDemos) x - 0:4 y - 0:20 z - matrix( runif(80), ncol=20 ) image(x,y,z) clipplot( image(x,y,z, col=heat.colors(12), add=TRUE), xlim=c(0,1) ) clipplot( image(x,y,z, col=terrain.colors(12), add=TRUE), xlim=c(1,2) ) clipplot( image(x,y,z, col=topo.colors(12), add=TRUE), xlim=c(2,3) ) clipplot( image(x,y,z, col=cm.colors(12), add=TRUE), xlim=c(3,4) ) Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Charles C. Berry Sent: Wednesday, January 23, 2008 4:37 PM To: Ajar Cc: R-help@r-project.org Subject: Re: [R] image question On Wed, 23 Jan 2008, Ajar wrote: Hi, I have a question regarding the image function. Is there a way to specify a separate color set for each column in the matrix? Yes. But it will require some attention to the scaling of your matrix. This shows how it might be done: mat - matrix( runif(100), nc=10) image( mat + rep( 1:2, each=50),col=c(topo.colors(10),heat.colors(10))) Add an offset to the matrix to choose a different color scheme. Of course, the step size for the offset needs to be greater than or equal to the range of values that you are representing. You will need to specify zlim to be sure this works right. HTH, Chuck TIA, ajar. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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:[EMAIL PROTECTED]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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Barplot w/ single stacked bar
Hi All, I can get the barplot function to do many types of plots, stacked or otherwise. However, I cannot get it to do a *single* stacked bar. I've searched several books listserv archives to no avail. I suspect I'm missing the obvious from the help file! I can reach my goal in ggplot2, although the relative heights of the bar's pieces don't seem quite right (it does generate a warning): library(ggplot2) x-factor(1) y-factor( c(Male,Male,Female) ) mydata - data.frame(x,y) rm(x,y) mydata #These are close to my goal: qplot( x, y, fill=y, geom=bar, data=mydata) # or ggplot(mydata, aes(x=x, y=y, fill=y)) + geom_bar() # But this places the bars beside each other rather than stack them. barplot( table(mydata$y), beside=FALSE) Thanks! Bob = Bob Muenchen (pronounced Min'-chen), Manager Statistical Consulting Center U of TN Office of Information Technology 200 Stokely Management Center, Knoxville, TN 37996-0520 Voice: (865) 974-5230 FAX: (865) 974-4810 Email: [EMAIL PROTECTED] Web: http://oit.utk.edu/scc, News: http://listserv.utk.edu/archives/statnews.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] R help?
Use summary on the fitted lm object, i.e.: fit - lm(y ~ x, data=mydata) summary(fit) And the t-tests will be printed (along with a bunch of other stuff). You can also save the results of summary if you want to use the t-values and p-values for something else. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of vic zhong Sent: Thursday, January 24, 2008 2:07 AM To: r-help@r-project.org Subject: [R] R help? Hey does anyone know how to do t.test for beta1 and beta0, which are the slope and intercept of the linear regression 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] TAF/METAR decoder
Hi, I'm looking for a script to translate TAF/METAR code into comprehensive text that I can include in a R-script (METAR is the international standard code format for hourly surface weather observations). I haven't seen anything in the libraries. Do you think such a thing exists for R ? Thanks in advance for your help, Ptit Bleu. -- View this message in context: http://www.nabble.com/TAF-METAR-decoder-tp15068796p15068796.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] plot help
Look at the examples for cnvrt.coords in the TeachingDemos package, they might give you some ideas to accomplish what you want. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tom soyer Sent: Wednesday, January 23, 2008 8:14 PM To: r-help@r-project.org Subject: [R] plot help Hi, Suppose I already have two plots on the same screen, and I want to draw lines in each of them. Is that possible in R? It seems that once you have two plots on the screen, you can only draw lines in the the last plot, never the 1st. Here is what I mean: #some data y1=rnorm(1:3) y2=rnorm(1:3) #draw two plots on the same screen par(mfrow=c(2,1),oma = c(6, 0, 5, 0)) par(mar=c(0, 5.1, 0, 5.1)) plot(y1,xaxt=n,type=n) #1st plot par(mar=c(0, 5.1, 0, 5.1)) plot(y2,xaxt=n,type=n) #2nd plot #try to draw lines onto each plot on the screen lines(y2) #draws a line in the 2nd plot lines(y1,col=2) #also draws a line in the 2nd plot, but that's not what I want. I want to draw the line in the 1st plot instead. Does anyone know if after more than one plot were drawn, can I still call the 1st plot and draw a line in it? Thanks, -- Tom [[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] Barplot w/ single stacked bar
Muenchen, Robert A (Bob) wrote: Hi All, I can get the barplot function to do many types of plots, stacked or otherwise. However, I cannot get it to do a *single* stacked bar. I've searched several books listserv archives to no avail. I suspect I'm missing the obvious from the help file! I can reach my goal in ggplot2, although the relative heights of the bar's pieces don't seem quite right (it does generate a warning): library(ggplot2) x-factor(1) y-factor( c(Male,Male,Female) ) mydata - data.frame(x,y) rm(x,y) mydata #These are close to my goal: qplot( x, y, fill=y, geom=bar, data=mydata) # or ggplot(mydata, aes(x=x, y=y, fill=y)) + geom_bar() # But this places the bars beside each other rather than stack them. barplot( table(mydata$y), beside=FALSE) Thanks! Bob Bob, Try this: barplot(as.matrix(table(mydata$y)), beside = FALSE) Conceptually, for a stacked bar, each bar is a column in a matrix. The components in a stacked bar are the row values in the column. Thus, you need to create a single column matrix from your table. One might question the value of such a plot however, if the intent is to provide a visual representation of the difference in counts/proportions between two groups. A side-by-side barplot or a dotchart would seem to be better here. 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] adjustment on the x-axis scale width
Specify xlim and ylim in the plot function to set the limits on the x/y axis. See ?plot.default for details. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of mohamed nur anisah Sent: Thursday, January 24, 2008 5:37 AM To: r-help@r-project.org Subject: [R] adjustment on the x-axis scale width Hi, I have sucessfully plotted the graph by using the following command: ec-rep(0,length(e)) fc-rep(0,length(f)) plot(e,ec,type=p,col=1,pch=19) points(f,fc,col=2,pch=20) legend(1.0e+08,1.0,c(dog, human),text.col=green4,pch=c(19,20),col=c(1,2)) Below are the values for e and f...the questions is how am i going to adjust the scale width of my x-axis and my y-axis will start at 0?? Any suggestion?? thanks in advance!! e: [1] 17358865 17966995 21306539 27880531 34166504 36111044 36266288 [8] 36854306 43786190 44322336 45529444 46302360 53479132 58567262 [15] 60564442 72637088 79875476 93155112 94372260 96643396 103123936 [22] 116908456 131781664 132968364 135945080 141788832 149924864 156539568 [29] 157817896 162399496 168344072 173146584 176302744 182878168 183946152 [36] 185068720 190791232NA f-[1] 17906353 21295547 27880531 34118702 35395488 36132622 37916920 [8] 43786190 44322336 46302360 53494622 62105336 63817440 72637088 [15] 79875476 94545992 96506368 103123936 116908456 126190072 127446552 [22] 131781664 154658264 176302744 181670472 182625272 182878168 183946152 [29]NA cheers, Anisah - [[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] readClipboard() from spreadsheet to data.frame with column names?
This code opens a CSV file from the working directory set by wd. I copy 2 or more columns in the spreadsheet and then close it. What I need help with is setting the first row as the column names in clipboardTextAsDF. There is probably a simple or better way to do this but I have been away from R for awhile now. I just be over-thinking this. I tried read.DIF to read the clipboard but that didn't work as I had hoped. writeClipboard(rownames(state.x77), format=1) #A paste, Ctrl+V in any Application should now list United States State names. statex77 - cbind(State=rownames(state.x77), state.x77) wd - b:/Chapter11/ setwd(wd)#Note use of / rather than \ write.csv(statex77, file=StateX77.csv, row.names=FALSE) getwd() StateX77CSV - paste(wd,StateX77.csv,sep=) shell(StateX77CSV) #Might open Excel rather than QP #data.entry(statex77) #Show statex77 in an interactive spreadhseet manner clipboardText - strsplit(readClipboard(format=1), \t) clipboardTextAsDF - t(data.frame(clipboardText)) data.entry(clipboardTextAsDF) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Printing large number
There is more than one way, but probably the easiest is to set options(scipen= some big number). See ?options for details. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of alex lam (RI) Sent: Thursday, January 24, 2008 6:34 AM To: r-help@r-project.org Subject: [R] Printing large number Dear R users, Just a quick question, how do I prevent 10 printed as 1e+05 when I print it into a file? Thanks, Alex Alex C. Lam Roslin Institute (Edinburgh) Midlothian EH25 9PS United Kingdom Tel: +44 131 5274471 Roslin Institute is a company limited by guarantee, registered in Scotland (registered number SC157100) and a Scottish Charity (registered number SC023592). Our registered office is at Roslin, Midlothian, EH25 9PS. VAT registration number 847380013. The information contained in this e-mail (including any attachments) is confidential and is intended for the use of the addressee only. The opinions expressed within this e-mail (including any attachments) are the opinions of the sender and do not necessarily constitute those of Roslin Institute (Edinburgh) (the Institute) unless specifically stated by a sender who is duly authorised to do so on behalf of the Institute __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fortran level mismatch between package and R
On Jan 18, 2008, at 5:57 PM, Hesen Peng wrote: Hi, I recompiled R using gfortran in my personal laptop. But I think it may help if you build an agent C program which calls the FORTRAN program, and then call the C program from R. I'm also curious on how to solve this problem without too much work. Please let me know if you find a good solution. Nothing turned up; we're going to try our first fallback (installing R built with gfortran and retaining the old with f77). Steve __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bar width and labels in barchart
On 1/23/08, Spilak,Jacqueline [Edm] [EMAIL PROTECTED] wrote: Hi everyone I am using barchart to make my graphs. Here is my code. barchart(percent_below ~ factor(Year)| factor(Season, levels=unique(Season)), data= .season_occurrence, origin = 0, layout = c(4, 1), scales=list(tick.number=ticknum,labels=NULL), ylim=c(0, ymax), group = factor(Year), xlab= Year, auto.key = list(points = FALSE, rectangles = TRUE,space=right,size=2,cex=0.8), upper_2007 = c(upper_limit_winter, upper_limit_spring, upper_limit_summer, upper_limit_autumn), par.settings = list(superpose.polygon = list(col=c(color1,color2,color3,color4,color5,color6,color7,color8))), lower_2007 = c(lower_limit_winter, lower_limit_spring, lower_limit_summer, lower_limit_autumn), panel = function(..., upper_2007,lower_2007) { panel.abline(h = upper_2007[packet.number()]) panel.abline(h = lower_2007[packet.number()]) panel.barchart(...) }) This code gives me a graph with four panels, one for each season, and then the percent_below is shown per year in each panel. I wanted each year to have a color associated with it so I added group = factor(Year) this worked and gave me what I wanted, however now the bars are very skinny and it is hard to distinguish the colors. How do I make them wider? My other question is that on the x-axis it list all years (2000-2007, inclusively) for each panel and they are squished and non-legable, can I get rid of them? They are not necessary as I have the years color coded with the legend at the side. Does having stack=TRUE help? If you have year as the x-variable, barchart will try to label them. You could control the labels using 'scales', but I think having some other variable as the x-variable might be the better solution. We need a (minimal) reproducible example to give more definite advice. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Barplot w/ single stacked bar
Marc Eric, Thanks so much for the help. That is exactly what I was looking for. I should have mentioned that I don't really like this plot, but I'm writing an explanation of the Grammar of Graphics concept. A very nice example of that is that a single stacked bar chart converts to a pie chart when you change from Cartesian to polar coordinates. And yes, that may well be going from bad to worse! Thanks! Bob = Bob Muenchen (pronounced Min'-chen), Manager Statistical Consulting Center U of TN Office of Information Technology 200 Stokely Management Center, Knoxville, TN 37996-0520 Voice: (865) 974-5230 FAX: (865) 974-4810 Email: [EMAIL PROTECTED] Web: http://oit.utk.edu/scc, News: http://listserv.utk.edu/archives/statnews.html = -Original Message- From: Marc Schwartz [mailto:[EMAIL PROTECTED] Sent: Thursday, January 24, 2008 11:32 AM To: Muenchen, Robert A (Bob) Cc: [EMAIL PROTECTED] Subject: Re: [R] Barplot w/ single stacked bar Muenchen, Robert A (Bob) wrote: Hi All, I can get the barplot function to do many types of plots, stacked or otherwise. However, I cannot get it to do a *single* stacked bar. I've searched several books listserv archives to no avail. I suspect I'm missing the obvious from the help file! I can reach my goal in ggplot2, although the relative heights of the bar's pieces don't seem quite right (it does generate a warning): library(ggplot2) x-factor(1) y-factor( c(Male,Male,Female) ) mydata - data.frame(x,y) rm(x,y) mydata #These are close to my goal: qplot( x, y, fill=y, geom=bar, data=mydata) # or ggplot(mydata, aes(x=x, y=y, fill=y)) + geom_bar() # But this places the bars beside each other rather than stack them. barplot( table(mydata$y), beside=FALSE) Thanks! Bob Bob, Try this: barplot(as.matrix(table(mydata$y)), beside = FALSE) Conceptually, for a stacked bar, each bar is a column in a matrix. The components in a stacked bar are the row values in the column. Thus, you need to create a single column matrix from your table. One might question the value of such a plot however, if the intent is to provide a visual representation of the difference in counts/proportions between two groups. A side-by-side barplot or a dotchart would seem to be better here. 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] problems with .svg
I suspect you have ignored 'If you are using an old version of R and think it does not work properly, upgrade to the latest version and try that, before posting.' (from the posting guide). You didn't tell us your R version (as we asked in the posting guide) and so we have assumed it was the latest version given that quote. RSvgDevice needs R = 2.6.0, as http://cran.at.r-project.org/src/contrib/Descriptions/RSvgDevice.html shows (linked from the page quoted below). Please do update your R if it is earlier. On Thu, 24 Jan 2008, Mag. Ferri Leberl wrote: Dear everybody, I still didn't manage to install the RSvgDevice-Package. Please, note the attached file: The server cannot seriousely be the problem. I would be glad if you could find the mistake. Thank you in advance. Yours, Mag. Ferri Leberl Am Sonntag, den 20.01.2008, 18:29 + schrieb Prof Brian Ripley: On Sun, 20 Jan 2008, Mag. Ferri Leberl wrote: The program does not open the interface again to select am mirror. Neither works install.packages(RSvgDevice, dependencies = TRUE, repos=http://cran.r-project.org,contriburl=http://cran.r-project.org;) the feedback here is Warnung in install.packages(RSvgDevice, dependencies = TRUE, repos = http://cran.r-project.org;, : argument 'lib' is missing: using '/home/nemo/R/i486-pc-linux-gnu-library/2.5' Warnung: unable to access index for repository http://cran.r-project.org Warning message: package ‘RSvgDevice’ is not available in: install.packages(RSvgDevice, dependencies = TRUE, repos = http://cran.r-project.org;, What is going wrong? You incorrectly specified contriburl: you only need repos, and giving contriburl incorrectly is the reason for the message you got. I suspect chooseCRAN mirror() failed because the CRAN master was inaccessible: it has been from here on and off all day. In which case you will need to select a different mirror. Yours, Leberl Am Sonntag, den 20.01.2008, 16:34 +0100 schrieb Gabor Csardi: Yes, try another mirror. Austria should work. Or go to http://cran.at.r-project.org/src/contrib/PACKAGES.html and download the package directly and install it via R CMD INSTALL package_file You might need to give the '-l' options for where to install to. G. On Sun, Jan 20, 2008 at 03:49:22PM +0100, Mag. Ferri Leberl wrote: Thank you so far. install.packages(RSvgDevice, dependencies = TRUE) returns Warnung in install.packages(RSvgDevice, dependencies = TRUE) : argument 'lib' is missing: using '/usr/local/lib/R/site-library' Warnung in install.packages(RSvgDevice, dependencies = TRUE) : 'lib = /usr/local/lib/R/site-library' is not writable Would you like to create a personal library '~/R/i486-pc-linux-gnu-library/2.5' to install packages into? (y/n) y --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done Warning message: package ‘RSvgDevice’ is not available in: install.packages(RSvgDevice, dependencies = TRUE) When asked I chose for the Bamberg-mirror. Can you recognize a mistake? Should I chose for a different mirror? Thank you in advance. Yours, Mag. Ferri Leberl Am Montag, den 14.01.2008, 19:21 +0100 schrieb Gabor Csardi: Are you sure this is an R problem? I guess it is not, but rather a pstoedit problem. You can use the RSVGDevice package, or the Cairo package to export your graphics directly into SVG from R. Gabor On Mon, Jan 14, 2008 at 07:10:13PM +0100, Mag. Ferri Leberl wrote: Dear everybody! I am making a graph in R and employ pstoedit to expot the .pdf-output to .svg. When I open the .svg with firefox I get the .svg-code shown wit the following header: Mit dieser XML-Datei sind anscheinend keine Style-Informationen verknüpft. Nachfolgend wird die Baum-Ansicht des Dokuments angezeigt. Which information should how be included? Thank you in advance. Yours, Mag. Ferri Leberl -- Brian D. Ripley, [EMAIL PROTECTED] 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.
[R] Using and external text editor with R
I am a new user of Crimson editor and was hoping that someone could help me to integrate Crimson Editor to run programs in R. I have tried the following and I receive an error message stating Argument Ignored. Command: C:\Program Files\R\R-2.6.0\bin\Rgui.exe Argument: $(FileName) $(FileDir) Initial Dir: $(FileDir) Thanks Stephanie -- View this message in context: http://www.nabble.com/Using-and-external-text-editor-with-R-tp15070068p15070068.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] boxplot axis labelling
Hi, i'm very new to R, so sorry for what i'm sure is a very basic question. I'm producing a boxplot with the data below: df3-data.frame( x=c(10,11,115,12,13,14,16,17,18,21,22,23,24,26,27,28,29,3,30,32,33,34,35,4,4 1,45,5,50,52,56,58,6,67,6738,68,7,8,9), fq=c(8,11,1,2,4,4,2,2,6,3,4,2,2,1,1,1,4,51,3,1,1,1,1,35,1,1,19,2,1,1,1,14,1, 1,1,10,13,5), fqcvd=c(5,8,1,1,3,3,2,2,5,3,4,2,2,0,1,1,3,13,2,1,1,1,1,17,1,0,11,2,1,1,1,7,1 ,1,1,7,7,1), fqcan=c(1,1,0,2,1,1,1,0,3,0,2,0,1,0,1,0,1,4,2,1,1,0,0,4,1,1,2,2,0,1,0,2,0,1, 1,2,3,1), fqnoncan=c(8,11,0,2,4,4,2,0,6,0,4,0,2,0,1,0,4,50,3,1,1,0,0,35,1,1,19,2,0,1,0 ,14,0,1,1,10,13,5)) k3-with(df3,rep(x,times=fq)) kcvd3-with(df3,rep(x,times=fqcvd)) kcvd3-c(kcvd3,rep(NA,times=length(k3)-length(kcvd3))) kcan3-with(df3,rep(x,times=fqcan)) kcan3-c(kcan3,rep(NA,times=length(k3)-length(kcan3))) knoncan3-with(df3,rep(x,times=fqnoncan)) knoncan3-c(knoncan3,rep(NA,times=length(k3)-length(knoncan3))) dfnew-data.frame(kcvd3,kcan3,knoncan3,k3) boxplot(dfnew,log='y', ylim=c(1,4000)) This produces x axis labels 'kcvd3,kcan3,knoncan3,k3', one for each plot as you might expect. However, I would like all plot to sit next to each other with a single label. Could anybody help? cheers Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 cpa in R
hi, iam working with cpa method ade4 and want to simulate with this mehod is it possible and how ? thank you - [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Maximum entropy spectral analysis
Nuno Prista nmprista at fc.ul.pt writes: Is there on R a package containing Maximum entropy spectral analysis function? Burg and Yule-Walker are in spec.ar(stats) 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] Filling data frame data into a matrix - please help
Dear group, I have a data.frame (d1) with various elements and a matrix (m1) created with NA (or 1s). I want to read each row,column in d1 and fill its numeric value in m1. Could some one help me because I have 130K rows and 500 column data.frame object and I was told that a for loop will take a long time. Thank you. r1 - c(A,A,B,B) c1 - c(Apple,Andy,Boy,Ball) v1 - as.numeric(c(0.001,0.02,0.3,NA)) d1 - cbind(r1,c1,as.numeric(v1)) d1 - data.frame(d1) d1 r1c1V3 1 A Apple 0.001 2 A Andy 0.02 3 B Boy 0.3 4 B Ball NA m1 - matrix(NA,2,4) rownames(m1)- unique(r1) colnames(m1)-unique(c1) m1 Apple Andy Boy Ball ANA NA NA NA BNA NA NA NA I want to have: result: Apple Andy Boy Ball A 0.001 0.02 NANA B NA NA0.3 NA thanks Srini Be a better friend, newshound, and __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] latex{Hmisc} cannot find xdvi on MAC OS X
. I also have an issue on the Mac getting latex(describe(iris)) to work. I get the .tex file but this error: latex(describe(iris)) This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) %-line parsing enabled. entering extended mode (/var/folders/AJ/AJjttUSSFdSi1HiInJZyYTI/-Tmp-//RtmpY5vKOM/ file10d63af1.tex LaTeX2e 2005/12/01 Babel v3.8h and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, arabic, basque, bulgarian, coptic, welsh, czech, slovak, german, ng erman, danish, esperanto, spanish, catalan, galician, estonian, farsi, finnish, french, greek, monogreek, ancientgreek, croatian, hungarian, interlingua, ibyc us, indonesian, icelandic, italian, latin, mongolian, dutch, norsk, polish, por tuguese, pinyin, romanian, russian, slovenian, uppersorbian, serbian, swedish, turkish, ukenglish, ukrainian, loaded. (/usr/local/texlive/2007/texmf-dist/tex/latex/base/report.cls Document Class: report 2005/09/16 v1.4f Standard LaTeX document class (/usr/local/texlive/2007/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2007/texmf-dist/tex/latex/setspace/setspace.sty Package: `setspace' 6.7 2000/12/01 ) (/usr/local/texlive/2007/texmf-dist/tex/latex/ltxmisc/relsize.sty) (/usr/local/texlive/2007/texmf-dist/tex/latex/geometry/geometry.sty (/usr/local/texlive/2007/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2007/texmf-dist/tex/xelatex/xetexconfig/ geometry.cfg)) No file file10d63af1.aux. [1] (./file10d63af1.aux) ) Output written on file10d63af1.dvi (1 page, 4264 bytes). Transcript written on file10d63af1.log. sh: xdvi: command not found For LaTeX installation I used MacTeX 2007 live, which places files in a way that will allow multiple TeX installations. I sometimes have problems with TeX from the command line, but not with TeXShop which is the GUI that comes with the bundle. Where TeX gets installed for the Mac is described here: http://www.tug.org/mactex/ and http://www.tug.org/mactex/whatgetsinstalledwhere.html Finally, in the .tex file created above, several % were not escaped (I had to do that manually), and the text style {\smaller } is not on my TeX installation. \footnotesize is. Also I had to guess at the some of the packages required to get the latex to compile (e.g., setspacing). But otherwise, pretty dang nifty. -Dave -- David C. Airey, Ph.D. Pharmacology Research Assistant Professor Center for Human Genetics Research Member Vanderbilt University Medical Center __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Filling data frame data into a matrix - please help
Try this: d1 - data.frame(d1) d1$V3 - as.numeric(as.character(d1$V3)) xtabs(V3 ~ r1+c1, data=d1) You can substitute 0 with NA: d1.tb - xtabs(V3 ~ r1+c1, data=d1) d1.tb[d1.tb==0] - NA On 24/01/2008, Srinivas Iyyer [EMAIL PROTECTED] wrote: Dear group, I have a data.frame (d1) with various elements and a matrix (m1) created with NA (or 1s). I want to read each row,column in d1 and fill its numeric value in m1. Could some one help me because I have 130K rows and 500 column data.frame object and I was told that a for loop will take a long time. Thank you. r1 - c(A,A,B,B) c1 - c(Apple,Andy,Boy,Ball) v1 - as.numeric(c(0.001,0.02,0.3,NA)) d1 - cbind(r1,c1,as.numeric(v1)) d1 - data.frame(d1) d1 r1c1V3 1 A Apple 0.001 2 A Andy 0.02 3 B Boy 0.3 4 B Ball NA m1 - matrix(NA,2,4) rownames(m1)- unique(r1) colnames(m1)-unique(c1) m1 Apple Andy Boy Ball ANA NA NA NA BNA NA NA NA I want to have: result: Apple Andy Boy Ball A 0.001 0.02 NANA B NA NA0.3 NA thanks Srini Be a better friend, newshound, and __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Filling data frame data into a matrix - please help
Dear Henrique, thanks for the tip. One question though: how do I get back a matrix out of d1.tb. d1.tb is an xtabs object. I tried: myres - ftable(d1.tb) myre1 - as.data.frame(myres) now myres1 is nor a matrix or a df. I want d1.tb as a matrix. Please suggest. thanks srini --- Henrique Dallazuanna [EMAIL PROTECTED] wrote: Try this: d1 - data.frame(d1) d1$V3 - as.numeric(as.character(d1$V3)) xtabs(V3 ~ r1+c1, data=d1) You can substitute 0 with NA: d1.tb - xtabs(V3 ~ r1+c1, data=d1) d1.tb[d1.tb==0] - NA On 24/01/2008, Srinivas Iyyer [EMAIL PROTECTED] wrote: Dear group, I have a data.frame (d1) with various elements and a matrix (m1) created with NA (or 1s). I want to read each row,column in d1 and fill its numeric value in m1. Could some one help me because I have 130K rows and 500 column data.frame object and I was told that a for loop will take a long time. Thank you. r1 - c(A,A,B,B) c1 - c(Apple,Andy,Boy,Ball) v1 - as.numeric(c(0.001,0.02,0.3,NA)) d1 - cbind(r1,c1,as.numeric(v1)) d1 - data.frame(d1) d1 r1c1V3 1 A Apple 0.001 2 A Andy 0.02 3 B Boy 0.3 4 B Ball NA m1 - matrix(NA,2,4) rownames(m1)- unique(r1) colnames(m1)-unique(c1) m1 Apple Andy Boy Ball ANA NA NA NA BNA NA NA NA I want to have: result: Apple Andy Boy Ball A 0.001 0.02 NANA B NA NA0.3 NA thanks Srini Be a better friend, newshound, and __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O Looking for last minute shopping deals? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 should I organize data to compare differences in matched pairs?
I'm just learning how to use R right now, so I'm not sure what the most efficient way to organize these data is. I had subjects perform the same task twice with slight changes between the rounds. I want to analyze differences between the rounds. All of the subjects also answered a questionnaire. Putting all of one subject's information on one row seems sloppy. I was thinking about making a three-dimensional array with subject number, round and measurement as axes, but then the differences would have to be the third column in the round axis, which also seemed messy. Also, I would have duplicates of all of the information from the questionnaire, which seems inefficient. Or maybe I could just use a matrix where round is just another column among all of the measurements. This is similar to the previous arrangement, but I don't know which is better. It still has all of the duplicated information that the previous method has. Anyway, I'm sure someone's done this before, so I'd like to see what other people have done for data like these. Thomas Levine [[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] testing coeficients of glm
Dear list, i'm trying to test if a linear combination of coefficients of glm is equal to 0. For example : class 'cl' has 3 levels (1,2,3) and 'y' is a response variable. We want to test H0: mu1 + mu2 - mu3 =0 where mu1,mu2, and mu3 are the means for each level. for me, the question is how to get the covariance matrix of the estimated parameters from glm. but perhaps there is a direct solution in one of the packages. i know how to solve this particular problem (i wrote it below) but i'm curious about the covariance matrix of coefficient as it seems to be important. the R code example : ### nObs - 10 cl - as.factor( sample(c(1,2,3),nObs,replace=TRUE) ) y - rnorm(nObs) model - glm(y ~ cl) b - model$coefficients H - c(1,1,-1) # we want to test H0: Hb = 0 ### the following code will NOT run unless we can compute covModelCoeffs #the mean of Hb is mu = H %*% model$coefficients #the variance is HB is var = H %*% covModelCoeffs %*% t(H) p.val - 2 * pnorm( -abs(mu), mean=0, sd=sqrt(var),lower.tail = TRUE) how do i get the covariance matrix of the estimated parameters ? thanks, peter P.S. the simple solution for this particular problem: ## get the mean for each level muV - by(y,cl,mean) ## get the variance for each level varV - by(y,cl,var) ## the mean of Hb is muHb - H %*% muV ## because of independence, the variance of Hb is varHb - sum(varV) ## the probability of error, so-called p-value: p.val - 2 * pnorm( -abs(muHb), mean=0, sd=sqrt(varHb),lower.tail = TRUE) thanks again, peter -- Peter Salzman, PhD Department of Biostatistics and Computational Biology University of Rochester [[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] JRI problem with R 2.6.1
Hello Members, I wonder if someone also having a problem with JRI using new R 2.6.1. To illustrate the problem, there is a simple Java driver problem below. The program runs just fine on the other computer with R 2.5.1, but does not run with R 2.6.1. It gives me no error messages either. Needles to say, I have jri.dll at the classpath. Also, I have downloaded the rJava package from R program (packages install packages rJava), so version must be correct. Any suggestions are highly appreciated, Thanks, Vlad import org.rosuda.JRI.Rengine; public class Driver { public static void main(String[] args){ try { String[] arg = {}; Rengine re = new Rengine(arg, false, null); if (!Rengine.versionCheck()) { Rengine.getVersion(); System.err.println(** Version mismatch); System.exit(1); } if (!re.waitForR()) { System.out.println(** Cannot load R); System.exit(1); } double d = re.eval(3+5).asDouble(); System.out.print(D = + d); } catch (RuntimeException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Reshaping a dataframe with conditional summary of columns - apply or reshape?
Try this: x$survey1[x$count==0] - 0 x$survey1[x$count %in% 1:11] - 1 x$survey1[x$count 11] - 2 x.wide - reshape(x, v.names=survey1, idvar=location, timevar=survey1, direction=wide) x.wide - x.wide[order(x.wide$location),] x.wide$var1 - tapply(x$var1, x$location, mean) x.wide On 24/01/2008, Dave Hewitt [EMAIL PROTECTED] wrote: I need to do a somewhat complex rearrangement of an existing dataframe that involves an on-the-fly conditional summary as well. I've tried to make the example as simple as possible. Code to produce the object being acted on is at the end of the message. I hope this isn't too much for a single posting. Any guidance will be much appreciated. The input example looks like this: survey yearcount locationvar1var2 1 1 2 A1 21.21 2 1 0 A1 15.61 3 1 29 A1 12.11 1 1 11 B3 9 2 3 1 5 B3 4.8 2 1 2 7 A2 20.14 2 2 2 A2 19.24 I need to rearrange it to look like this (the order of the columns is not important): locationyearsurvey1 survey2 survey3 var1summvar2 A1 1 1 0 2 16.31 B3 1 2 NA 1 6.9 2 A2 2 1 1 NA 19.74 The operations/conditions that I need are: (A) The observations in count for each survey at each location in a given year need to be reduced according to the following rules and then placed in new columns survey1, survey2, survey3 : -- when count = 0, surveyX = 0 -- when 0 count 11, surveyX = 1 -- when 11 count, surveyX = 2 (B) The observations in var1 need to be summarized (here, by taking the mean) across all surveys for a given location in a given year and placed in var1summ (C) Observations in var2 need to be summarized in a similar way, except that they don't change across surveys for a given location in a given year (so mean, median, etc. would work, but a more general solution would be nice for variables that are categorical) (D) Surveys (rows) can be missing for a given location in a given year. I'd like to retain a column for each survey in the new dataframe and denote surveys that were missing as NA. E.g., survey2 is missing for location B3 in year 1. ** Object creation: x - structure(list(survey = c(1L, 2L, 3L, 1L, 3L, 1L, 2L), year = c(1L, 1L, 1L, 1L, 1L, 2L, 2L), count = c(2L, 0L, 29L, 11L, 5L, 7L, 2L), location = structure(c(1L, 1L, 1L, 3L, 3L, 2L, 2L), .Label = c(A1, A2, B3), class = factor), var1 = c(21.2, 15.6, 12.1, 9, 4.8, 20.1, 19.2), var2 = c(1L, 1L, 1L, 2L, 2L, 4L, 4L)), .Names = c(survey, year, count, location, var1, var2), class = data.frame, row.names = c(NA, -7L)) Thanks, Dave Hewitt Fisheries Science Virginia Institute of Marine Science, Gloucester Point, VA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Filling data frame data into a matrix - please help
Perhaps this helps: myres - d1.tb[] attributes(myres)$call - NULL myres class(myres) If you want remove 'c1' and 'r1' then: names(dimnames(myres)) - NULL class(myres) On 24/01/2008, Srinivas Iyyer [EMAIL PROTECTED] wrote: Dear Henrique, thanks for the tip. One question though: how do I get back a matrix out of d1.tb. d1.tb is an xtabs object. I tried: myres - ftable(d1.tb) myre1 - as.data.frame(myres) now myres1 is nor a matrix or a df. I want d1.tb as a matrix. Please suggest. thanks srini --- Henrique Dallazuanna [EMAIL PROTECTED] wrote: Try this: d1 - data.frame(d1) d1$V3 - as.numeric(as.character(d1$V3)) xtabs(V3 ~ r1+c1, data=d1) You can substitute 0 with NA: d1.tb - xtabs(V3 ~ r1+c1, data=d1) d1.tb[d1.tb==0] - NA On 24/01/2008, Srinivas Iyyer [EMAIL PROTECTED] wrote: Dear group, I have a data.frame (d1) with various elements and a matrix (m1) created with NA (or 1s). I want to read each row,column in d1 and fill its numeric value in m1. Could some one help me because I have 130K rows and 500 column data.frame object and I was told that a for loop will take a long time. Thank you. r1 - c(A,A,B,B) c1 - c(Apple,Andy,Boy,Ball) v1 - as.numeric(c(0.001,0.02,0.3,NA)) d1 - cbind(r1,c1,as.numeric(v1)) d1 - data.frame(d1) d1 r1c1V3 1 A Apple 0.001 2 A Andy 0.02 3 B Boy 0.3 4 B Ball NA m1 - matrix(NA,2,4) rownames(m1)- unique(r1) colnames(m1)-unique(c1) m1 Apple Andy Boy Ball ANA NA NA NA BNA NA NA NA I want to have: result: Apple Andy Boy Ball A 0.001 0.02 NANA B NA NA0.3 NA thanks Srini Be a better friend, newshound, and __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 should I organize data to compare differences in matched pairs?
Putting all the information in one row is going to be the easest for data entry and for analysis. If it's easier you can enter the task information in one data set and the questionnaire in another (with the same unique id ) and merge the data sets later if you need to. All you want is the data in a form that you can read into R, probably as a data.frame. Then do any data manipulations that you want. --- Thomas Levine [EMAIL PROTECTED] wrote: I'm just learning how to use R right now, so I'm not sure what the most efficient way to organize these data is. I had subjects perform the same task twice with slight changes between the rounds. I want to analyze differences between the rounds. All of the subjects also answered a questionnaire. Putting all of one subject's information on one row seems sloppy. I was thinking about making a three-dimensional array with subject number, round and measurement as axes, but then the differences would have to be the third column in the round axis, which also seemed messy. Also, I would have duplicates of all of the information from the questionnaire, which seems inefficient. Or maybe I could just use a matrix where round is just another column among all of the measurements. This is similar to the previous arrangement, but I don't know which is better. It still has all of the duplicated information that the previous method has. Anyway, I'm sure someone's done this before, so I'd like to see what other people have done for data like these. Thomas Levine [[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] step and glm : keep all models
Hi everyone, I'm running the following command: step(mydata.glm,directions=both,trace=T) which returns the model with the lowest AIC. Now I'd like to get the list of all the models (or at least the formulas) that were used in between. I've noticed the keep option, but couldnt find any help on how to use it. Would anyone here be able to help me with this? Thank you. Regards, Sylvain [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How should I organize data to compare differences in matchedpairs?
Here is how I would do it (there are multiple ways you could do it, so there is not single Right answer): Assign each person a unique identifier. Put all the information from the questionaire along with the idenifier and anything else that does not change between rounds (age, sex, height, ...) into one data frame. This df will have as many rows as you have subjects. The round information then goes into a second data frame with each round being a row (each subject has multiple rows) and include the unique identifier on each row for that person. If you need information combined from both data frames, then use the merge function to merge the 2 data frames (or subsets of them) together. Advantages of this method include: Uses data frames which most of the analysis functions expect. Each piece of data is only entered once (other than the id) Disadvantage: Data is split between 2 objects. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Levine Sent: Thursday, January 24, 2008 11:43 AM To: r-help@r-project.org Subject: [R] How should I organize data to compare differences in matchedpairs? I'm just learning how to use R right now, so I'm not sure what the most efficient way to organize these data is. I had subjects perform the same task twice with slight changes between the rounds. I want to analyze differences between the rounds. All of the subjects also answered a questionnaire. Putting all of one subject's information on one row seems sloppy. I was thinking about making a three-dimensional array with subject number, round and measurement as axes, but then the differences would have to be the third column in the round axis, which also seemed messy. Also, I would have duplicates of all of the information from the questionnaire, which seems inefficient. Or maybe I could just use a matrix where round is just another column among all of the measurements. This is similar to the previous arrangement, but I don't know which is better. It still has all of the duplicated information that the previous method has. Anyway, I'm sure someone's done this before, so I'd like to see what other people have done for data like these. Thomas Levine [[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] testing coeficients of glm
On Thu, 24 Jan 2008, peter salzman wrote: Dear list, i'm trying to test if a linear combination of coefficients of glm is equal to 0. For example : class 'cl' has 3 levels (1,2,3) and 'y' is a response variable. We want to test H0: mu1 + mu2 - mu3 =0 where mu1,mu2, and mu3 are the means for each level. for me, the question is how to get the covariance matrix of the estimated parameters from glm. but perhaps there is a direct solution in one of the packages. See ?vcov . BTW, help.search(covariance matrix) finds it. i know how to solve this particular problem (i wrote it below) but i'm curious about the covariance matrix of coefficient as it seems to be important. the R code example : ### nObs - 10 cl - as.factor( sample(c(1,2,3),nObs,replace=TRUE) ) y - rnorm(nObs) model - glm(y ~ cl) b - model$coefficients H - c(1,1,-1) # we want to test H0: Hb = 0 ### the following code will NOT run unless we can compute covModelCoeffs #the mean of Hb is mu = H %*% model$coefficients #the variance is HB is var = H %*% covModelCoeffs %*% t(H) p.val - 2 * pnorm( -abs(mu), mean=0, sd=sqrt(var),lower.tail = TRUE) how do i get the covariance matrix of the estimated parameters ? thanks, peter P.S. the simple solution for this particular problem: ## get the mean for each level muV - by(y,cl,mean) ## get the variance for each level varV - by(y,cl,var) ## the mean of Hb is muHb - H %*% muV ## because of independence, the variance of Hb is varHb - sum(varV) ## the probability of error, so-called p-value: p.val - 2 * pnorm( -abs(muHb), mean=0, sd=sqrt(varHb),lower.tail = TRUE) thanks again, peter -- Brian D. Ripley, [EMAIL PROTECTED] 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] step and glm : keep all models
On Thu, 24 Jan 2008, Sylvain Bertrand wrote: Hi everyone, I'm running the following command: step(mydata.glm,directions=both,trace=T) which returns the model with the lowest AIC. Now I'd like to get the list of all the models (or at least the formulas) that were used in between. I've noticed the keep option, but couldnt find any help on how to use it. Would anyone here be able to help me with this? Did you try the example on the help page? The final display shows you how to see the list of models. Or step(lm1, keep=function(model, aic) formula(model))$keep[1,] (It's a bit peculiar: a formula is of length 3 but prints like length 1.) -- Brian D. Ripley, [EMAIL PROTECTED] 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.
[R] Error using Rmetrics to read data
Hi folks. This set of code used to work, but after upgrading to the latest version of Rmetrics it no longer does. Any ideas? SP500-read.table(SP500.csv,header=TRUE,sep=,) head(SP500) DateOpenHigh Low Close Volume Close2 1 8/4/2006 1280.26 1292.92 1273.82 1279.40 2530970112 1279.40 2 8/3/2006 1278.22 1283.96 1271.25 1280.27 2728440064 1280.27 3 8/2/2006 1270.73 1283.42 1270.73 1277.41 2610749952 1277.41 4 8/1/2006 1278.53 1278.66 1265.71 1270.92 2527689984 1270.92 5 7/31/2006 1278.53 1278.66 1274.31 1276.66 2461299968 1276.66 6 7/28/2006 1263.15 1280.42 1263.15 1278.55 2480420096 1278.55 SP500-as.timeSeries(SP500) Error in .midnightStandard(charvec, format) : 'charvec' has non-NA entries of different number of characters [[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] Alternating numbers in rep()
All, I'm trying to obtain a one-liner to generate a certain sequence of alternatign numbers. Consider: unlist(rep(list(c(1,2), c(3,4)), each = 6)) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 I'd like the result to be as above but continue until 38. Of course, I could hardcode this going up to c(37,38), but is there a more elegant way? Thanks! David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] testing coeficients of glm
thank you, peter On 1/24/08, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Thu, 24 Jan 2008, peter salzman wrote: Dear list, i'm trying to test if a linear combination of coefficients of glm is equal to 0. For example : class 'cl' has 3 levels (1,2,3) and 'y' is a response variable. We want to test H0: mu1 + mu2 - mu3 =0 where mu1,mu2, and mu3 are the means for each level. for me, the question is how to get the covariance matrix of the estimated parameters from glm. but perhaps there is a direct solution in one of the packages. See ?vcov . BTW, help.search(covariance matrix) finds it. i know how to solve this particular problem (i wrote it below) but i'm curious about the covariance matrix of coefficient as it seems to be important. the R code example : ### nObs - 10 cl - as.factor( sample(c(1,2,3),nObs,replace=TRUE) ) y - rnorm(nObs) model - glm(y ~ cl) b - model$coefficients H - c(1,1,-1) # we want to test H0: Hb = 0 ### the following code will NOT run unless we can compute covModelCoeffs #the mean of Hb is mu = H %*% model$coefficients #the variance is HB is var = H %*% covModelCoeffs %*% t(H) p.val - 2 * pnorm( -abs(mu), mean=0, sd=sqrt(var),lower.tail = TRUE) how do i get the covariance matrix of the estimated parameters ? thanks, peter P.S. the simple solution for this particular problem: ## get the mean for each level muV - by(y,cl,mean) ## get the variance for each level varV - by(y,cl,var) ## the mean of Hb is muHb - H %*% muV ## because of independence, the variance of Hb is varHb - sum(varV) ## the probability of error, so-called p-value: p.val - 2 * pnorm( -abs(muHb), mean=0, sd=sqrt(varHb),lower.tail = TRUE) thanks again, peter -- Brian D. Ripley, [EMAIL PROTECTED] 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 -- Peter Salzman, PhD Department of Biostatistics and Computational Biology University of Rochester [[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] Alternating numbers in rep()
This ?? as.vector( outer(0:1, rep(seq(1,37,by=2), each=6), + ) ) On Thu, 24 Jan 2008, David Afshartous wrote: All, I'm trying to obtain a one-liner to generate a certain sequence of alternatign numbers. Consider: unlist(rep(list(c(1,2), c(3,4)), each = 6)) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 I'd like the result to be as above but continue until 38. Of course, I could hardcode this going up to c(37,38), but is there a more elegant way? Thanks! David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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:[EMAIL PROTECTED] 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.
Re: [R] Error using Rmetrics to read data
SP500$Date - as.character(as.Date(as.character(SP500$Date), %m/%d/%y)) SP500-as.timeSeries(SP500) On 24/01/2008, Kerpel, John [EMAIL PROTECTED] wrote: Hi folks. This set of code used to work, but after upgrading to the latest version of Rmetrics it no longer does. Any ideas? SP500-read.table(SP500.csv,header=TRUE,sep=,) head(SP500) DateOpenHigh Low Close Volume Close2 1 8/4/2006 1280.26 1292.92 1273.82 1279.40 2530970112 1279.40 2 8/3/2006 1278.22 1283.96 1271.25 1280.27 2728440064 1280.27 3 8/2/2006 1270.73 1283.42 1270.73 1277.41 2610749952 1277.41 4 8/1/2006 1278.53 1278.66 1265.71 1270.92 2527689984 1270.92 5 7/31/2006 1278.53 1278.66 1274.31 1276.66 2461299968 1276.66 6 7/28/2006 1263.15 1280.42 1263.15 1278.55 2480420096 1278.55 SP500-as.timeSeries(SP500) Error in .midnightStandard(charvec, format) : 'charvec' has non-NA entries of different number of characters [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Alternating numbers in rep()
On Thu, Jan 24, 2008 at 03:03:22PM -0500, David Afshartous wrote: All, I'm trying to obtain a one-liner to generate a certain sequence of alternatign numbers. Consider: unlist(rep(list(c(1,2), c(3,4)), each = 6)) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 I'd like the result to be as above but continue until 38. Of course, I could hardcode this going up to c(37,38), but is there a more elegant way? It is a matter of taste as well, but i think as.vector(apply(matrix(1:38, nr=2), 2, rep, 6)) is not bad. Gabor Thanks! David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Csardi Gabor [EMAIL PROTECTED]UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] two histograms in the same graph
Duncan Murdoch wrote: On 1/24/2008 9:43 AM, Juan Pablo Fededa wrote: Dear Contributors: I have two vectors x and z, and I want to display the histograms of both vectors in the same graph, x in red bars, z in blue bars. If you have any clue on how to do that, I will be very glad to hear it!! It's hard to design a graph like this that looks good, but it's easy to draw using add=TRUE: x - rnorm(1000) y - rnorm(1000, mean=1) breaks - pretty(range(c(x,y)), 20) hist(x, breaks=breaks, col='red', main=Hist of x and y) hist(y, breaks=breaks, add=TRUE, border='blue') Duncan Murdoch This is where frequency polygons can be useful. The basically just play connect-the-dots with the bar tops of the histogram, but since they are transparent, they are more easily overplotted. They are quite a long way towards density estimates, but retaining the feature of the histogram: that it can be explained to the totally uninitiated, with no reference to smoothing kernels and whatnot. freqpoly - function(x, ..., xlab=deparse(substitute(x)), add=FALSE, freq=FALSE) { force(xlab) h - hist(x, ..., plot=FALSE) nbin - length(h$mids) minb - h$breaks[1] maxb - h$breaks[nbin+1] minm - h$mid[1] maxm - h$mid[nbin] xmin - minb - (minm - minb) xmax - maxb + (maxb - maxm) x - c(xmin,h$mid,xmax) y - c(0, if (freq) h$counts else h$density, 0) if (!add) plot(x, y, xlab=xlab, ylab= if (freq) Frequency else Density, type=o, pch=16, ...) else lines(x, y, type=o, pch=16, ...) } freqpoly(x,breaks=breaks) freqpoly(y,breaks=breaks, add=TRUE, col=red) (This is a bit of a rough sketch because ... gets sent to incompatible places) -- 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 ~~ - ([EMAIL PROTECTED]) 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] Error using Rmetrics to read data
But look what happens to the date field: SP500-read.table(SP500.csv,header=TRUE,sep=,) head(SP500) DateOpenHigh Low Close Volume Close2 1 8/4/2006 1280.26 1292.92 1273.82 1279.40 2530970112 1279.40 2 8/3/2006 1278.22 1283.96 1271.25 1280.27 2728440064 1280.27 3 8/2/2006 1270.73 1283.42 1270.73 1277.41 2610749952 1277.41 4 8/1/2006 1278.53 1278.66 1265.71 1270.92 2527689984 1270.92 5 7/31/2006 1278.53 1278.66 1274.31 1276.66 2461299968 1276.66 6 7/28/2006 1263.15 1280.42 1263.15 1278.55 2480420096 1278.55 SP500$Date - as.character(as.Date(as.character(SP500$Date), %m/%d/%y)) SP500-as.timeSeries(SP500) head(SP500) OpenHigh Low Close Volume Close2 2020-08-04 1280.26 1292.92 1273.82 1279.40 2530970112 1279.40 2020-08-03 1278.22 1283.96 1271.25 1280.27 2728440064 1280.27 2020-08-02 1270.73 1283.42 1270.73 1277.41 2610749952 1277.41 2020-08-01 1278.53 1278.66 1265.71 1270.92 2527689984 1270.92 2020-07-31 1278.53 1278.66 1274.31 1276.66 2461299968 1276.66 2020-07-28 1263.15 1280.42 1263.15 1278.55 2480420096 1278.55 -Original Message- From: Henrique Dallazuanna [mailto:[EMAIL PROTECTED] Sent: Thursday, January 24, 2008 2:02 PM To: Kerpel, John Cc: r-help@r-project.org Subject: Re: [R] Error using Rmetrics to read data SP500$Date - as.character(as.Date(as.character(SP500$Date), %m/%d/%y)) SP500-as.timeSeries(SP500) On 24/01/2008, Kerpel, John [EMAIL PROTECTED] wrote: Hi folks. This set of code used to work, but after upgrading to the latest version of Rmetrics it no longer does. Any ideas? SP500-read.table(SP500.csv,header=TRUE,sep=,) head(SP500) DateOpenHigh Low Close Volume Close2 1 8/4/2006 1280.26 1292.92 1273.82 1279.40 2530970112 1279.40 2 8/3/2006 1278.22 1283.96 1271.25 1280.27 2728440064 1280.27 3 8/2/2006 1270.73 1283.42 1270.73 1277.41 2610749952 1277.41 4 8/1/2006 1278.53 1278.66 1265.71 1270.92 2527689984 1270.92 5 7/31/2006 1278.53 1278.66 1274.31 1276.66 2461299968 1276.66 6 7/28/2006 1263.15 1280.42 1263.15 1278.55 2480420096 1278.55 SP500-as.timeSeries(SP500) Error in .midnightStandard(charvec, format) : 'charvec' has non-NA entries of different number of characters [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 using Rmetrics to read data
Yes, in the previous email that I send to you i comment this: you need the %Y SP500$Date - as.character(as.Date(as.character(SP500$Date), %m/%d/%Y)) On 24/01/2008, Kerpel, John [EMAIL PROTECTED] wrote: But look what happens to the date field: SP500-read.table(SP500.csv,header=TRUE,sep=,) head(SP500) DateOpenHigh Low Close Volume Close2 1 8/4/2006 1280.26 1292.92 1273.82 1279.40 2530970112 1279.40 2 8/3/2006 1278.22 1283.96 1271.25 1280.27 2728440064 1280.27 3 8/2/2006 1270.73 1283.42 1270.73 1277.41 2610749952 1277.41 4 8/1/2006 1278.53 1278.66 1265.71 1270.92 2527689984 1270.92 5 7/31/2006 1278.53 1278.66 1274.31 1276.66 2461299968 1276.66 6 7/28/2006 1263.15 1280.42 1263.15 1278.55 2480420096 1278.55 SP500$Date - as.character(as.Date(as.character(SP500$Date), %m/%d/%y)) SP500-as.timeSeries(SP500) head(SP500) OpenHigh Low Close Volume Close2 2020-08-04 1280.26 1292.92 1273.82 1279.40 2530970112 1279.40 2020-08-03 1278.22 1283.96 1271.25 1280.27 2728440064 1280.27 2020-08-02 1270.73 1283.42 1270.73 1277.41 2610749952 1277.41 2020-08-01 1278.53 1278.66 1265.71 1270.92 2527689984 1270.92 2020-07-31 1278.53 1278.66 1274.31 1276.66 2461299968 1276.66 2020-07-28 1263.15 1280.42 1263.15 1278.55 2480420096 1278.55 -Original Message- From: Henrique Dallazuanna [mailto:[EMAIL PROTECTED] Sent: Thursday, January 24, 2008 2:02 PM To: Kerpel, John Cc: r-help@r-project.org Subject: Re: [R] Error using Rmetrics to read data SP500$Date - as.character(as.Date(as.character(SP500$Date), %m/%d/%y)) SP500-as.timeSeries(SP500) On 24/01/2008, Kerpel, John [EMAIL PROTECTED] wrote: Hi folks. This set of code used to work, but after upgrading to the latest version of Rmetrics it no longer does. Any ideas? SP500-read.table(SP500.csv,header=TRUE,sep=,) head(SP500) DateOpenHigh Low Close Volume Close2 1 8/4/2006 1280.26 1292.92 1273.82 1279.40 2530970112 1279.40 2 8/3/2006 1278.22 1283.96 1271.25 1280.27 2728440064 1280.27 3 8/2/2006 1270.73 1283.42 1270.73 1277.41 2610749952 1277.41 4 8/1/2006 1278.53 1278.66 1265.71 1270.92 2527689984 1270.92 5 7/31/2006 1278.53 1278.66 1274.31 1276.66 2461299968 1276.66 6 7/28/2006 1263.15 1280.42 1263.15 1278.55 2480420096 1278.55 SP500-as.timeSeries(SP500) Error in .midnightStandard(charvec, format) : 'charvec' has non-NA entries of different number of characters [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Alternating numbers in rep()
Here are a couple of options (I'm sure there are plenty of others) that replicate your results and can be extended without too much more typing (but some arithmatic): unname(unlist( rep( as.data.frame( matrix(1:4, nrow=2) ) , each=6 ) )) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 c(aperm(array(rep( 1:4, 6), c(2,2,6)),c(1,3,2))) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous Sent: Thursday, January 24, 2008 1:03 PM To: r-help@r-project.org Subject: [R] Alternating numbers in rep() All, I'm trying to obtain a one-liner to generate a certain sequence of alternatign numbers. Consider: unlist(rep(list(c(1,2), c(3,4)), each = 6)) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 I'd like the result to be as above but continue until 38. Of course, I could hardcode this going up to c(37,38), but is there a more elegant way? Thanks! David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] testing coeficients of glm
On Thu, 24 Jan 2008, peter salzman wrote: Dear list, i'm trying to test if a linear combination of coefficients of glm is equal to 0. For example : class 'cl' has 3 levels (1,2,3) and 'y' is a response variable. We want to test H0: mu1 + mu2 - mu3 =0 where mu1,mu2, and mu3 are the means for each level. Look at linear.hypothesis() in package car. ## data (reduce treatment to three levels) data(OrchardSprays) os - subset(OrchardSprays, treatment %in% c(A, B, C)) os$treatment - factor(os$treatment) ## model and test fm - lm(decrease ~ 0 + treatment, data = os) coef(fm) linear.hypothesis(fm, treatmentA + treatmentB - treatmentC = 0) See the accompanying documentation for an overview which extractor functions (such as coef, vcov, etc.) are used to compute the test. hth, Z for me, the question is how to get the covariance matrix of the estimated parameters from glm. but perhaps there is a direct solution in one of the packages. i know how to solve this particular problem (i wrote it below) but i'm curious about the covariance matrix of coefficient as it seems to be important. the R code example : ### nObs - 10 cl - as.factor( sample(c(1,2,3),nObs,replace=TRUE) ) y - rnorm(nObs) model - glm(y ~ cl) b - model$coefficients H - c(1,1,-1) # we want to test H0: Hb = 0 ### the following code will NOT run unless we can compute covModelCoeffs #the mean of Hb is mu = H %*% model$coefficients #the variance is HB is var = H %*% covModelCoeffs %*% t(H) p.val - 2 * pnorm( -abs(mu), mean=0, sd=sqrt(var),lower.tail = TRUE) how do i get the covariance matrix of the estimated parameters ? thanks, peter P.S. the simple solution for this particular problem: ## get the mean for each level muV - by(y,cl,mean) ## get the variance for each level varV - by(y,cl,var) ## the mean of Hb is muHb - H %*% muV ## because of independence, the variance of Hb is varHb - sum(varV) ## the probability of error, so-called p-value: p.val - 2 * pnorm( -abs(muHb), mean=0, sd=sqrt(varHb),lower.tail = TRUE) thanks again, peter -- Peter Salzman, PhD Department of Biostatistics and Computational Biology University of Rochester [[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] Alternating numbers in rep()
The last one can be shortened to: c(aperm(array(1:4, c(2,2,6)),c(1,3,2))) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 And it extends to 38 fairly easily: c(aperm(array(1:38, c(2,38/2,6)),c(1,3,2))) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 5 [26] 6 5 6 5 6 5 6 5 6 5 6 7 8 7 8 7 8 7 8 7 8 7 8 9 10 [51] 9 10 9 10 . . . -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Snow Sent: Thursday, January 24, 2008 1:33 PM To: David Afshartous; r-help@r-project.org Subject: Re: [R] Alternating numbers in rep() Here are a couple of options (I'm sure there are plenty of others) that replicate your results and can be extended without too much more typing (but some arithmatic): unname(unlist( rep( as.data.frame( matrix(1:4, nrow=2) ) , each=6 ) )) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 c(aperm(array(rep( 1:4, 6), c(2,2,6)),c(1,3,2))) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous Sent: Thursday, January 24, 2008 1:03 PM To: r-help@r-project.org Subject: [R] Alternating numbers in rep() All, I'm trying to obtain a one-liner to generate a certain sequence of alternatign numbers. Consider: unlist(rep(list(c(1,2), c(3,4)), each = 6)) [1] 1 2 1 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 3 4 3 4 3 4 I'd like the result to be as above but continue until 38. Of course, I could hardcode this going up to c(37,38), but is there a more elegant way? Thanks! David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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.
[R] Odp: boxplot axis labelling
Hi [EMAIL PROTECTED] napsal dne 24.01.2008 18:20:41: Hi, i'm very new to R, so sorry for what i'm sure is a very basic question. I'm producing a boxplot with the data below: df3-data.frame( x=c(10,11,115,12,13,14,16,17,18,21,22,23,24,26,27,28,29,3,30,32,33,34,35,4,4 1,45,5,50,52,56,58,6,67,6738,68,7,8,9), fq=c(8,11,1,2,4,4,2,2,6,3,4,2,2,1,1,1,4,51,3,1,1,1,1,35,1,1,19,2,1,1,1,14,1, 1,1,10,13,5), fqcvd=c(5,8,1,1,3,3,2,2,5,3,4,2,2,0,1,1,3,13,2,1,1,1,1,17,1,0,11,2,1,1,1,7,1 ,1,1,7,7,1), fqcan=c(1,1,0,2,1,1,1,0,3,0,2,0,1,0,1,0,1,4,2,1,1,0,0,4,1,1,2,2,0,1,0,2,0,1, 1,2,3,1), fqnoncan=c(8,11,0,2,4,4,2,0,6,0,4,0,2,0,1,0,4,50,3,1,1,0,0,35,1,1,19,2,0,1,0 ,14,0,1,1,10,13,5)) k3-with(df3,rep(x,times=fq)) kcvd3-with(df3,rep(x,times=fqcvd)) kcvd3-c(kcvd3,rep(NA,times=length(k3)-length(kcvd3))) kcan3-with(df3,rep(x,times=fqcan)) kcan3-c(kcan3,rep(NA,times=length(k3)-length(kcan3))) knoncan3-with(df3,rep(x,times=fqnoncan)) knoncan3-c(knoncan3,rep(NA,times=length(k3)-length(knoncan3))) dfnew-data.frame(kcvd3,kcan3,knoncan3,k3) boxplot(dfnew,log='y', ylim=c(1,4000)) Supress axes by axes=F and use xlab for some label and then add box or y axis by box() and axis(2) Regards Petr This produces x axis labels 'kcvd3,kcan3,knoncan3,k3', one for each plot as you might expect. However, I would like all plot to sit next to each other with a single label. Could anybody help? cheers Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Displaying trailing zeroes
round(12.01,1) will give the answer 12, not 12.0 or even 12. To make a table look nice, I need to display the trailing zero so that just as round(12.05,1) yields 12.1, round(12.01) yields 12.0. I cannot find an answer in print() or format() or options(). Any suggestions would be appreciated. Joseph F. Lucke, PhD Biostatistician Center for Clinical Research and Evidence-based Medicine University of Texas Medical School at Houston Email: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Displaying trailing zeroes
formatC(round(12.01), digits=1, format=f) -Christos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lucke, Joseph F Sent: Thursday, January 24, 2008 4:37 PM To: r-help@r-project.org Subject: [R] Displaying trailing zeroes round(12.01,1) will give the answer 12, not 12.0 or even 12. To make a table look nice, I need to display the trailing zero so that just as round(12.05,1) yields 12.1, round(12.01) yields 12.0. I cannot find an answer in print() or format() or options(). Any suggestions would be appreciated. Joseph F. Lucke, PhD Biostatistician Center for Clinical Research and Evidence-based Medicine University of Texas Medical School at Houston Email: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Re shaping a dataframe with conditional summary of columns - apply or reshape?
Try this: x$survey1[x$count==0] - 0 x$survey1[x$count %in% 1:11] - 1 x$survey1[x$count 11] - 2 x.wide - reshape(x, v.names=survey1, idvar=location, timevar=survey1, direction=wide) x.wide - x.wide[order(x.wide$location),] x.wide$var1 - tapply(x$var1, x$location, mean) x.wide Thanks a lot Henrique. Only needed two simple changes: (1) Made the range in the second assignment 1:10 and the operator in the second 10 to conform with the rules I needed. (2) Changed timevar from survey1 to survey. Using survey1 reordered the columns for the survey observations, and it was much easier to have survey1 first, survey2 second, and survey3 third. - David Hewitt Virginia Institute of Marine Science http://www.vims.edu/fish/students/dhewitt/ -- View this message in context: http://www.nabble.com/Reshaping-a-dataframe-with-conditional-summary-of-columns---apply-or-reshape--tp15058600p15075986.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] Re shaping a dataframe with conditional summary of columns - apply or reshape?
x$survey1[x$count==0] - 0 x$survey1[x$count %in% 1:11] - 1 x$survey1[x$count 11] - 2 x.wide - reshape(x, v.names=survey1, idvar=location, timevar=survey1, direction=wide) x.wide - x.wide[order(x.wide$location),] x.wide$var1 - tapply(x$var1, x$location, mean) x.wide Thanks a lot Henrique. Only needed two simple changes: (1) Made the range in the second assignment 1:10 and the operator in the second 10 to conform with the rules I needed. (2) Changed timevar from survey1 to survey. Using survey1 reordered the columns for the survey observations, and it was much easier to have survey1 first, survey2 second, and survey3 third. Oops, spoke too soon. Should have put this in the example, but the locations can be replicated in subsequent years (observations from the same place through time), so reshape drops all but the first. Any ideas? - David Hewitt Virginia Institute of Marine Science http://www.vims.edu/fish/students/dhewitt/ -- View this message in context: http://www.nabble.com/Reshaping-a-dataframe-with-conditional-summary-of-columns---apply-or-reshape--tp15058600p15076251.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] Grouping
I need to group some subjects according to two variables (var1, var2) I have a data frame that looks something like this: Subject var1 var2 1 400150 2 320100 3 580600 4 145789 Each suject would fall into one of 2 categories ('A' or 'B'). I want to find (and see) all the possible combinations of letter assignment that exist, but every combination needs to have an equal amount of subjects categorized as 'A' or 'B'(eg. if I have 20 subjects there should be 10 assigned with letter 'A' and 10 with letter 'B') Thank you in advance for any hints, Judith Never miss a thing. Make Yahoo your home page. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Displaying trailing zeroes
On 24/01/2008 4:36 PM, Lucke, Joseph F wrote: round(12.01,1) will give the answer 12, not 12.0 or even 12. Those are all the same number. You aren't asking about the answer, you are asking about how to control how the number is printed. To make a table look nice, I need to display the trailing zero so that just as round(12.05,1) yields 12.1, round(12.01) yields 12.0. I cannot find an answer in print() or format() or options(). Any suggestions would be appreciated. R tries to be consistent when it prints a vector, so you could convert all the entries at once. For example, x - c(12, 12.1) format(x) [1] 12.0 12.1 If you want individual control on each entry, see formatC or sprintf. Christos gave you the formatC version; the sprintf version is sprintf(%.1f, 12) [1] 12.0 Duncan Murdoch Joseph F. Lucke, PhD Biostatistician Center for Clinical Research and Evidence-based Medicine University of Texas Medical School at Houston Email: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] latex{Hmisc} cannot find xdvi on MAC OS X
Don MacQueen wrote: Nobody seems to have asked whether the student is using R from the Mac GUI, or R at the unix-style command line prompt. I have R 2.6.1 installed on a Mac running OS 10.4.11. When I start R at the command prompt in a terminal emulator in the X windows environment, the example expression, latex(describe(dataframe)), succeeds. xdvi starts up and displays the preview. When I use the Mac GUI, xdvi does not start up. Both ways of starting R are using the same installation of R. When started by double-clicking on the icon that represents R, the unix path is not inherited. It's probably more accurate to say that PATH does not exist, because no unix shell has been started. There are other mechanisms for creating environment variables that R can obtain via Sys.getenv(). (Create a file named environment.plist, or something like that, but I don't remember the exact details.) Even if the R gui environment is set up so that the path to xdvi is available, it won't necessarily work, because xdvi requires that an X windows server and window manager be running. That's not normally the case for most Mac users (one assumes). On Mac OS 10.5.x those should start automatically when xdvi is started, but not on earlier versions of Mac OS. (As an aside, this is probably the answer to Frank's comment, shame on Mac (for not inheriting path) -- if one wants the Mac to act like a linux box, then one must do one's work from within a unix shell. That's done either from the Terminal application, or other terminal emulator.) The experts on this issue are best reached through R-sig-mac. A search of the archives will probably reveal how to define unix stye environment variables such as PATH, that the Mac R gui can use. The Mac-related pages at CRAN may also have this information. -Don Thanks for this additional info. She is running from the MAC GUI. The fixed Sys.setenv() now fixes the xdvi not found, but throws this error. dyld: Library not loaded: /usr/X11R6/lib/libXaw.7.dylib Referenced from: /usr/texbin/xdvi-xaw.bin Reason: image not found 2008-01-24 17:11:08.253 R[1370] tossing reply message sequence 3 on thread 0x3d31450 This certainly looks to me like the X libs are not loaded. Am I remembering correctly that there is a Start X menu item in the MAC GUI for R or elsewhere? BTW, I requested her sessionInfo(). Here it is. sessionInfo() R version 2.6.1 (2007-11-26) powerpc-apple-darwin8.10.1 locale: en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8 attached base packages: [1] splines stats graphics grDevices utils datasets methods [8] base other attached packages: [1] Design_2.1-1 survival_2.34 Hmisc_3.4-3lattice_0.17-2 loaded via a namespace (and not attached): [1] cluster_1.11.9 grid_2.6.1 So the MAC OS is 8.10.1? Earlier than the 8.10.5 you mention above. Thanks, Kevin At 9:22 AM -0500 1/23/08, Kevin E. Thorpe wrote: Hello. I am posting this on behalf of a student in my class. I have been introducing them to R. I suspect that the problem I need help with is not so much an R issue, but a MAC config issue, but I don't have enough MAC experience to know what to do. Anyway, on to the problem. We are using Frank Harrell's Hmisc and Design packages. This student also wishes to use the latex formatting facilities provided in those packages so she has installed LaTeX. When she does something like latex(describe(dataframe)), the latex file is produced, the dvi file is successfully written but then the error sh: line 1: xdvi: command not found appears. I started a terminal and a which xdvi returned the path where it found xdvi. So, it appears that xdvi is in the PATH. My apologies, I forgot to get her sessionInfo() but I think she is running R 2.6.? -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Department of Public Health Sciences Faculty of Medicine, University of Toronto email: [EMAIL PROTECTED] Tel: 416.864.5776 Fax: 416.864.6057 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Linux, UNIX, XP32, Vista X64 or ...? [SEC=UNCLASSIFIED]
Hi Peter, Thank you for the quick answer. Given that we have UNIX system available here in Geoscience Australia, I am wondering if UNIX is also faster and with 64 bit build. Perhaps they may be kind enough to let me have a Linux system. As I only have experience in using Windows PC, what kind of challenges are there for using R in other systems like UNIX and Linux? Thanks again, Jin -Original Message- From: Peter Dalgaard [mailto:[EMAIL PROTECTED] Sent: Thursday, 24 January 2008 10:23 To: Li Jin Cc: r-help@r-project.org Subject: Re: [R] Linux, UNIX, XP32, Vista X64 or ...? [SEC=UNCLASSIFIED] [EMAIL PROTECTED] wrote: Dear All, I am currently using R in Windows PC with a 2 GB of RAM. Some pretty large datasets are expected soon, perhaps in an order of several GB. I am facing a similar situation like Ralph, either to get a new PC with a bigger RAM or else. I am just wondering if R is getting faster in other systems like UNIX or Linux. Any suggestions are appreciated. Regards, Jin It has always been faster in Linux than in Windows on the same hardware. In addition, the toolchain issues have been holding up 64 bit development on 64 bit Windows, whereas 64 bit build has been working on Linux for years. Jin Li, PhD Spatial Modeller/ Computational Statistician Marine Coastal Environment Geoscience Australia Ph: 61 (02) 6249 9899 Fax: 61 (02) 6249 9956 email: [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Prof Brian Ripley Sent: Thursday, 24 January 2008 12:05 To: Ralph79 Cc: r-help@r-project.org Subject: Re: [R] Problems with XP32-3GB-patch?/ Worth upgrading to Vista X64? On Wed, 23 Jan 2008, Ralph79 wrote: Dear R-Users, as I will start a huge simulation in a few weeks, I am about to buy a new and fast PC. I have noticed, that the RAM has been the limiting factor in many of my calculations up to now (I had 2 GB in my old system, but Windows still used quite a lot of virtual memory), hence my new computer will have 4 GB of fast DDR2-800 RAM. However, I know that 1.) Windows 32 bit cannot make use of more than about 3,2 GB RAM and 2.) it is normally not allowed to allocate more than 2 GB of RAM to one single application (at least under XP, I don't know if that has changed under Vista?). I remember from the R-FAQ that you can manually adjust XP so that it allocates up to 3 GB to one application (the 3GB patch), but I read in a PC-magazine and some message boards that this may cause problems. Does anybody of you successfully use this trick without any problems? Yes, many people: most 32-bit Exchange servers use it. Please don't rate the advice in the R documentation below tittle-tattle you read on the web. Would it be wise to use a 64bit OS, as e.g. Vista X64? I think, under Vista X64 it should be no problem to allocate 4 GB of RAM to R. Any experiences with that? That's what the rw-FAQ says, and we do write answers based on experience! Thanks in advance, Ralph Wirth - Ralph Wirth University Erlangen-Nuremberg, Chair of Statistics GfK Group, Department of Methods and Product Development -- 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 ~~ - ([EMAIL PROTECTED]) 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] Displaying trailing zeroes
Lucke, Joseph F wrote: round(12.01,1) will give the answer 12, not 12.0 or even 12. To make a table look nice, I need to display the trailing zero so that just as round(12.05,1) yields 12.1, round(12.01) yields 12.0. I cannot find an answer in print() or format() or options(). Any suggestions would be appreciated. formatC(round(12.01,1),1,format=f) [1] 12.0 cat(sprintf(%6.1f\n, round(12.01,1))) 12.0 -- 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 ~~ - ([EMAIL PROTECTED]) 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.
[R] package 'foreign'
Hi Everybody, I need to install the R-package 'foreign'. However, when I try the standard install.packages('foreign') I get the following error message: package 'foreign' is not available in: install.packages(foreign) The funny thing is, that I am using an Ubuntu Gutsy system and the foreign package should actually be installed by default... Any help is greatly appreciated. Best, Tobias __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 should I organize data to compare differences in matchedpairs?
By accident, I didn't send this to the list. On Thu, 2008-01-24 at 17:54 -0500, Thomas Levine wrote: Oh, right, I don't need the differences. I only needed to get the differences before because I was doing them sloppily in a spreadsheet and needed to do a t-test manually because the program didn't have a function for one type of t-test. I shall do it this way then. On Thu, 2008-01-24 at 12:05 -0700, Greg Snow wrote: Here is how I would do it (there are multiple ways you could do it, so there is not single Right answer): Assign each person a unique identifier. Put all the information from the questionaire along with the idenifier and anything else that does not change between rounds (age, sex, height, ...) into one data frame. This df will have as many rows as you have subjects. The round information then goes into a second data frame with each round being a row (each subject has multiple rows) and include the unique identifier on each row for that person. If you need information combined from both data frames, then use the merge function to merge the 2 data frames (or subsets of them) together. Advantages of this method include: Uses data frames which most of the analysis functions expect. Each piece of data is only entered once (other than the id) Disadvantage: Data is split between 2 objects. Hope this helps, signature.asc Description: This is a digitally signed message part __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Barplot w/ single stacked bar
I can reach my goal in ggplot2, although the relative heights of the bar's pieces don't seem quite right (it does generate a warning): library(ggplot2) x-factor(1) y-factor( c(Male,Male,Female) ) mydata - data.frame(x,y) rm(x,y) mydata Ooops! There was a bug in stat_bin that occurred when there was a single categorical x value. It'll be fixed in the next version. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.