Re: [R] Help in installing and loading the BradleyTerry add on package in R
However you may also need to install the package brlr, since the BradleyTerry package depends on this. For Windows users, it's usually easiest to install packages using the Packages menu in the RGui - any dependencies are then automatically installed. Heather -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Lemon Sent: 10 September 2007 12:07 To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Help in installing and loading the BradleyTerry add on package in R Kalyan Roy (DEL/MSG) wrote: How do I install and load the BradleyTerry add on package in R 2.5.1 in MSWindowsXP environment? Hi Kalyan, If R CMD INSTALL doesn't work, you can use WinZip or Zip Reader to unzip the package to: C:\Program Files\R-2.5.1\library or whatever your path to the library directory is, and then hand edit the packages.html file in: C:\Program Files\R-2.5.1\doc\html to include the new package in your HTML listing. This will allow you to access the help files and use the package. Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help in installing and loading the BradleyTerry add on package in R
Kalyan Roy (DEL/MSG) wrote: How do I install and load the BradleyTerry add on package in R 2.5.1 in MSWindowsXP environment? Hi Kalyan, If R CMD INSTALL doesn't work, you can use WinZip or Zip Reader to unzip the package to: C:\Program Files\R-2.5.1\library or whatever your path to the library directory is, and then hand edit the packages.html file in: C:\Program Files\R-2.5.1\doc\html to include the new package in your HTML listing. This will allow you to access the help files and use the package. Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with color coded bar graph
Luis Naver wrote: I have a list of observations that are -1, 1 or 0. I would like to represent them in a horizontal bar color coded based on value like a stacked bar graph. I can achieve this in the form of a png with the following code: A = floor(runif(10)*3) - 1 png(width=100, height=10) par(mar=c(0,0,0,0)) image(matrix(A), col=grey(c(0.1, 0.5, 0.9))) dev.off() However I would like to do this with one of the standard plotting tools (i.e. barplot) to take advantage of labels and multiple series. Any help would be appreciated. Hi Luis, I understood your request as wanting a single horizontal bar with 10 segments, each colored according to the value of A. If this is correct, you might want: library(plotrix) plot(1,xlim=c(-1,1),ylim=c(-1,1),xlab=,ylab=,type=n,axes=FALSE) gradient.rect(-1,-0.1,1,0.1,col=grey(c(0.1,0.5,0.9))[A+2]) Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help on replacing values
Your columns are factors, not character strings. Use as.is = TRUE as an argument to read.table. Also its a bit dangerous to use T although not wrong. Its safer to use TRUE. On 9/7/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear List, I have a newbie question. I have read in a data.frame as follows: data = read.table(table.txt, header = T) data X1 X2 X3 X4 A AB AC AB AC B AB AC AA AB C AA AB AA AB D AA AB AB AC E AB AA AA AB F AB AA AB AC B AB AC AB AA I would like to replace AA values by BB in column X2. I have tried using replace() with no success, although I am not sure this is the right function. This is the code I have used: data$X2 - replace(data$X2, data$X2 ==AA,BB) Warning message: invalid factor level, NAs generated in: `[-.factor`(`*tmp*`, list, value = BB) What is wrong with the code? How can I get this done? how about changing AA values by BB in all 4 columns simultaneously? Actually this is a small example dataframe, the real one would have about 1000 columns. Extendind this, I found a similar thread dated July 2006 that used replace() on iris dataset, but I have tried reproducing it obtaining same warning message iris$Species - replace(iris$Species, iris$Species == setosa,NewName) Warning message: invalid factor level, NAs generated in: `[-.factor`(`*tmp*`, list, value = NewName) Thanks in advance your help, David __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help on replacing values
Thanks a lot Gabor, that was very helpful. All sorted now! Best David Your columns are factors, not character strings. Use as.is = TRUE as an argument to read.table. Also its a bit dangerous to use T although not wrong. Its safer to use TRUE. On 9/7/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear List, I have a newbie question. I have read in a data.frame as follows: data = read.table(table.txt, header = T) data X1 X2 X3 X4 A AB AC AB AC B AB AC AA AB C AA AB AA AB D AA AB AB AC E AB AA AA AB F AB AA AB AC B AB AC AB AA I would like to replace AA values by BB in column X2. I have tried using replace() with no success, although I am not sure this is the right function. This is the code I have used: data$X2 - replace(data$X2, data$X2 ==AA,BB) Warning message: invalid factor level, NAs generated in: `[-.factor`(`*tmp*`, list, value = BB) What is wrong with the code? How can I get this done? how about changing AA values by BB in all 4 columns simultaneously? Actually this is a small example dataframe, the real one would have about 1000 columns. Extendind this, I found a similar thread dated July 2006 that used replace() on iris dataset, but I have tried reproducing it obtaining same warning message iris$Species - replace(iris$Species, iris$Species == setosa,NewName) Warning message: invalid factor level, NAs generated in: `[-.factor`(`*tmp*`, list, value = NewName) Thanks in advance your help, David __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with color coded bar graph
On Fri, 2007-09-07 at 12:45 -0700, Luis Naver wrote: I have a list of observations that are -1, 1 or 0. I would like to represent them in a horizontal bar color coded based on value like a stacked bar graph. I can achieve this in the form of a png with the following code: A = floor(runif(10)*3) - 1 png(width=100, height=10) par(mar=c(0,0,0,0)) image(matrix(A), col=grey(c(0.1, 0.5, 0.9))) dev.off() However I would like to do this with one of the standard plotting tools (i.e. barplot) to take advantage of labels and multiple series. Any help would be appreciated. - Luis Naver How about this: barplot(rep(1, length(A)), col = black, space = 0, border = 0) barplot(A, col = grey(0.9), space = 0, border = 0, add = TRUE) The first call sets the plot region to black, ensuring that the x and y axes are consistent with the second call. Alternatively, you can use barplot2() in the gplots CRAN package to do this in a single call, as it has an argument to color the plot region. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with color coded bar graph
On Fri, 7 Sep 2007, Luis Naver wrote: I have a list of observations that are -1, 1 or 0. I would like to represent them in a horizontal bar color coded based on value like a stacked bar graph. I can achieve this in the form of a png with the following code: A = floor(runif(10)*3) - 1 png(width=100, height=10) par(mar=c(0,0,0,0)) image(matrix(A), col=grey(c(0.1, 0.5, 0.9))) dev.off() If I understand you correctly, you want a sequence of bars with equal height and colors coded by A (treated like a factor). So Maybe something like cA - grey.colors(3)[factor(A)] barplot(rep(1, length(A)), col = cA, border = cA) or barplot(rep(1, length(A)), col = cA, border = cA, space = 0, xaxs = i, axes = FALSE) ? hth, Z However I would like to do this with one of the standard plotting tools (i.e. barplot) to take advantage of labels and multiple series. Any help would be appreciated. - Luis Naver __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with color coded bar graph
On Fri, 2007-09-07 at 15:07 -0500, Marc Schwartz wrote: On Fri, 2007-09-07 at 12:45 -0700, Luis Naver wrote: I have a list of observations that are -1, 1 or 0. I would like to represent them in a horizontal bar color coded based on value like a stacked bar graph. I can achieve this in the form of a png with the following code: A = floor(runif(10)*3) - 1 png(width=100, height=10) par(mar=c(0,0,0,0)) image(matrix(A), col=grey(c(0.1, 0.5, 0.9))) dev.off() However I would like to do this with one of the standard plotting tools (i.e. barplot) to take advantage of labels and multiple series. Any help would be appreciated. - Luis Naver How about this: barplot(rep(1, length(A)), col = black, space = 0, border = 0) barplot(A, col = grey(0.9), space = 0, border = 0, add = TRUE) The first call sets the plot region to black, ensuring that the x and y axes are consistent with the second call. Alternatively, you can use barplot2() in the gplots CRAN package to do this in a single call, as it has an argument to color the plot region. Actually, here is an easier way: barplot(rep(1, length(A)), col = ifelse(A == 0, black, grey(0.9)), space = 0, border = 0) Just set 'col' based upon the value in 'A'. HTH, Marc __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with color coded bar graph
Thanks to all who replied (and very quickly). Unfortunatly I was not clear enough as to my intentions. My goal is to replicate a graph I saw in the work by Perry, Miller and Enright in A comparison of methods for the statistical analysis of spatial point patterns in plant ecology (http://www.springerlink.com/content/ 013275pp7376v0hx). For those without the article here is a copy of the graph in question (replicated without permission) http:// img511.imageshack.us/img511/8720/barexamplejl8.png. As you can see in the example, there are several hoizontal bars, colored by the values in an array (one for each bar). I've been thinking of following your examples but setting it to stack, such that all the elements would be placed one on top another. While this may work it seems particularly ungraceful. Again, thanks for the help. -Luis Naver On Sep 7, 2007, at 1:21 PM, Marc Schwartz wrote: On Fri, 2007-09-07 at 15:07 -0500, Marc Schwartz wrote: On Fri, 2007-09-07 at 12:45 -0700, Luis Naver wrote: I have a list of observations that are -1, 1 or 0. I would like to represent them in a horizontal bar color coded based on value like a stacked bar graph. I can achieve this in the form of a png with the following code: A = floor(runif(10)*3) - 1 png(width=100, height=10) par(mar=c(0,0,0,0)) image(matrix(A), col=grey(c(0.1, 0.5, 0.9))) dev.off() However I would like to do this with one of the standard plotting tools (i.e. barplot) to take advantage of labels and multiple series. Any help would be appreciated. - Luis Naver How about this: barplot(rep(1, length(A)), col = black, space = 0, border = 0) barplot(A, col = grey(0.9), space = 0, border = 0, add = TRUE) The first call sets the plot region to black, ensuring that the x and y axes are consistent with the second call. Alternatively, you can use barplot2() in the gplots CRAN package to do this in a single call, as it has an argument to color the plot region. Actually, here is an easier way: barplot(rep(1, length(A)), col = ifelse(A == 0, black, grey(0.9)), space = 0, border = 0) Just set 'col' based upon the value in 'A'. HTH, Marc __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help: how can i build a constrained non-linear model?
Dear all I try to run the code as follows, test.model-nls(y~exp(A)*(x-PMA)^4+exp(B)*(x-PMA)^2+Const, data=test, start=list(A=8,B=5,Const=10,PMA=0), control=nls.control(maxiter = 50,minFactor=1/1048), trace=TRUE) But how can i build a selfSart, since i have much data ? Thanks for your help first! Vina From: [EMAIL PROTECTED]: [EMAIL PROTECTED]: Help: how can i build a constrained non-linear model?Date: Tue, 4 Sep 2007 07:53:41 + DearI have a data.frame, and want to fit a constrained non-linear model:data: x y -0.08 20.815 -0.065 19.8128 -0.05 19.1824 -0.03 18.7346 -0.015 18.3129 0.015 18.0269 0.03 18.4715 0.05 18.9517 0.065 19.4184 0.08 20.146 0 18.2947model:y~exp(a)*(x-m)^4+exp(b)*(x-m)^2+const I try to use nls() and set start=list(a=1,b=1,c=1,m=1), but which always give me a error message that Error in qr.solv(QR.B,cc): singular matrix 'a' in solve. How can i build a selfStart? or any suggestion! ThanksRegards,Vina Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it! _ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help on inverse distribution
To make it specific, I need to simulation Y with inverse beta distribution, that is, Y~inverseF(X), where F is the CDF of beta distribution. THANKS On 9/4/07, Lisa Hu [EMAIL PROTECTED] wrote: Dear All, I need to use the inverse of some distributions in R for simulation, but I could not find it, can anyone tell me which package I should install? thanks [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help on inverse distribution
On 5/09/2007, at 11:16 AM, Lisa Hu wrote: To make it specific, I need to simulation Y with inverse beta distribution, that is, Y~inverseF(X), where F is the CDF of beta distribution. THANKS On 9/4/07, Lisa Hu [EMAIL PROTECTED] wrote: Dear All, I need to use the inverse of some distributions in R for simulation, but I could not find it, can anyone tell me which package I should install? thanks help.search(distribution) ?Beta ## Attention:\ This e-mail message is privileged and confidenti...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help on coxph
In the R-surface menu, go to packages - install packages. Select a server and install the package survival. Then, on the prompt, type: library(survival) Then it works. Look up the numerous manual on using R if you need further help. If that's not the issue, give us more detailed information on the problem. Daniel PhD Program Strategy Dept. of Management and Organization Robert H. Smith School of Business University of Maryland Van Munching Hall College Park, MD 20742 www.rhsmith.umd.edu www.umd.edu mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Wei Hu Gesendet: Sunday, August 26, 2007 9:49 PM An: r-help@stat.math.ethz.ch Betreff: [R] Help on coxph I am new to R. I just installed R2.5.1 in my computer and tried to use coxph, but it gives me this message: No documentation for 'coxph' in specified packages and libraries: you could try 'help.search(coxph)' can anyone tell me how to install this package? thanks a lot [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with vector gymnastics
try 5*which(tf)[cumsum(tf)] Gladwin, Philip schrieb: Hello, What is the best way of solving this problem? answer - ifelse(tf=TRUE, i * 5, previous answer) where as an initial condition tf[1] - TRUE For example if, tf - c(T,F,F,F,T,T,F) over i = 1 to 7 then the output of the function will be answer = 5 5 5 5 25 30 30 Thank you. Phil, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 22046 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with vector gymnastics
library(zoo) tf - c(T,F,F,F,T,T,F) i - seq(7) answer - ifelse(tf, i*5, NA) answer - na.locf(answer) On 8/23/07, Gladwin, Philip [EMAIL PROTECTED] wrote: Hello, What is the best way of solving this problem? answer - ifelse(tf=TRUE, i * 5, previous answer) where as an initial condition tf[1] - TRUE For example if, tf - c(T,F,F,F,T,T,F) over i = 1 to 7 then the output of the function will be answer = 5 5 5 5 25 30 30 Thank you. Phil, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Felix Andrews / 安福立 PhD candidate Integrated Catchment Assessment and Management Centre The Fenner School of Environment and Society The Australian National University (Building 48A), ACT 0200 Beijing Bag, Locked Bag 40, Kingston ACT 2604 http://www.neurofractal.org/felix/ voice:+86_1051404394 (in China) mobile:+86_13522529265 (in China) mobile:+61_410400963 (in Australia) xmpp:[EMAIL PROTECTED] 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with vector gymnastics
Philip - I don't know if this is the best way, but it gives you the output you want. Using your tf, vals - rle(ifelse(tf, 5*which(tf), 0)) vals$values[vals$values == 0] - vals$values[which(vals$values==0) - 1] inverse.rle(vals) [1] 5 5 5 5 25 30 30 Gladwin, Philip wrote: Hello, What is the best way of solving this problem? answer - ifelse(tf=TRUE, i * 5, previous answer) where as an initial condition tf[1] - TRUE For example if, tf - c(T,F,F,F,T,T,F) over i = 1 to 7 then the output of the function will be answer = 5 5 5 5 25 30 30 Thank you. Phil, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help and Firefox
I found a solution to my problem. It is describe here. http://kb.mozillazine.org/Windows_error_opening_Internet_shortcut_or_local_HTML_file_-_Firefox Essentially, it involves switching off DDE for some file associations in Windows Explorer. It really is a Firefox bug. Erich Neuwirth wrote: My configuration is Windows XP, R-2.5.1patched. My standard browser in Windows is Firefox 2.0.6, and I am using htmlhelp. I have problems with starting the browser for displaying help. help(lm) works as it should when Firefox is already running. When I do help(lm) and the browser is not yet started, I get Error in shell.exec(url) : 'C:\PROGRA~2\R\R-25~1.1\library\stats\html\lm.html' not found but nevertheless the browser starts and the html file is displayed some seconds later. If I try to use help from within a function and the browser is not open, the browser will not start and therefore help will not be displayed. Has anybody else experienced the same problem? Is there a solution? -- Erich Neuwirth, University of Vienna Faculty of Computer Science Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-39459 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with npmc
I cant't seem to get npmc to make a comparison to a control level summary(npmc(brain), type=BF, control=1) $`Data-structure` group.index class.level nobs c 1 c 30 l 2 l 30 r 3 r 30 $`Results of the multiple Behrens-Fisher-Test` cmpeffect lower.cl upper.cl p.value.1s p.value.2s 1 1-2 0.643 0.4610459 0.8256208 0.08595894 0.14750647 2 1-3 0.444 0.2576352 0.6312537 0.99636221 0.75376639 3 2-3 0.328 0.1602449 0.4964218 1. 0.04476692 What elementary error am I making. Thanks, Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with scatterplot3d
On 8/13/2007 3:03 PM, Ryan Briscoe Runquist wrote: Hello, I am having a bit of trouble with scatterplot3d(). I was able to plot a 3d cloud of points using the following code: my.3dplot-scatterplot3d(my.coords, pch=19, zlim=c(0,1), scale.y=0.5, angle=30, box=FALSE) where my.coords is a data frame that contains x, y, and z coordinates for grid points whose elevation we sampled. The problem occurs when I try to add points using points3d. I tried to follow the code in the examples of the package pdf. First, I tried the following code to add all of the points that I wanted: my.3dplot$points3d(seq(400,600,0.19), seq(600,400,0.295), seq(800,500,0.24), seq(1000,1400,0.22), seq(1200,600,0.24), seq(1200,1500,0.28), seq(1300,1400,0.205), seq(1700,500,0.26), seq(1700,600,0.21), seq(1900,1400,0.255), seq(2300,1400,0.275), seq(2600,1300,0.225), seq(2700,400,0.235), seq(2700,1300,0.265), seq(3100,1000,0.135), col=blue, type=h, pch=16) The header to the function (which you can see by evaluating my.3dplot$points3d) is function (x, y = NULL, z = NULL, type = p, ...) so you are setting x to seq(400,600,0.19), y to seq(600,400,0.295), etc. I think you probably want my.3dplot$points3d(x=c(400, 600, ...), y=c(600, 400, ...), z=c(0.19, 0.295, ...), ...) (where the ... is to be filled in by you.) and got the following error: Error in seq.default(600, 400, 0.295) : wrong sign in 'by' argument So I just tried to add the first point using the following code: my.3dplot$points3d(seq(400,600,0.19), col=blue, type=h, pch=16) and got the following error message: Error in xyz.coords(x, y, z) : 'x', 'y' and 'z' lengths differ. Does anyone know how I can use this function in the scatterplot3d package? try my.3dplot$points3d(x=400, y=600, z=0.19, col=blue, type=h, pch=16) Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with scatterplot3d
Ryan Briscoe Runquist rdbriscoe at ucdavis.edu writes: Hello, I am having a bit of trouble with scatterplot3d(). I was able to plot a 3d cloud of points using the following code: my.3dplot-scatterplot3d(my.coords, pch=19, zlim=c(0,1), scale.y=0.5, angle=30, box=FALSE) where my.coords is a data frame that contains x, y, and z coordinates for grid points whose elevation we sampled. The problem occurs when I try to add points using points3d. I tried to follow the code in the examples of the package pdf. First, I tried the following code to add all of the points that I wanted: my.3dplot$points3d(seq(400,600,0.19), seq(600,400,0.295), seq(800,500,0.24), seq(1000,1400,0.22), seq(1200,600,0.24), seq(1200,1500,0.28), seq(1300,1400,0.205), seq(1700,500,0.26), seq(1700,600,0.21), seq(1900,1400,0.255), seq(2300,1400,0.275), seq(2600,1300,0.225), seq(2700,400,0.235), seq(2700,1300,0.265), seq(3100,1000,0.135), col=blue, type=h, pch=16) I think you probably want: xvals - c(400,600,800,1000,1200,1200,1300,1700,1700,1900, 2300,2600,2700,2700,3100) yvals - c(600,400,500,1400,600,1500,1400,500,600, 1400,1400,1300,400,1300,1000) zvals - c(0.19,0.295,0.24,0.22,0.24,0.28,0.205,0.26, 0.21,0.255,0.275,0.225,0.235,0.265,0.135) my.3dplot$points3d(x=xvals,y=yvals,z=zvals,col=blue,type=h,pch=16) Look carefully at ?seq and you may understand what you've done wrong ... Ben Bolker __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help using gPath
Here's a partial extract from a sample session after running your code (NOTE this is using the development version of R; grid.ls() does not exist in R 2.5.1 or earlier): Inspect the grob tree with grid.ls() (similar to Hadley's current.grobTree(), but with different formatting) ... (I'll probably remove current.grobTree as soon as grid.ls makes it to a released version of R) grid.ls() plot-surrounds GRID.cellGrob.118 background GRID.cellGrob.119 plot.gTree.113 background guide.gTree.90 background.rect.80 minor-horizontal.segments.82 minor-vertical.segments.84 # OUTPUT TRUNCATED The format is much nicer than mine! ... It is not necessarily obvious which grob is which, but a little trial and error (e.g., grid.edit() to change the colour of a grob) shows that the border on the first panel is 'guide.rect.92', which is a child of 'plot.gTree.113' (NOTE the numbers come from a fresh R session). I will try and rename these grobs so that they are more easily accessible (and reproducible across multiple calls). That should make things easier in the future. Use grid.get() to grab that gTree and inspect that further using grid.ls(), this time also showing the viewports involved ... What do all the upViewports represent? Could the downViewports be incorporating into the same place as the original definition? (The remaining code should work for you in your version of R; it is just grid.ls() that is new.) Remove the original border rect, ... grid.remove(guide.rect.92, global=TRUE) ... (need global=TRUE because the border appears twice as a child of 'plot.gTree.113' [not sure why that is]) then add some lines that only draw the top, right, and bottom borders ... grid.add(plot.gTree.113, linesGrob(c(0, 1, 1, 0), c(1, 1, 0, 0), gp=gpar(col=green), vp=vpPath(layout, panel_1_1))) ... (I drew the new lines green so that they are easy to see). NOTE that in order to put the new lines in the same place as the original border, the new lines are added as children of the gTree 'plot.gTree.113' and they have a vpPath to make sure they get drawn in the right viewport within that gTree. Do you think it would be worth drawing all these rectangles as lines to make them easier to edit? What would probably be ideal would be a graphical interface to the grid.ls()-type information (something like an object explorer) that would make it easier to see which object is which and also make it easier to add and remove objects. A nice student project perhaps :) That would be great! Hadley -- http://had.co.nz/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help using gPath
Hi Emilio Gagliardi wrote: haha Paul, It's important not only to post code, but also to make sure that other people can run it (i.e., include real data or have the code generate data or use one of R's predefined data sets). Oh, I hadn't thought of using the predefined datasets, thats a good idea! Also, isn't this next time ? :) By next time I meant, when I ask a question in the future, I didn't think you'd respond! So here is some code! library(reshape) library(ggplot2) theme_t - list(grid.fill=white,grid.colour=lightgrey,background.colour=black,axis.colour=dimgrey) ggtheme(theme_t) grp - c(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3) time - c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2) cc - c(0.7271,0.7563,0.6979,0.8208,0.7521,0.7875,0.7563,0.7771,0.8208,0.7938,0.8083,0.7188,0.7521,0.7854,0.7979,0.7583,0.7646,0.6938,0.6813,0.7708,0.7375,0.8104,0.8104,0.7792,0.7833,0.8083,0.8021,0.7313,0.7958,0.7021 ,0.8167,0.8167,0.7583,0.7167,0.6563,0.6896,0.7333,0.8208,0.7396,0.8063,0.7083,0.6708,0.7292,0.7646,0.7667,0.775,0.8021,0.8125,0.7646,0.6917,0.7458,0.7833,0.7396,0.7229,0.7708,0.7729,0.8083,0.7771,0.6854,0.8417,0.7667,0.7063 ,0.75,0.7813,0.8271,0.7896,0.7979,0.625,0.7938,0.7583,0.7396,0.7583,0.7938,0.7333,0.7875,0.8146) data - as.data.frame(cbind(time,grp,cc)) data$grp - factor(data$grp,labels=c(Group A,Group B)) data$time - factor(data$time,labels=c(Pre-test,Post-test)) boxplot - qplot(grp, cc, data=data, geom=boxplot, orientation=horizontal, ylim=c(0.5,1), main=Hello World!, xlab=Label X, ylab=Label Y, facets=.~time, colour=red, size=2) boxplot + geom_jitter(aes(colour=steelblue)) + scale_colour_identity() + scale_size_identity() grid.gedit(ylabel, gp=gpar(fontsize=16)) Great. Thanks. Some example code of my own below ... There's a book that provides a full explanation and the (basic) grid chapter is online (see http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html) Awesome, I'll check that out. Yep, the facilities for investigating the viewport and grob tree are basically inadequate. Based on some work Hadley did for ggplot, the development version of R has a slightly better tool called grid.ls() that can show how the grob tree and the viewport tree intertwine. That would allow you to see which viewport each grob was drawn in, which would help you, for example, to know which viewport you had to go to to replace a rectangle you want to remove. okie dokie, I'm ready to be amazed! hehe. Or perhaps amused ... Here's a partial extract from a sample session after running your code (NOTE this is using the development version of R; grid.ls() does not exist in R 2.5.1 or earlier): Inspect the grob tree with grid.ls() (similar to Hadley's current.grobTree(), but with different formatting) ... grid.ls() plot-surrounds GRID.cellGrob.118 background GRID.cellGrob.119 plot.gTree.113 background guide.gTree.90 background.rect.80 minor-horizontal.segments.82 minor-vertical.segments.84 # OUTPUT TRUNCATED ... It is not necessarily obvious which grob is which, but a little trial and error (e.g., grid.edit() to change the colour of a grob) shows that the border on the first panel is 'guide.rect.92', which is a child of 'plot.gTree.113' (NOTE the numbers come from a fresh R session). Use grid.get() to grab that gTree and inspect that further using grid.ls(), this time also showing the viewports involved ... grid.ls(grid.get(plot.gTree.113), viewports=TRUE, fullNames=TRUE) gTree[plot.gTree.113] viewport[layout] viewport[strip_h_1_1] upViewport[1] viewport[strip_h_1_2] upViewport[1] viewport[strip_v_1_1] upViewport[1] viewport[axis_h_1_1] upViewport[1] viewport[axis_h_1_2] upViewport[1] viewport[axis_v_1_1] upViewport[1] viewport[panel_1_1] upViewport[1] viewport[panel_1_2] upViewport[2] rect[background] downViewport[layout] downViewport[panel_1_1] gTree[guide.gTree.90] rect[background.rect.80] segments[minor-horizontal.segments.82] # OUTPUT TRUNCATED grid.ls(grid.get(plot.gTree.113), viewports=TRUE, print=grobPathListing) |plot.gTree.113 |plot.gTree.113::background layout::panel_1_1|plot.gTree.113::guide.gTree.90 layout::panel_1_1|plot.gTree.113::guide.gTree.90::background.rect.80 layout::panel_1_1|plot.gTree.113::guide.gTree.90::minor-horizontal.segments.82 layout::panel_1_1|plot.gTree.113::guide.gTree.90::minor-vertical.segments.84 #
Re: [R] Help with cumsum function
Hectorman Hectorman wrote: Hello! I have a question regarding the cumsum function that I do not know how to solve. Would appreciate help from someone. I have imported data from a txtfile with 2 columns. I am interested in the seconds column, which contains numbers from i=0 to 40. I would like to count the number of instances of the numbers 0 to 40 in the seconds column. My problem is that if there are no observations of one number i in the second column cumsum skips this in the output. Below is an example of the output of the argument Y=cumsum(table(x[,2])) 0 1 2 3 5 6 789 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 3 5 6 10 13 14 16 18 21 25 27 30 32 35 38 40 42 54 105 233 306 341 383 417 2526 27 28 2930 31 32 33 34 35 36 37 38 39 40 441 468 487 502 518 532 542 546 552 564 566 574 578 584 591 594 As you can see from the output there are no observations of i=4 in this column. Are there any way I could return the following result instead 0 1 2 3 45 6 78 and so on 3 5 6 10 10 13 14 16 18 When i=4 cumsum is the same as when i=3 (10) Y - cumsum(table(factor(x[,2], levels=0:40))) Uwe Ligges I would really appreciate if anyone could help me with this one:) Jan Moberg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help using gPath
Hi Emilio Gagliardi wrote: Hi Paul, I'm sorry for not posting code, I wasn't sure if it would be helpful without the data...should I post the code and a sample of the data? I will remember to do that next time! It's important not only to post code, but also to make sure that other people can run it (i.e., include real data or have the code generate data or use one of R's predefined data sets). Also, isn't this next time ? :) grid.gedit(gPath(ylabel.text.382), gp=gpar(fontsize=16)) OK, I think my confusion comes from the notation that current.grobTree() produces and what strings are required in order to make changes to the underlying grobs. But, from what you've provided, it looks like I can access each grob with its unique name, regardless of which parent it is nested in...that helps Yes. By default, grid will search the tree of all grobs to find the name you provide. You can even just provide part of the name and it will find partial matches (depending on argument settings). On the other hand, by specifying a path that specified parent and child grobs, you can make sure you get exactly the grob you want. like to remove the left border on the first panel. I'd like to adjust the I'd guess you'd have to remove the grob background.rect.345 and then draw in just the sides you want, which would require getting to the right viewport, for which you'll need to study the viewport tree (see current.vpTree()) I did some digging into this and it seems pretty complicated, is there an example anywhere that makes sense to the beginner? The whole viewport grob relationship is not clear to me. So, accessing viewports and removing objects and drawing new ones is beyond me at this point. I can get my mind around your example below because I can see the object I want to modify in the viewer, and the code changes a property of that object, click enter, and bang the object changes. When you start talking external pointers and finding viewports and pushing and popping grobs I just get lost. I found the viewports for the grobTree, it looks like this: There's a book that provides a full explanation and the (basic) grid chapter is online (see http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html) viewport[ROOT]-(viewport[layout]-(viewport[axis_h_1_1]-(viewport[bottom_axis]-(viewport[labels], viewport[ticks])), viewport[axis_h_1_2]-(viewport[bottom_axis]-(viewport[labels], viewport[ticks])), viewport[axis_v_1_1]-(viewport[left_axis]-(viewport[labels], viewport[ticks])), viewport[panel_1_1], viewport[panel_1_2], viewport[strip_h_1_1], viewport[strip_h_1_2], viewport[strip_v_1_1])) at that point I was like, ok, I'm done. :S Yep, the facilities for investigating the viewport and grob tree are basically inadequate. Based on some work Hadley did for ggplot, the development version of R has a slightly better tool called grid.ls() that can show how the grob tree and the viewport tree intertwine. That would allow you to see which viewport each grob was drawn in, which would help you, for example, to know which viewport you had to go to to replace a rectangle you want to remove. Something like ... grid.gedit(geom_bar.rect, gp=gpar(col=green)) Again, it would really help to have some code to run. My apologies, I thought the grobTree was sufficient in this case. Thanks very much for your help. Sorry to harp on about it, but if I had your code I could show you an example of how grid.ls() might help. Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with counting how many times each value occur in each column
[Gabor Grothendieck] table(col(mat), mat) Clever, simple, and elegant! :-) -- François Pinard http://pinard.progiciels-bpi.ca __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help wit matrices
An even simpler solution is: mat2 - 1 * (mat1 0.25) Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lanre Okusanya Sent: Friday, August 10, 2007 2:20 PM To: jim holtman Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Help wit matrices that was ridiculously simple. duh. THanks Lanre On 8/10/07, jim holtman [EMAIL PROTECTED] wrote: Is this what you want: x - matrix(runif(100), 10) round(x, 3) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0.268 0.961 0.262 0.347 0.306 0.762 0.524 0.062 0.028 0.226 [2,] 0.219 0.100 0.165 0.131 0.578 0.933 0.317 0.109 0.527 0.131 [3,] 0.517 0.763 0.322 0.374 0.910 0.471 0.278 0.382 0.880 0.982 [4,] 0.269 0.948 0.510 0.631 0.143 0.604 0.788 0.169 0.373 0.327 [5,] 0.181 0.819 0.924 0.390 0.415 0.485 0.702 0.299 0.048 0.507 [6,] 0.519 0.308 0.511 0.690 0.211 0.109 0.165 0.192 0.139 0.681 [7,] 0.563 0.650 0.258 0.689 0.429 0.248 0.064 0.257 0.321 0.099 [8,] 0.129 0.953 0.046 0.555 0.133 0.499 0.755 0.181 0.155 0.119 [9,] 0.256 0.954 0.418 0.430 0.460 0.373 0.620 0.477 0.132 0.050 [10,] 0.718 0.340 0.854 0.453 0.943 0.935 0.170 0.771 0.221 0.929 ifelse(x .5, 1, 0) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]010001100 0 [2,]000011001 0 [3,]110010001 1 [4,]011101100 0 [5,]011000100 1 [6,]101100000 1 [7,]110100000 0 [8,]010100100 0 [9,]010000100 0 [10,]101011010 1 On 8/10/07, Lanre Okusanya [EMAIL PROTECTED] wrote: Hello all, I am working with a 1000x1000 matrix, and I would like to return a 1000x1000 matrix that tells me which value in the matrix is greater than a theshold value (1 or 0 indicator). i have tried mat2-as.matrix(as.numeric(mat10.25)) but that returns a 1:10 matrix. I have also tried for loops, but they are grossly inefficient. THanks for all your help in advance. Lanre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help wit matrices
Will something like this help? mm - matrix(rnorm(100),nrow=10) mm nn - mm .5 nn --- Lanre Okusanya [EMAIL PROTECTED] wrote: Hello all, I am working with a 1000x1000 matrix, and I would like to return a 1000x1000 matrix that tells me which value in the matrix is greater than a theshold value (1 or 0 indicator). i have tried mat2-as.matrix(as.numeric(mat10.25)) but that returns a 1:10 matrix. I have also tried for loops, but they are grossly inefficient. THanks for all your help in advance. Lanre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help wit matrices
I hope you don't mind that I offer also two solutions. No.1 is really bad. No.2 should be on par with the other ones. Best, Roland mydata - matrix(rnorm(10*10), ncol=10) threshold.value - 1.5 mydata2 - matrix(0, nrow=nrow(mydata), ncol=ncol(mydata)) mydata3 - matrix(0, nrow=nrow(mydata), ncol=ncol(mydata)) ### not really the way to go: for (i in 1:nrow(mydata)) { for (j in 1:ncol(mydata)) { if (mydata[i,j]threshold.value) { mydata2[i,j] - 1 } } } ### a better way... mydata3[mydata threshold.value] - 1 mydata2 mydata3 Lanre Okusanya wrote: Hello all, I am working with a 1000x1000 matrix, and I would like to return a 1000x1000 matrix that tells me which value in the matrix is greater than a theshold value (1 or 0 indicator). i have tried mat2-as.matrix(as.numeric(mat10.25)) but that returns a 1:10 matrix. I have also tried for loops, but they are grossly inefficient. THanks for all your help in advance. Lanre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help using gPath
haha Paul, It's important not only to post code, but also to make sure that other people can run it (i.e., include real data or have the code generate data or use one of R's predefined data sets). Oh, I hadn't thought of using the predefined datasets, thats a good idea! Also, isn't this next time ? :) By next time I meant, when I ask a question in the future, I didn't think you'd respond! So here is some code! library(reshape) library(ggplot2) theme_t - list(grid.fill=white,grid.colour=lightgrey,background.colour= black,axis.colour=dimgrey) ggtheme(theme_t) grp - c(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3) time - c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2) cc - c(0.7271,0.7563,0.6979,0.8208,0.7521,0.7875,0.7563,0.7771,0.8208, 0.7938,0.8083,0.7188,0.7521,0.7854,0.7979,0.7583,0.7646,0.6938,0.6813,0.7708 ,0.7375,0.8104,0.8104,0.7792,0.7833,0.8083,0.8021,0.7313,0.7958,0.7021, 0.8167,0.8167,0.7583,0.7167,0.6563,0.6896,0.7333,0.8208,0.7396,0.8063,0.7083 ,0.6708,0.7292,0.7646,0.7667,0.775,0.8021,0.8125,0.7646,0.6917,0.7458,0.7833 ,0.7396,0.7229,0.7708,0.7729,0.8083,0.7771,0.6854,0.8417,0.7667,0.7063,0.75, 0.7813,0.8271,0.7896,0.7979,0.625,0.7938,0.7583,0.7396,0.7583,0.7938,0.7333, 0.7875,0.8146) data - as.data.frame(cbind(time,grp,cc)) data$grp - factor(data$grp,labels=c(Group A,Group B)) data$time - factor(data$time,labels=c(Pre-test,Post-test)) boxplot - qplot(grp, cc, data=data, geom=boxplot, orientation=horizontal, ylim=c(0.5,1), main=Hello World!, xlab=Label X, ylab=Label Y, facets=.~time, colour=red, size=2) boxplot + geom_jitter(aes(colour=steelblue)) + scale_colour_identity() + scale_size_identity() grid.gedit(ylabel, gp=gpar(fontsize=16)) There's a book that provides a full explanation and the (basic) grid chapter is online (see http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html) Awesome, I'll check that out. Yep, the facilities for investigating the viewport and grob tree are basically inadequate. Based on some work Hadley did for ggplot, the development version of R has a slightly better tool called grid.ls() that can show how the grob tree and the viewport tree intertwine. That would allow you to see which viewport each grob was drawn in, which would help you, for example, to know which viewport you had to go to to replace a rectangle you want to remove. okie dokie, I'm ready to be amazed! hehe. emilio [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help wit matrices
Is this what you want: x - matrix(runif(100), 10) round(x, 3) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0.268 0.961 0.262 0.347 0.306 0.762 0.524 0.062 0.028 0.226 [2,] 0.219 0.100 0.165 0.131 0.578 0.933 0.317 0.109 0.527 0.131 [3,] 0.517 0.763 0.322 0.374 0.910 0.471 0.278 0.382 0.880 0.982 [4,] 0.269 0.948 0.510 0.631 0.143 0.604 0.788 0.169 0.373 0.327 [5,] 0.181 0.819 0.924 0.390 0.415 0.485 0.702 0.299 0.048 0.507 [6,] 0.519 0.308 0.511 0.690 0.211 0.109 0.165 0.192 0.139 0.681 [7,] 0.563 0.650 0.258 0.689 0.429 0.248 0.064 0.257 0.321 0.099 [8,] 0.129 0.953 0.046 0.555 0.133 0.499 0.755 0.181 0.155 0.119 [9,] 0.256 0.954 0.418 0.430 0.460 0.373 0.620 0.477 0.132 0.050 [10,] 0.718 0.340 0.854 0.453 0.943 0.935 0.170 0.771 0.221 0.929 ifelse(x .5, 1, 0) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]010001100 0 [2,]000011001 0 [3,]110010001 1 [4,]011101100 0 [5,]011000100 1 [6,]101100000 1 [7,]110100000 0 [8,]010100100 0 [9,]010000100 0 [10,]101011010 1 On 8/10/07, Lanre Okusanya [EMAIL PROTECTED] wrote: Hello all, I am working with a 1000x1000 matrix, and I would like to return a 1000x1000 matrix that tells me which value in the matrix is greater than a theshold value (1 or 0 indicator). i have tried mat2-as.matrix(as.numeric(mat10.25)) but that returns a 1:10 matrix. I have also tried for loops, but they are grossly inefficient. THanks for all your help in advance. Lanre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with counting how many times each value occur in each column
Try this where we have constructed the example to illustrate that it does handle the case where not all values are in each column: mat - matrix(rep(1:6, each = 4), 6) table(col(mat), mat) On 8/10/07, Tom Cohen [EMAIL PROTECTED] wrote: Dear list, I have the following dataset and want to know how many times each value occur in each column. data [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] -100 -100 -100000000 -100 [2,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [3,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [4,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [5,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -50 [6,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [7,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [8,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [9,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [10,] -100 -100 -100 -50 -100 -100 -100 -100 -100 -100 [11,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [12,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [13,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [14,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [15,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [16,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [17,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [18,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [19,] -100 -100 -100000000 -100 [20,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 The result matrix should look like -100 0 -50 [1] 20 [2] 20 [3] 20 [4] 17 [5] 18 [6] 18 [7] 18 and so on [8] [9] [10] How can I do this in R ? Thanks alot for your help, Tom - Jämför pris på flygbiljetter och hotellrum: http://shopping.yahoo.se/c-169901-resor-biljetter.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help wit matrices
mat2-matrix(as.numeric(mat10.25), ncol=1000) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 10/08/07, Lanre Okusanya [EMAIL PROTECTED] wrote: Hello all, I am working with a 1000x1000 matrix, and I would like to return a 1000x1000 matrix that tells me which value in the matrix is greater than a theshold value (1 or 0 indicator). i have tried mat2-as.matrix(as.numeric(mat10.25)) but that returns a 1:10 matrix. I have also tried for loops, but they are grossly inefficient. THanks for all your help in advance. Lanre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with counting how many times each value occur in each column
[Tom Cohen] I have the following dataset and want to know how many times each value occur in each column. data [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] -100 -100 -100000000 -100 [2,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [3,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [4,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [5,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -50 [6,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [7,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [8,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [9,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [10,] -100 -100 -100 -50 -100 -100 -100 -100 -100 -100 [11,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [12,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [13,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [14,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [15,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [16,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [17,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [18,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [19,] -100 -100 -100000000 -100 [20,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 The result matrix should look like -100 0 -50 [1] 20 [2] 20 [3] 20 [4] 17 [5] 18 [6] 18 [7] 18 and so on [8] [9] [10] Presuming that data is a matrix, one could try a sequence like this: dataf - factor(data) dim(dataf) - dim(data) result - t(apply(dataf, 2, tabulate, nlevels(dataf))) colnames(result) - levels(dataf) result If you want the columns sorted, you might decide the order of the levels on the factor() call, or explicitly reorder columns afterwards. -- François Pinard http://pinard.progiciels-bpi.ca __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help wit matrices
that was ridiculously simple. duh. THanks Lanre On 8/10/07, jim holtman [EMAIL PROTECTED] wrote: Is this what you want: x - matrix(runif(100), 10) round(x, 3) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0.268 0.961 0.262 0.347 0.306 0.762 0.524 0.062 0.028 0.226 [2,] 0.219 0.100 0.165 0.131 0.578 0.933 0.317 0.109 0.527 0.131 [3,] 0.517 0.763 0.322 0.374 0.910 0.471 0.278 0.382 0.880 0.982 [4,] 0.269 0.948 0.510 0.631 0.143 0.604 0.788 0.169 0.373 0.327 [5,] 0.181 0.819 0.924 0.390 0.415 0.485 0.702 0.299 0.048 0.507 [6,] 0.519 0.308 0.511 0.690 0.211 0.109 0.165 0.192 0.139 0.681 [7,] 0.563 0.650 0.258 0.689 0.429 0.248 0.064 0.257 0.321 0.099 [8,] 0.129 0.953 0.046 0.555 0.133 0.499 0.755 0.181 0.155 0.119 [9,] 0.256 0.954 0.418 0.430 0.460 0.373 0.620 0.477 0.132 0.050 [10,] 0.718 0.340 0.854 0.453 0.943 0.935 0.170 0.771 0.221 0.929 ifelse(x .5, 1, 0) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]010001100 0 [2,]000011001 0 [3,]110010001 1 [4,]011101100 0 [5,]011000100 1 [6,]101100000 1 [7,]110100000 0 [8,]010100100 0 [9,]010000100 0 [10,]101011010 1 On 8/10/07, Lanre Okusanya [EMAIL PROTECTED] wrote: Hello all, I am working with a 1000x1000 matrix, and I would like to return a 1000x1000 matrix that tells me which value in the matrix is greater than a theshold value (1 or 0 indicator). i have tried mat2-as.matrix(as.numeric(mat10.25)) but that returns a 1:10 matrix. I have also tried for loops, but they are grossly inefficient. THanks for all your help in advance. Lanre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help wit matrices
On 10-Aug-07 18:05:50, Lanre Okusanya wrote: Hello all, I am working with a 1000x1000 matrix, and I would like to return a 1000x1000 matrix that tells me which value in the matrix is greater than a theshold value (1 or 0 indicator). i have tried mat2-as.matrix(as.numeric(mat10.25)) but that returns a 1:10 matrix. I have also tried for loops, but they are grossly inefficient. THanks for all your help in advance. Lanre Simple-minded, but: S-matrix(rnorm(25),nrow=5) S [,1][,2] [,3] [,4] [,5] [1,] -0.9283624 -0.44418487 1.1174555 1.9040999 -0.4675796 [2,] 0.2658770 -0.28492642 -1.2271013 -0.5713291 1.8036235 [3,] 0.7010885 -0.42972262 0.7576021 0.3407972 -1.0628487 [4,] -0.2003087 0.87006841 0.6233792 -0.9974902 -0.9104270 [5,] 0.2729014 0.09781886 -1.0004486 1.5987385 -0.4747125 T-0*S T[S0.25] - 1+0*S[S0.25] T [,1] [,2] [,3] [,4] [,5] [1,]00110 [2,]10001 [3,]10110 [4,]01100 [5,]10010 Does this work OK for your big matrix? HTH Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 10-Aug-07 Time: 19:50:37 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with counting how many times each value occur in eachcolumn
Tom, If all values (-100,0,-50) would be in every column then simple apply(data,2,table) would work. Even if there aren0t all values in every column you could correct that and insert additional lines with all values for all columns like data - cbind(data,matrix(ncol=10,nrow=3,rep(c(-100,0,-50),10))) and then do apply(data,2,table)-1 to get correct results. But someone on a list can probably make much more elegant solution. Bye, Gasper Cankar, PhD Researcher National Examinations Centre Slovenia -Original Message- From: Tom Cohen [mailto:[EMAIL PROTECTED] Sent: Friday, August 10, 2007 2:02 PM To: r-help@stat.math.ethz.ch Subject: [R] help with counting how many times each value occur in eachcolumn Dear list, I have the following dataset and want to know how many times each value occur in each column. data [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] -100 -100 -100000000 -100 [2,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [3,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [4,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [5,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -50 [6,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [7,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [8,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [9,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [10,] -100 -100 -100 -50 -100 -100 -100 -100 -100 -100 [11,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [12,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [13,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [14,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [15,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [16,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [17,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [18,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [19,] -100 -100 -100000000 -100 [20,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 The result matrix should look like -100 0 -50 [1] 20 [2] 20 [3] 20 [4] 17 [5] 18 [6] 18 [7] 18 and so on [8] [9] [10] How can I do this in R ? Thanks alot for your help, Tom - Jämför pris på flygbiljetter och hotellrum: http://shopping.yahoo.se/c-169901-resor-biljetter.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help on R performance using aov function
aov() will handle multiple responses and that would be considerably more efficient than running separate fits as you seem to be doing. Your code is nigh unreadable: please use your spacebar and remove the redundant semicolons: `Writing R Extensions' shows you how to tidy up your code to make it presentable. But I think anova_[[1]] is really coef(summary(aov_)) which is a lot more intelligible. On Thu, 9 Aug 2007, Francoise PFIFFELMANN wrote: Hi, Im trying to replace some SAS statistical functions by R (batch calling). But Ive seen that calling R in a batch mode (under Unix) takes about 2or 3 times more than SAS software. So its a great problem of performance for me. Here is an extract of the calculation: stoutput-file(res_oneWayAnova.dat,w); cat(Param|F|Prob,file=stoutput,\n); for (i in 1:n) { p-list_param[[i]] aov_-aov(A[,p]~ A[,wafer],data=A); anova_-summary(aov_); if (!is.na(anova_[[1]][1,5]) anova_[[1]][1,5]=0.0001) res_aov-cbind(p,anova_[[1]][1,4],0.0001) else res_aov-cbind(p,anova_[[1]][1,4],anova_[[1]][1,5]); cat(res_aov, file=stoutput, append = TRUE,sep = |,\n); }; close(stoutput); A is a data.frame of about (400 lines and 1800 parameters). Im a new user of R and I dont know if its a problem in my code or if there are some tips that I can use to optimise my treatment. Thanks a lot for your help. Françoise Pfiffelmann Engineering Data Analysis Group -- Crolles2 Alliance 860 rue Jean Monnet 38920 Crolles, France Tel: +33 438 92 29 84 Email: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help using gPath
Hi Emilio Gagliardi wrote: Hi everyone,I'm trying to figure out how to use gPath and the documentation is not very helpful :( I have the following plot object: plot-surrounds:: background plot.gTree.378:: background guide.gTree.355:: (background.rect.345, minor-horizontal.segments.347, minor-vertical.segments.349, major-horizontal.segments.351, major-vertical.segments.353) guide.gTree.356:: (background.rect.345, minor-horizontal.segments.347, minor-vertical.segments.349, major-horizontal.segments.351, major-vertical.segments.353) yaxis.gTree.338:: ticks.segments.321 labels.gTree.335:: (label.text.324, label.text.326, label.text.328, label.text.330, label.text.332, label.text.334) xaxis.gTree.339:: ticks.segments.309 labels.gTree.315:: (label.text.312, label.text.314) xaxis.gTree.340:: ticks.segments.309 labels.gTree.315:: (label.text.312, label.text.314) strip.gTree.364:: (background.rect.361, label.text.363) strip.gTree.370:: (background.rect.367, label.text.369) guide.rect.357 guide.rect.358 boxplots.gTree.283:: geom_boxplot.gTree.273:: (GRID.segments.267, GRID.segments.268, geom_bar.rect.270, geom_bar.rect.272) geom_boxplot.gTree.281:: (GRID.segments.275, GRID.segments.276, geom_bar.rect.278, geom_bar.rect.280) boxplots.gTree.301:: geom_boxplot.gTree.291:: (GRID.segments.285, GRID.segments.286, geom_bar.rect.288, geom_bar.rect.290) geom_boxplot.gTree.299:: (GRID.segments.293, GRID.segments.294, geom_bar.rect.296, geom_bar.rect.298) geom_jitter.points.303 geom_jitter.points.305 guide.rect.357 guide.rect.358 ylabel.text.382 xlabel.text.380 title It would be easier to help if we also had the code used to produce this plot, but in the meantime ... Could someone be so kind and create the proper call to grid.gedit() to access a couple of different aspects of this graph? I tried: grid.gedit(gPath(ylabel.text.382,labels), gp=gpar(fontsize=16)) # error That is looking for a grob called labels that is the child of a grob called ylabel.text.382. I can see a grob called ylabel.text.382, but it has no children. Try just ... grid.gedit(gPath(ylabel.text.382), gp=gpar(fontsize=16)) I'd like to change the margins on the label for the yaxis (not the tick marks) to put more space between the label and the tick marks. I'd also Margins may be tricky because it likely depends on a layout generated by ggplot; Hadley Wickham may have to help us out with a ggplot argument here ... (?) like to remove the left border on the first panel. I'd like to adjust the I'd guess you'd have to remove the grob background.rect.345 and then draw in just the sides you want, which would require getting to the right viewport, for which you'll need to study the viewport tree (see current.vpTree()) size of the font for the axis labels independently of the tick marks. I'd That's the one we've already done, right? like to change the color of the lines that make up the boxplots. Plus, I'd Something like ... grid.gedit(geom_bar.rect, gp=gpar(col=green)) ...? Again, it would really help to have some code to run. Paul like to change the margins of the strip labels. If you could show me a couple of examples I'm sure I cold get the rest working. Thanks so much, emilio [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help using gPath
Hi Paul, I'm sorry for not posting code, I wasn't sure if it would be helpful without the data...should I post the code and a sample of the data? I will remember to do that next time! grid.gedit(gPath(ylabel.text.382), gp=gpar(fontsize=16)) OK, I think my confusion comes from the notation that current.grobTree() produces and what strings are required in order to make changes to the underlying grobs. But, from what you've provided, it looks like I can access each grob with its unique name, regardless of which parent it is nested in...that helps like to remove the left border on the first panel. I'd like to adjust the I'd guess you'd have to remove the grob background.rect.345 and then draw in just the sides you want, which would require getting to the right viewport, for which you'll need to study the viewport tree (see current.vpTree()) I did some digging into this and it seems pretty complicated, is there an example anywhere that makes sense to the beginner? The whole viewport grob relationship is not clear to me. So, accessing viewports and removing objects and drawing new ones is beyond me at this point. I can get my mind around your example below because I can see the object I want to modify in the viewer, and the code changes a property of that object, click enter, and bang the object changes. When you start talking external pointers and finding viewports and pushing and popping grobs I just get lost. I found the viewports for the grobTree, it looks like this: viewport[ROOT]-(viewport[layout]-(viewport[axis_h_1_1]-(viewport[bottom_axis]-(viewport[labels], viewport[ticks])), viewport[axis_h_1_2]-(viewport[bottom_axis]-(viewport[labels], viewport[ticks])), viewport[axis_v_1_1]-(viewport[left_axis]-(viewport[labels], viewport[ticks])), viewport[panel_1_1], viewport[panel_1_2], viewport[strip_h_1_1], viewport[strip_h_1_2], viewport[strip_v_1_1])) at that point I was like, ok, I'm done. :S Something like ... grid.gedit(geom_bar.rect, gp=gpar(col=green)) Again, it would really help to have some code to run. My apologies, I thought the grobTree was sufficient in this case. Thanks very much for your help. emilio [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help on getting weekday
Baoqiang Cao wrote: Dear All, I'd like to know which weekday it is for any given date, such as, what is the weekday for 2006-06-01? Any help will be highly appreciated. See ?weekdays Uwe Ligges Best, Baoqiang [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with ROC curve
Hi Ritesh, may be i can help, but yeah i will try ? you can reach help to ROCR package by help.search(ROCR) What is the structure of your data ? can you give some sample i.e. few lines of your dataset ? To build ROC curve using only PSA(variable) alone of the original cohort against the ROC of the Model of the original cohort. what do you intend to do, please clarify more ? it sounds like you have been given tutorial, or you are working this for corporate ? :) cheers Rithesh M. Mohan [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 07/30/2007 01:06 PM To r-help@stat.math.ethz.ch cc Subject [R] help with ROC curve Hi I'm new to stats and R, so can you please help me or guide me building ROC curve in an elaborate way with codes I loaded ROCR package, but I'm not sure how to use it. Requirement To build ROC curve using only PSA(variable) alone of the original cohort against the ROC of the Model of the original cohort. It would be really great if you could help me with this. Thanks Rithesh M Mohan [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with Dates
Are you using the latest version of fame? 1.05 and earlier had a bug in tisFromCsv that was fixed in 1.08. Below I show what I get with fame version 1.08. There is still a problem in that the frequency-figuring logic appears to think the frequency is bwsunday (biweekly with weeks ending on Sunday) rather than semimonthly, which would appear to be a better fit. That's why the 19860330 observation is getting filled in with NA's. Jeff Lines - Date Price Open.Int. Comm.Long Comm.Short net.comm 15-Jan-86 673.25175645 65910 2842537485 31-Jan-86 677.00167350 54060 2712026940 14-Feb-86 680.25157985 37955 2542512530 28-Feb-86 691.75162775 49760 1603033730 14-Mar-86 706.50163495 54120 2799526125 31-Mar-86 709.75164120 54715 3039024325 + + + + + + boink - tisFromCsv(textConnection(Lines), dateFormat = %d-%b-%y, dateCol = Date, sep = ) boink $Price [,1] 19860119 673.25 19860202 677.00 19860216 680.25 19860302 691.75 19860316 706.50 19860330 NA 19860413 709.75 class: tis $Open.Int. [,1] 19860119 175645 19860202 167350 19860216 157985 19860302 162775 19860316 163495 19860330 NA 19860413 164120 class: tis $Comm.Long [,1] 19860119 65910 19860202 54060 19860216 37955 19860302 49760 19860316 54120 19860330NA 19860413 54715 class: tis $Comm.Short [,1] 19860119 28425 19860202 27120 19860216 25425 19860302 16030 19860316 27995 19860330NA 19860413 30390 class: tis $net.comm [,1] 19860119 37485 19860202 26940 19860216 12530 19860302 33730 19860316 26125 19860330NA 19860413 24325 class: tis Gabor Grothendieck [EMAIL PROTECTED] writes: On 26 Jul 2007 09:59:31 -0400, Jeffrey J. Hallman [EMAIL PROTECTED] wrote: zoo is nice. 'tisFromCsv()' in the fame package is nicer. Jeff 1. What am I doing wrong here? I only get one data column. 2. I assume the regularized dates which do not exactly match the input ones are intended so as to make this a regularly spaced series. Is that right? 3. What is the cause of the warning message? 4. Why is a list returned with a single component containing the output? Thanks. library(fame) Lines - Date Price Open.Int. Comm.Long Comm.Short net.comm + 15-Jan-86 673.25175645 65910 2842537485 + 31-Jan-86 677.00167350 54060 2712026940 + 14-Feb-86 680.25157985 37955 2542512530 + 28-Feb-86 691.75162775 49760 1603033730 + 14-Mar-86 706.50163495 54120 2799526125 + 31-Mar-86 709.75164120 54715 3039024325 + tisFromCsv(textConnection(Lines), dateFormat = %d-%b-%y, dateCol = Date, sep = ) [[1]] [,1] 19860119 673.25 19860202 677.00 19860216 680.25 19860302 691.75 19860316 706.50 19860330 709.75 class: tis Warning message: number of items to replace is not a multiple of replacement length in: x[i] - value __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with Dates
Yes, I was using 1.05. I get the same result as you with 1.08. On 26 Jul 2007 11:39:41 -0400, Jeffrey J. Hallman [EMAIL PROTECTED] wrote: Are you using the latest version of fame? 1.05 and earlier had a bug in tisFromCsv that was fixed in 1.08. Below I show what I get with fame version 1.08. There is still a problem in that the frequency-figuring logic appears to think the frequency is bwsunday (biweekly with weeks ending on Sunday) rather than semimonthly, which would appear to be a better fit. That's why the 19860330 observation is getting filled in with NA's. Jeff Lines - Date Price Open.Int. Comm.Long Comm.Short net.comm 15-Jan-86 673.25175645 65910 2842537485 31-Jan-86 677.00167350 54060 2712026940 14-Feb-86 680.25157985 37955 2542512530 28-Feb-86 691.75162775 49760 1603033730 14-Mar-86 706.50163495 54120 2799526125 31-Mar-86 709.75164120 54715 3039024325 + + + + + + boink - tisFromCsv(textConnection(Lines), dateFormat = %d-%b-%y, dateCol = Date, sep = ) boink $Price [,1] 19860119 673.25 19860202 677.00 19860216 680.25 19860302 691.75 19860316 706.50 19860330 NA 19860413 709.75 class: tis $Open.Int. [,1] 19860119 175645 19860202 167350 19860216 157985 19860302 162775 19860316 163495 19860330 NA 19860413 164120 class: tis $Comm.Long [,1] 19860119 65910 19860202 54060 19860216 37955 19860302 49760 19860316 54120 19860330NA 19860413 54715 class: tis $Comm.Short [,1] 19860119 28425 19860202 27120 19860216 25425 19860302 16030 19860316 27995 19860330NA 19860413 30390 class: tis $net.comm [,1] 19860119 37485 19860202 26940 19860216 12530 19860302 33730 19860316 26125 19860330NA 19860413 24325 class: tis Gabor Grothendieck [EMAIL PROTECTED] writes: On 26 Jul 2007 09:59:31 -0400, Jeffrey J. Hallman [EMAIL PROTECTED] wrote: zoo is nice. 'tisFromCsv()' in the fame package is nicer. Jeff 1. What am I doing wrong here? I only get one data column. 2. I assume the regularized dates which do not exactly match the input ones are intended so as to make this a regularly spaced series. Is that right? 3. What is the cause of the warning message? 4. Why is a list returned with a single component containing the output? Thanks. library(fame) Lines - Date Price Open.Int. Comm.Long Comm.Short net.comm + 15-Jan-86 673.25175645 65910 2842537485 + 31-Jan-86 677.00167350 54060 2712026940 + 14-Feb-86 680.25157985 37955 2542512530 + 28-Feb-86 691.75162775 49760 1603033730 + 14-Mar-86 706.50163495 54120 2799526125 + 31-Mar-86 709.75164120 54715 3039024325 + tisFromCsv(textConnection(Lines), dateFormat = %d-%b-%y, dateCol = Date, sep = ) [[1]] [,1] 19860119 673.25 19860202 677.00 19860216 680.25 19860302 691.75 19860316 706.50 19860330 709.75 class: tis Warning message: number of items to replace is not a multiple of replacement length in: x[i] - value __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with Dates
On 26 Jul 2007 09:59:31 -0400, Jeffrey J. Hallman [EMAIL PROTECTED] wrote: zoo is nice. 'tisFromCsv()' in the fame package is nicer. Jeff 1. What am I doing wrong here? I only get one data column. 2. I assume the regularized dates which do not exactly match the input ones are intended so as to make this a regularly spaced series. Is that right? 3. What is the cause of the warning message? 4. Why is a list returned with a single component containing the output? Thanks. library(fame) Lines - Date Price Open.Int. Comm.Long Comm.Short net.comm + 15-Jan-86 673.25175645 65910 2842537485 + 31-Jan-86 677.00167350 54060 2712026940 + 14-Feb-86 680.25157985 37955 2542512530 + 28-Feb-86 691.75162775 49760 1603033730 + 14-Mar-86 706.50163495 54120 2799526125 + 31-Mar-86 709.75164120 54715 3039024325 + tisFromCsv(textConnection(Lines), dateFormat = %d-%b-%y, dateCol = Date, sep = ) [[1]] [,1] 19860119 673.25 19860202 677.00 19860216 680.25 19860302 691.75 19860316 706.50 19860330 709.75 class: tis Warning message: number of items to replace is not a multiple of replacement length in: x[i] - value __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with Dates
zoo is nice. 'tisFromCsv()' in the fame package is nicer. Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help on looping problem needed!
try this: tol - 0.01 mat - matrix(as.numeric(NA), 1000, 5) k - 1 while(any(is.na(mat))){ x - rnorm(1000, sd = 0.02) if (abs(mean(x)) tol) { mat[, k] - x k - k + 1 } } abs(colMeans(mat)) par(mfrow = c(2, 3)) apply(mat, 2, hist) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Ing. Michal Kneifl, Ph.D. [EMAIL PROTECTED] To: Rhelp r-help@stat.math.ethz.ch Sent: Monday, July 23, 2007 4:40 PM Subject: [R] Help on looping problem needed! I am wondering if someone could help me out with following problem: I have written a for loop which generates a random normal distribution let us say 1000 times. When the restriction is met (mean0.01), the loop stops, prints the mean value and plots a histogram. for(i in 1:1000) { a-rnorm(1000,0,.2) b-abs(mean(a)) if(b.01) next else {print(b);hist(a);break}} How to reshape the loop when I want to find at least 5 distibutions that meet my restriction and save them (assign) under names R1R5. Could you help me please? Michael __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with Dates
I am taking an excel dataset and reading it into R using read.table. (actually I am dumping the data into a .txt file first and then reading data in to R). If you are on *windows* you could also try my xlsReadWrite package which contains some datetime functions. Exceldates (e.g. formatted as dd-mmm-yy) can be read as COleDateTime (floating point) values or as character strings. The first one is preferable imo as it avoids a typecast and it is the type commonly used in OLE automation. But how can I subset for multiple periods e.g 00- 05? Floating point numbers dates can be converted to year-strings with dateTimeToStr( value, yy ) and then subset as shown in a previous post. The (paid) pro version contains many more date functions, e.g. yearOf. Details see http://treetron.googlepages.com/xls.oledatetimeex.html. -- Regards, Hans-Peter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with Dates
Alex: I am taking an excel dataset and reading it into R using read.table. This sets up a data.frame object. The data you have are probably more conveniently represented as a time series, storing the date in an appropriate format, e.g., in class Date. (actually I am dumping the data into a .txt file first and then reading data in to R). Then you can do both steps (calling read.table() and transformation to a time series) in one go using the function read.zoo() from package zoo. If your text file looks like Date Price Open.Int. Comm.Long Comm.Short net.comm 15-Jan-86 673.25175645 65910 2842537485 31-Jan-86 677.00167350 54060 2712026940 14-Feb-86 680.25157985 37955 2542512530 28-Feb-86 691.75162775 49760 1603033730 14-Mar-86 706.50163495 54120 2799526125 31-Mar-86 709.75164120 54715 3039024325 then you can read it in via z - read.zoo(mydata.txt, format = %d-%b-%y, header = TRUE) Then you can do all sorts of standard things for time series, such as plot(z) or... The dataset runs from 1986 to 2007. I want to be able to take subsets of my data based on date e.g. data between 2000 - 2005. ...subsetting z2 - window(z, start = as.Date(2000-01-01), end = as.Date(2005-12-31)) etc. Look at the zoo package vignettes for more information vignette(zoo-quickref, package = zoo) vignette(zoo, package = zoo) hth, Z As it stands, I can't work with the dates as they are not in correct format. I tried successfully converting the dates to just the year using: transform(data, Yr = format(as.Date(as.character(Date),format = '%d-%b-%y'), %y))) This gives the following format: Date Price Open.Int. Comm.Long Comm.Short net.comm Yr 1 15-Jan-86 673.25175645 65910 2842537485 86 2 31-Jan-86 677.00167350 54060 2712026940 86 3 14-Feb-86 680.25157985 37955 2542512530 86 4 28-Feb-86 691.75162775 49760 1603033730 86 5 14-Mar-86 706.50163495 54120 2799526125 86 6 31-Mar-86 709.75164120 54715 3039024325 86 I can subset for a single year e.g: head(subset(df, Yr ==00) But how can I subset for multiple periods e.g 00- 05? The following won't work: head(subset(df, Yr ==00 Yr==01) or head(subset(df, Yr = c(00,01,02,03) I can't help but feeling that I am missing something and there is a simpler route. I leafed through R newletter 4.1 which deals with dates and times but it seemed that strptime and POSIXct / POSIXlt are not what I need either. Can anybody help me? Regards Alex __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with heatmap - how to remove annoying X before numeric values?
Sorry, I just realized I didn't send this to the list! (See below) Thanks for all the help! All is working fine now. If anyone knows of a more straightforward way to change the Value string for the Key, please let me know (just to satisfy my curiosity). I got it to work by modifying the source code (specifically, heatmap.2.R in the gplots package). However, before, I didn't make the call source(heatmap.2.R) before I called source(mysillyheatmap.R) Making the additional call to heatmap.2.R fixed everything. Thanks again for all your help! On 7/19/07, Suzanne Matthews [EMAIL PROTECTED] wrote: Thank you all for your prompt replies! The check.names=FALSE parameter fixed things entirely. One more question: Is there a straightforward way to modify the the Values string that labels the key to a user-defined value? For example, let's say I want to change Values to Silly Values. So far, what I have found that I need to do is actually go and change a static string in the source code. Is there a more direct way? Also, after I make the source code change (in gplots package, file: heatmap.2.R), how do I have R build from that? If I remember correctly, if I put the new heatmap.2.R in my directory, R is supposed to check for functions and such there before it goes and builds it from the main source code base (located at /usr/bin/R). I am a touch confused on which directory is my directory, where R will check first. I tried putting the modified heatmap.2.R file in the directory that my script is, and where I initially run R. But that didn't work! Is there anything that I should add to my R script that will force it to read from that from my directory? If not, which directory should I place this in? My OS is OS X, so I think Unix-based instructions will work. Thank you once again for your time and patience! Sincerely, Suzanne On 7/18/07, Moshe Olshansky [EMAIL PROTECTED] wrote: I was right saying that my solution was not the best possible! --- Prof Brian Ripley [EMAIL PROTECTED] wrote: read.table('temp.txt', check.names = FALSE) would be easier (and more general, since make.names can do more than prepend an 'X'). On Wed, 18 Jul 2007, Moshe Olshansky wrote: Hi Suzanne, My solution (which I am sure is not the best) would be: heat - read.table('temp.txt') heat X1905 X1910 X1950 X1992 X2011 X2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat0.40 0.54 0.52 0.60 0.60 0.63 Cat0.16 0.27 0.29 0.39 0.37 0.41 Dog0.43 0.54 0.52 0.61 0.60 0.62 Lynx 0.50 0.57 0.54 0.59 0.50 0.59 a-names(heat) b-strsplit(a,split=X) w-unlist(b) w [1] 1905 1910 1950 1992 2011 2020 z - w[seq(2,length(w),by=2)] z [1] 1905 1910 1950 1992 2011 2020 names(heat) - z heat 1905 1910 1950 1992 2011 2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat 0.40 0.54 0.52 0.60 0.60 0.63 Cat 0.16 0.27 0.29 0.39 0.37 0.41 Dog 0.43 0.54 0.52 0.61 0.60 0.62 Lynx 0.50 0.57 0.54 0.59 0.50 0.59 Regards, Moshe. --- Suzanne Matthews [EMAIL PROTECTED] wrote: Hello All, I have a simple question based on how things are labeled on my heat map; particularly, there is this annoying X that appears before the numeric value of all the labels of my columns. Let's say I have the following silly data, stored in temp.txt 19051910195019922011 2020 Gnat0.080.290.290.370.39 0.43 Snake 0.160.340.320.400.41 0.53 Bat 0.400.540.520.60 0.60 0.63 Cat 0.160.270.290.390.37 0.41 Dog 0.430.540.520.610.60 0.62 Lynx0.500.570.540.59 0.5 0.59 I use the following commands to generate my heatmap: heat - read.table('temp.txt') x - as.matrix(heat) heatmap.2(x, keysize=1.2, dendrogram=none, trace=none, Colv = FALSE, main = Silly Data, labCol= NULL, margin=c(7,8)) This generates a very nice heatmap, but there is one thing I have an issue with: How do I get rid of the 'X' that seems to come automatically before my numeric column values? I just want those columns to be labeled 1905, 1910, 1950, and so on. I cannot find anything in the heatmap.2 documentation that suggests how I should do this. Thank you very much for your time, and patience in reading this! Sincerely, Suzanne [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read
Re: [R] help with heatmap - how to remove annoying X before numeric values?
Try this. It makes a copy of heatmap.2 whose scope is changed to first look within heatmap.3 for functions like mtext. We redefine mtext to intercept the text argument and change it appropriately. Then we call our copy of heatmap.2. With this there is no need to change the source of heatmap.2. heatmap.3 - function(...) { environment(heatmap.2) - environment() mtext - function(text, ...) { if (text == Value) text - Silly Value graphics::mtext(text, ...) } heatmap.2(...) } heatmap.3(as.matrix(heat), keysize=1.2, dendrogram=none, trace=none, Colv = FALSE, main = Silly Data, labCol= NULL, margin=c(7,8)) On 7/19/07, Suzanne Matthews [EMAIL PROTECTED] wrote: Sorry, I just realized I didn't send this to the list! (See below) Thanks for all the help! All is working fine now. If anyone knows of a more straightforward way to change the Value string for the Key, please let me know (just to satisfy my curiosity). I got it to work by modifying the source code (specifically, heatmap.2.R in the gplots package). However, before, I didn't make the call source(heatmap.2.R) before I called source(mysillyheatmap.R) Making the additional call to heatmap.2.R fixed everything. Thanks again for all your help! On 7/19/07, Suzanne Matthews [EMAIL PROTECTED] wrote: Thank you all for your prompt replies! The check.names=FALSE parameter fixed things entirely. One more question: Is there a straightforward way to modify the the Values string that labels the key to a user-defined value? For example, let's say I want to change Values to Silly Values. So far, what I have found that I need to do is actually go and change a static string in the source code. Is there a more direct way? Also, after I make the source code change (in gplots package, file: heatmap.2.R), how do I have R build from that? If I remember correctly, if I put the new heatmap.2.R in my directory, R is supposed to check for functions and such there before it goes and builds it from the main source code base (located at /usr/bin/R). I am a touch confused on which directory is my directory, where R will check first. I tried putting the modified heatmap.2.R file in the directory that my script is, and where I initially run R. But that didn't work! Is there anything that I should add to my R script that will force it to read from that from my directory? If not, which directory should I place this in? My OS is OS X, so I think Unix-based instructions will work. Thank you once again for your time and patience! Sincerely, Suzanne On 7/18/07, Moshe Olshansky [EMAIL PROTECTED] wrote: I was right saying that my solution was not the best possible! --- Prof Brian Ripley [EMAIL PROTECTED] wrote: read.table('temp.txt', check.names = FALSE) would be easier (and more general, since make.names can do more than prepend an 'X'). On Wed, 18 Jul 2007, Moshe Olshansky wrote: Hi Suzanne, My solution (which I am sure is not the best) would be: heat - read.table('temp.txt') heat X1905 X1910 X1950 X1992 X2011 X2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat0.40 0.54 0.52 0.60 0.60 0.63 Cat0.16 0.27 0.29 0.39 0.37 0.41 Dog0.43 0.54 0.52 0.61 0.60 0.62 Lynx 0.50 0.57 0.54 0.59 0.50 0.59 a-names(heat) b-strsplit(a,split=X) w-unlist(b) w [1] 1905 1910 1950 1992 2011 2020 z - w[seq(2,length(w),by=2)] z [1] 1905 1910 1950 1992 2011 2020 names(heat) - z heat 1905 1910 1950 1992 2011 2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat 0.40 0.54 0.52 0.60 0.60 0.63 Cat 0.16 0.27 0.29 0.39 0.37 0.41 Dog 0.43 0.54 0.52 0.61 0.60 0.62 Lynx 0.50 0.57 0.54 0.59 0.50 0.59 Regards, Moshe. --- Suzanne Matthews [EMAIL PROTECTED] wrote: Hello All, I have a simple question based on how things are labeled on my heat map; particularly, there is this annoying X that appears before the numeric value of all the labels of my columns. Let's say I have the following silly data, stored in temp.txt 19051910195019922011 2020 Gnat0.080.290.290.370.39 0.43 Snake 0.160.340.320.400.41 0.53 Bat 0.400.540.520.60 0.60 0.63 Cat 0.160.270.290.390.37 0.41 Dog 0.430.540.520.610.60 0.62 Lynx0.500.570.540.59 0.5 0.59 I use the following commands to generate my heatmap: heat -
Re: [R] Help with Dates
Try some of the following: head(subset(df, Yr %in% c(00,01,02,03))) subset(df, (Yr = '00') (Yr = '03')) # same as above subset(df, (Yr == '00') | (Yr == '01') | (Yr == '02') |(Yr == '03')) # same On 7/19/07, Alex Park [EMAIL PROTECTED] wrote: R I am taking an excel dataset and reading it into R using read.table. (actually I am dumping the data into a .txt file first and then reading data in to R). Here is snippet: head(data); Date Price Open.Int. Comm.Long Comm.Short net.comm 1 15-Jan-86 673.25175645 65910 2842537485 2 31-Jan-86 677.00167350 54060 2712026940 3 14-Feb-86 680.25157985 37955 2542512530 4 28-Feb-86 691.75162775 49760 1603033730 5 14-Mar-86 706.50163495 54120 2799526125 6 31-Mar-86 709.75164120 54715 3039024325 The dataset runs from 1986 to 2007. I want to be able to take subsets of my data based on date e.g. data between 2000 - 2005. As it stands, I can't work with the dates as they are not in correct format. I tried successfully converting the dates to just the year using: transform(data, Yr = format(as.Date(as.character(Date),format = '%d-%b-%y'), %y))) This gives the following format: Date Price Open.Int. Comm.Long Comm.Short net.comm Yr 1 15-Jan-86 673.25175645 65910 2842537485 86 2 31-Jan-86 677.00167350 54060 2712026940 86 3 14-Feb-86 680.25157985 37955 2542512530 86 4 28-Feb-86 691.75162775 49760 1603033730 86 5 14-Mar-86 706.50163495 54120 2799526125 86 6 31-Mar-86 709.75164120 54715 3039024325 86 I can subset for a single year e.g: head(subset(df, Yr ==00) But how can I subset for multiple periods e.g 00- 05? The following won't work: head(subset(df, Yr ==00 Yr==01) or head(subset(df, Yr = c(00,01,02,03) I can't help but feeling that I am missing something and there is a simpler route. I leafed through R newletter 4.1 which deals with dates and times but it seemed that strptime and POSIXct / POSIXlt are not what I need either. Can anybody help me? Regards Alex __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with heatmap - how to remove annoying X before numeric values?
read.table is doing that, not heatmap.2. Use read.table(temp.txt, header = TRUE, check.names = FALSE) On 7/18/07, Suzanne Matthews [EMAIL PROTECTED] wrote: Hello All, I have a simple question based on how things are labeled on my heat map; particularly, there is this annoying X that appears before the numeric value of all the labels of my columns. Let's say I have the following silly data, stored in temp.txt 190519101950199220112020 Gnat0.080.290.290.370.390.43 Snake 0.160.340.320.400.410.53 Bat 0.400.540.520.600.600.63 Cat 0.160.270.290.390.370.41 Dog 0.430.540.520.610.600.62 Lynx0.500.570.540.590.5 0.59 I use the following commands to generate my heatmap: heat - read.table('temp.txt') x - as.matrix(heat) heatmap.2(x, keysize=1.2, dendrogram=none, trace=none, Colv = FALSE, main = Silly Data, labCol= NULL, margin=c(7,8)) This generates a very nice heatmap, but there is one thing I have an issue with: How do I get rid of the 'X' that seems to come automatically before my numeric column values? I just want those columns to be labeled 1905, 1910, 1950, and so on. I cannot find anything in the heatmap.2 documentation that suggests how I should do this. Thank you very much for your time, and patience in reading this! Sincerely, Suzanne [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with heatmap - how to remove annoying X before numeric values?
Hi Suzanne, My solution (which I am sure is not the best) would be: heat - read.table('temp.txt') heat X1905 X1910 X1950 X1992 X2011 X2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat0.40 0.54 0.52 0.60 0.60 0.63 Cat0.16 0.27 0.29 0.39 0.37 0.41 Dog0.43 0.54 0.52 0.61 0.60 0.62 Lynx 0.50 0.57 0.54 0.59 0.50 0.59 a-names(heat) b-strsplit(a,split=X) w-unlist(b) w [1] 1905 1910 1950 1992 2011 2020 z - w[seq(2,length(w),by=2)] z [1] 1905 1910 1950 1992 2011 2020 names(heat) - z heat 1905 1910 1950 1992 2011 2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat 0.40 0.54 0.52 0.60 0.60 0.63 Cat 0.16 0.27 0.29 0.39 0.37 0.41 Dog 0.43 0.54 0.52 0.61 0.60 0.62 Lynx 0.50 0.57 0.54 0.59 0.50 0.59 Regards, Moshe. --- Suzanne Matthews [EMAIL PROTECTED] wrote: Hello All, I have a simple question based on how things are labeled on my heat map; particularly, there is this annoying X that appears before the numeric value of all the labels of my columns. Let's say I have the following silly data, stored in temp.txt 190519101950199220112020 Gnat0.080.290.290.370.390.43 Snake 0.160.340.320.400.410.53 Bat 0.400.540.520.600.600.63 Cat 0.160.270.290.390.370.41 Dog 0.430.540.520.610.600.62 Lynx0.500.570.540.590.5 0.59 I use the following commands to generate my heatmap: heat - read.table('temp.txt') x - as.matrix(heat) heatmap.2(x, keysize=1.2, dendrogram=none, trace=none, Colv = FALSE, main = Silly Data, labCol= NULL, margin=c(7,8)) This generates a very nice heatmap, but there is one thing I have an issue with: How do I get rid of the 'X' that seems to come automatically before my numeric column values? I just want those columns to be labeled 1905, 1910, 1950, and so on. I cannot find anything in the heatmap.2 documentation that suggests how I should do this. Thank you very much for your time, and patience in reading this! Sincerely, Suzanne [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with heatmap - how to remove annoying X before numeric values?
read.table('temp.txt', check.names = FALSE) would be easier (and more general, since make.names can do more than prepend an 'X'). On Wed, 18 Jul 2007, Moshe Olshansky wrote: Hi Suzanne, My solution (which I am sure is not the best) would be: heat - read.table('temp.txt') heat X1905 X1910 X1950 X1992 X2011 X2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat0.40 0.54 0.52 0.60 0.60 0.63 Cat0.16 0.27 0.29 0.39 0.37 0.41 Dog0.43 0.54 0.52 0.61 0.60 0.62 Lynx 0.50 0.57 0.54 0.59 0.50 0.59 a-names(heat) b-strsplit(a,split=X) w-unlist(b) w [1] 1905 1910 1950 1992 2011 2020 z - w[seq(2,length(w),by=2)] z [1] 1905 1910 1950 1992 2011 2020 names(heat) - z heat 1905 1910 1950 1992 2011 2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat 0.40 0.54 0.52 0.60 0.60 0.63 Cat 0.16 0.27 0.29 0.39 0.37 0.41 Dog 0.43 0.54 0.52 0.61 0.60 0.62 Lynx 0.50 0.57 0.54 0.59 0.50 0.59 Regards, Moshe. --- Suzanne Matthews [EMAIL PROTECTED] wrote: Hello All, I have a simple question based on how things are labeled on my heat map; particularly, there is this annoying X that appears before the numeric value of all the labels of my columns. Let's say I have the following silly data, stored in temp.txt 190519101950199220112020 Gnat0.080.290.290.370.390.43 Snake 0.160.340.320.400.410.53 Bat 0.400.540.520.600.600.63 Cat 0.160.270.290.390.370.41 Dog 0.430.540.520.610.600.62 Lynx0.500.570.540.590.5 0.59 I use the following commands to generate my heatmap: heat - read.table('temp.txt') x - as.matrix(heat) heatmap.2(x, keysize=1.2, dendrogram=none, trace=none, Colv = FALSE, main = Silly Data, labCol= NULL, margin=c(7,8)) This generates a very nice heatmap, but there is one thing I have an issue with: How do I get rid of the 'X' that seems to come automatically before my numeric column values? I just want those columns to be labeled 1905, 1910, 1950, and so on. I cannot find anything in the heatmap.2 documentation that suggests how I should do this. Thank you very much for your time, and patience in reading this! Sincerely, Suzanne [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with heatmap - how to remove annoying X before numeric values?
I was right saying that my solution was not the best possible! --- Prof Brian Ripley [EMAIL PROTECTED] wrote: read.table('temp.txt', check.names = FALSE) would be easier (and more general, since make.names can do more than prepend an 'X'). On Wed, 18 Jul 2007, Moshe Olshansky wrote: Hi Suzanne, My solution (which I am sure is not the best) would be: heat - read.table('temp.txt') heat X1905 X1910 X1950 X1992 X2011 X2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat0.40 0.54 0.52 0.60 0.60 0.63 Cat0.16 0.27 0.29 0.39 0.37 0.41 Dog0.43 0.54 0.52 0.61 0.60 0.62 Lynx 0.50 0.57 0.54 0.59 0.50 0.59 a-names(heat) b-strsplit(a,split=X) w-unlist(b) w [1] 1905 1910 1950 1992 2011 2020 z - w[seq(2,length(w),by=2)] z [1] 1905 1910 1950 1992 2011 2020 names(heat) - z heat 1905 1910 1950 1992 2011 2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat 0.40 0.54 0.52 0.60 0.60 0.63 Cat 0.16 0.27 0.29 0.39 0.37 0.41 Dog 0.43 0.54 0.52 0.61 0.60 0.62 Lynx 0.50 0.57 0.54 0.59 0.50 0.59 Regards, Moshe. --- Suzanne Matthews [EMAIL PROTECTED] wrote: Hello All, I have a simple question based on how things are labeled on my heat map; particularly, there is this annoying X that appears before the numeric value of all the labels of my columns. Let's say I have the following silly data, stored in temp.txt 19051910195019922011 2020 Gnat0.080.290.290.370.39 0.43 Snake 0.160.340.320.400.41 0.53 Bat 0.400.540.520.600.60 0.63 Cat 0.160.270.290.390.37 0.41 Dog 0.430.540.520.610.60 0.62 Lynx0.500.570.540.590.5 0.59 I use the following commands to generate my heatmap: heat - read.table('temp.txt') x - as.matrix(heat) heatmap.2(x, keysize=1.2, dendrogram=none, trace=none, Colv = FALSE, main = Silly Data, labCol= NULL, margin=c(7,8)) This generates a very nice heatmap, but there is one thing I have an issue with: How do I get rid of the 'X' that seems to come automatically before my numeric column values? I just want those columns to be labeled 1905, 1910, 1950, and so on. I cannot find anything in the heatmap.2 documentation that suggests how I should do this. Thank you very much for your time, and patience in reading this! Sincerely, Suzanne [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] HELP FOR BUGS
You might find the 'arm' package useful. For a good introduction to heirarchical modeling, using 'arm' and also WinBUGS and R2WinBUGS, read Gelman, A; J Hill 2007. Data analysis using regression and multilevel/hierarchical models. Cambridge University Press. Cheers, Mike. Ali raza-4 wrote: Hi Sir I am very new user of R for the research project on multilevel logistic regression. There is confusion about bugs() function in R and BUGS software. Is there any relation between these two? Is there any comprehensive package for Multilevel Logistic modelling in R? Please guide in this regard. Thank You RAZA - Boardwalk for $500? In 2007? Ha! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/HELP-FOR-BUGS-tf4078749.html#a11605645 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] HELP FOR BUGS
Ali raza wrote: Hi Sir I am very new user of R for the research project on multilevel logistic regression. There is confusion about bugs() function in R Do you mean bugs() from package R2WinBUGS? Yes, it is related to the software WinBUGS 1.4.x (and OpenBUGS 2.x with package BRugs). Uwe Ligges and BUGS software. Is there any relation between these two? Is there any comprehensive package for Multilevel Logistic modelling in R? Please guide in this regard. Thank You RAZA - Boardwalk for $500? In 2007? Ha! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with handling replicates before reshaping data
Hi Tom, I have a dataset consists of duplicated sequences within day for each patient (see below data) and I want to reshape the data with patient as time variable. However the reshape function only takes the first sequence of the replicates and ignores the second. How can I 1) average the duplicates and 2) give the duplicated sequences unique names before reshaping the data ? data patient day seq y 1 10 1 acdf -0.52416066 2 10 1 cdsv 0.62551539 3 10 1 dlfg -1.54668047 4 10 1 acdf 0.82404978 5 10 1 cdsv -1.17459914 6 10 2 acdf 0.47238216 You mind find that the functions in the reshape package give you a bit more flexibility. # The reshape package expects data like to have # the value variable named value d2 - rename(data, c(y = value)) # I think this is the format you want, which will average over the reps cast(d2, day + seq ~ patient, mean) Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help Needed!!
See ?summary.manova -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 10/07/07, deepa gupta [EMAIL PROTECTED] wrote: Hi, Can anyone help me with repeated meausres MANOVA in R ? For repeated measures ANOVA I used function aov. Is there something like this exists for MANOVA? Thanks, Deepa - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with write.foreign (exporting data to Stata)
I am not sure what you are doing there but what you need is library(foreign) and write.dta() see ?write.dta once you have loaded the foreign package Stefan Original Message Subject: [R] Help with write.foreign (exporting data to Stata) From: kdestler [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date: Tue Jul 10 2007 19:37:54 GMT+0200 Hi. I'm trying to export a dataframe from R into Stata to use a statistical function I have there. I attached library write.foreign and renamed my variables to get them to match Stata's required format, and now have the following error: file /tmp/Rtmps7rmrM/file1c06dac8.raw not found Other than typing write.foreign, do I need to do something in R to get it to save the file on my hard drive? When I search for the file name on my computer nothing comes up. I'm using a Mac in case that makes a difference. Thanks, Kate __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with write.foreign (exporting data to Stata)
On Tue, 10 Jul 2007, Stefan Grosse wrote: I am not sure what you are doing there but what you need is library(foreign) and write.dta() write.foreign should also work, though. My guess is that Kate used tempfile() to specify the filenames, and that the data file would then have been deleted on leaving R. This is only a guess, of course. The syntax for write.dta is write.dta(the.data.set, file=dataset.dta) and for write.foreign is write.foreign(the.data.set,codefile=dataset.do, datafile=dataset.raw, package=Stata) -thomas see ?write.dta once you have loaded the foreign package Stefan Original Message Subject: [R] Help with write.foreign (exporting data to Stata) From: kdestler [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date: Tue Jul 10 2007 19:37:54 GMT+0200 Hi. I'm trying to export a dataframe from R into Stata to use a statistical function I have there. I attached library write.foreign and renamed my variables to get them to match Stata's required format, and now have the following error: file /tmp/Rtmps7rmrM/file1c06dac8.raw not found Other than typing write.foreign, do I need to do something in R to get it to save the file on my hard drive? When I search for the file name on my computer nothing comes up. I'm using a Mac in case that makes a difference. Thanks, Kate __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help on fisher.test(stats)?
Original Message Subject: [R] help on fisher.test(stats)? From: zhijie zhang [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Date: 09.07.2007 09:03 Dear friends, My dataset have many zeros, so i must use fisher exact test . Unfortunately, the fisher.test(stats) function fail to do it. Anybody knows how to do the fisher exact test with many zeros in the dataset? My dataset is: a-matrix(c(0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,1,1,0,2,1,5,1,1,6,4,4,1,17,2,8,5,7,1,1,24,3,6,1,1,3,2,16,7,4,0,2,4,0,17,0,1,0,0,0,1,2),nrow=8,byrow=TRUE) data.frame(a) b-a[,-7] as.matrix(b) c-as.matrix(b) c [,1] [,2] [,3] [,4] [,5] [,6] [1,]010000 [2,]010000 [3,]011021 [4,]116441 [5,]285711 [6,]361132 [7,]740240 [8,]010001 fisher.test(c,workspace=20) ŽíÎóÓÚfisher.test(c, workspace = 2e+17) : ÍâœÓº¯Êýµ÷ÓÃʱ²»ÄÜÓÐNA(arg10) ŽËÍâ: Warning message: Ç¿Öƞıä¹ý³ÌÖвúÉúÁËNA Any suggestion or help are greatly appreciated. Your workspace is by far to large. I have done it with fisher.test(c,workspace=4000) Fisher's Exact Test for Count Data data: c p-value = 0.01548 alternative hypothesis: two.sided (btw. it took half an hour...) Simulation would also be an alternative approach: fisher.test(c,simulate=T) Fisher's Exact Test for Count Data with simulated p-value (based on 2000 replicates) data: c p-value = 0.01349 alternative hypothesis: two.sided As you see the p-value is not that different, you could use more replications: fisher.test(c,simulate=T,B=100) Fisher's Exact Test for Count Data with simulated p-value (based on 1e+06 replicates) data: c p-value = 0.01514 alternative hypothesis: two.sided and it is still much faster... Stefan -=-=- ... The most incomprehensible thing about the world is that it is comprehensible. (A. Einstein) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help in installing rggobi in ubuntu linux
Looks like rggobi can't find GGobi. Make sure that PKG_CONFIG_PATH contains the path to your ggobi.pc file. For example: export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig I would have assumed, however, that the ggobi package would have installed to the /usr prefix, in which case pkg-config should have no problem finding GGobi. On 7/8/07, Kenneth Cabrera [EMAIL PROTECTED] wrote: Hi R users. I am experimenting with ubuntu 7.04 Feisty. I install the ggobi package with apt-get. I got almost all the packages, but when I try to obtain rggobi, I got this message: - install.packages(rggobi) Aviso en install.packages(rggobi) : argument 'lib' is missing: using '/usr/local/lib/R/site-library' --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done probando la URL 'http://cran.at.r-project.org/src/contrib/rggobi_2.1.4-4.tar.gz' Content type 'application/x-gzip' length 401451 bytes URL abierta == downloaded 392Kb * Installing *source* package 'rggobi' ... checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for GGOBI... configure: creating ./config.status config.status: creating src/Makevars ** libs gcc -std=gnu99 -I/usr/share/R/include -I/usr/share/R/include -g -DUSE_EXT_PTR=1 -D_R_=1 -fpic -g -O2 -c brush.c -o brush.o En el fichero incluÃdo de brush.c:1: RSGGobi.h:5:22: error: GGobiAPI.h: No existe el fichero ó directorio In file included from RSGGobi.h:6, from brush.c:1: conversion.h:174: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âasCLogicalâ conversion.h:176: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âasCRawâ --- snip --- brush.c:124: error: âtâ no se declaró aquà (primer uso en esta función) brush.c:124: error: âsâ no se declaró aquà (primer uso en esta función) brush.c:124: error: el objeto âGGOBI(erroneous-expression)â llamado no es una función brush.c: En el nivel principal: brush.c:135: error: expected â)â before âcidâ make: *** [brush.o] Error 1 chmod: no se puede acceder a `/usr/local/lib/R/site-library/rggobi/libs/*': No existe el fichero ó directorio ERROR: compilation failed for package 'rggobi' ** Removing '/usr/local/lib/R/site-library/rggobi' The downloaded packages are in /tmp/RtmpVCacJd/downloaded_packages Warning message: installation of package 'rggobi' had non-zero exit status in: install.packages(rggobi) --- What am I doing wrong? Thank you for your help. -- Kenneth Roy Cabrera Torres Cel 315 504 9339 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help in installing rggobi in ubuntu linux
On 9 July 2007 at 22:38, Michael Lawrence wrote: | Looks like rggobi can't find GGobi. Make sure that PKG_CONFIG_PATH contains | the path to your ggobi.pc file. For example: | | export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig | | I would have assumed, however, that the ggobi package would have installed | to the /usr prefix, in which case pkg-config should have no problem finding | GGobi. | | On 7/8/07, Kenneth Cabrera [EMAIL PROTECTED] wrote: | | Hi R users. | | I am experimenting with ubuntu 7.04 Feisty. | | I install the ggobi package with apt-get. | | I got almost all the packages, but | when I try to obtain rggobi, I got | this message: Why don;t you install the Rggobi that is provided via Ubuntu? It is version 2.1.4-4-1 and it corresponds to the 2.1.4-2 version of Ggobi you just installed. Just do 'sudo apt-get install r-omegahat-ggobi' On Debian, we are now at 2.1.5-* for both (and we renamed it r-cran-rggobi as it now resides on CRAN). Hth, Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with vector construction
Hi, Example: n - 1:10 mat[2+3*n,3] #Where mat is the matrix Is what you want? -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 05/07/07, Juan Pablo Fededa [EMAIL PROTECTED] wrote: Hi all, I want to make a vector with the third column of a matrix, but only for the 2+3n rows of the matrix, with n being an entire number from 0 to a million. How can I do that in an easy way? Thanks in advance, Juan Pablo [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with vector construction
Or an alternative to Henrique's if you want to select all the rows from row 2 up to the 3*n row this may work. n - 2 myvector - data1[2:(2*n), 3] --- Juan Pablo Fededa [EMAIL PROTECTED] wrote: Hi all, I want to make a vector with the third column of a matrix, but only for the 2+3n rows of the matrix, with n being an entire number from 0 to a million. How can I do that in an easy way? Thanks in advance, Juan Pablo [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with vector construction
One approach is to use the fact that vectors are automatically replicated to the correct length when subscripting, so you can do something like: my.matrix[ c(FALSE,TRUE,FALSE), 3 ] To get every 3rd element starting at the 2nd element, and the 3rd column. 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 Juan Pablo Fededa Sent: Thursday, July 05, 2007 11:30 AM To: r-help@stat.math.ethz.ch Subject: [R] help with vector construction Hi all, I want to make a vector with the third column of a matrix, but only for the 2+3n rows of the matrix, with n being an entire number from 0 to a million. How can I do that in an easy way? Thanks in advance, Juan Pablo [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help again
On Jul 2, 2007, at 6:22 PM, umarporn charusombat wrote: hi i try to use arima and holtwinter to predict drought from 1895-2006 unless you have access to time-travel isn't this better called retrodiction? ingmar but i cannot read whole period of time and i try to do the exponent fitting, but it comes out as the coordinate x-y error i send the source code and data to take a look if anyone can help me, i am really new in R thank u so much jam __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help again
hi i try to use arima and holtwinter to predict drought from 1895-2006 but i cannot read whole period of time and i try to do the exponent fitting, but it comes out as the coordinate x-y error i send the source code and data to take a look if anyone can help me, i am really new in R PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This makes it much easier to help! (how do your numbers look like e.g.) You don't need to send the whole dataset but a few lines would be nice plus what commands you've done to receive those errors... Stefan -=-=- ... Lotteries are a tax on ignorance. (A. Smith - attributed) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help again
Stefan Grosse wrote: This makes it much easier to help! (how do your numbers look like e.g.) You don't need to send the whole dataset but a few lines would be nice plus what commands you've done to receive those errors... In fact, I noticed that, most of the time, when I reduce the problematic code to a minimum code that reproduces the bug, it's much easier _for me_ to spot (and fix) the error :-) Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help on the use of ldBand
Tomas Goicoa wrote: Hi R Users, I am trying to use the ldBand package. Together with the package, I have downloaded the ld98 program (version for windows) as indicated in the help page on ldBand. I did it, but obtained an error message Error in (head + 1):length(w) : Argument NA/NaN when I copied the help examples, so it seems that a conection between R and ld98 is not well performed in my computer. Did I put ld98.exe in the wrong place? If so, where should I put it? Thanks a lot in advance, Berta Ibañez Beroiz Do you mean the Hmisc package? Do you mean the ldBands function? Did you put ld98.exe in a place that is in your system path as specified in the ldBands help file? And please read the posting guide referenced below. Frank __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help in ARIMA
Sounds more like you would want to explore the use of some sort of Queueing model. A quick search of R help did not yield any packages that could be used to develop such models, but I think that modeling simple queuing systems and estimating wait times is pretty straight forward and could be programmed in R. Hopefully someone out there will have more/better advice. Good luck, Spencer On 6/19/07, Roshan Sumbaly [EMAIL PROTECTED] wrote: I am working on a data set which has the waiting times taken of jobs running on a cluster. I need to come up with a method to use this historical data to come up with a prediction for the future. Even probably try simulating the full history (as in I have history of the job submission time and running time,etc). So I can run through the actual history and at every job submission, depending on the status of the cluster, try to predict the waiting time. Can I do this using any of the models used in R? Particularly forecast...Can I used ARIMA or ARMA for this? ...The problem is I don't think I'm dealing with time series because the measurements of waiting times (at a particular state i.e. job submission) ain't done at regular intervals. Could anyone please suggest a model for this? Thanking you, RS [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help w/ nonlinear regression
Your B coefficient differs by a suspicious-looking factor of 2.30... (ln(10). Does SPSS log() mean log10 or ln? R log(x) uses ln(x). S Eduardo Esteves [EMAIL PROTECTED] 19/06/2007 17:19:35 Dear All, I'd like to fit a kind of logistic model to small data-set using nonlinear least-squares regression. A transcript of R-script are reproduced below. Estimated B and T (the model's coeff, herein B=-8,50 and T=5,46) seem appropriate (at least visually) but are quite diff from those obtained w/ SPSS (Levenberg-Marquardt): B=-19,56 and T=2,37. Am I doing something wrong in R (or at least non-comparable methodologies)? Please, feel free to comment/suggest. Regards, Eduardo Esteves # Dados CO2-c(141,172,181,227,309,414,641,936) Prop-c(0.25,0.34,0.34,0.68,0.85,0.99,0.98,0.99) # Diagrama dispersão plot(Prop~CO2, las=1, xlim=c(0,1000),ylim=c(0,1),pch=16,cex=1.5, xlab=CO2 (ppm), ylab=Proporção de respostas correctas) # Estimaçao (Método Mínimos Quadrados) ajuste-nls(Prop~(1/3+exp(B*(T-log(CO2/(1+exp(B*(T-log(CO2, data=data.frame(CO2=CO2,Prop=Prop),start=list(B=-10,T=5)) summary(ajuste) # Ilustracao do ajuste PropEsp-predict(ajuste,newdata=list(CO2=seq(0,1000,length=100)),se.fit=T) lines(PropEsp~seq(0,1000,length=100),lwd=2,col=6) # IC upIC-PropEsp+qt(.975,summary(ajuste)$df[2])*summary(ajuste)$sigma loIC-PropEsp-qt(.975,summary(ajuste)$df[2])*summary(ajuste)$sigma lines(upIC~seq(0,1000,length=100),col=4) lines(loIC~seq(0,1000,length=100),col=4) [[alternative HTML version deleted]] *** This email and any attachments are confidential. Any use, co...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with using grid to modify ggplot/lattice plots
Hi Vikas Rawal wrote: I want to use grid to modify some boxplots made using ggplot. I would really appreciate if somebody could guide me to a resource on how to use grid to modify such graphics. I guess the basic approach will be similar to using grid to modify lattice graphics. To that extent something that explains use of grid to modify lattice graphics may also be useful. I have gone through vignettes in the grid package but am somehow not able to understand the overall approach. It would be useful if there is something more specific that deals with using grid to modify such graphics. A couple of suggestions: - look at Hadley Wickham's online book draft for ggplot2 http://had.co.nz/ggplot2/ - look at the online chapter on grid from my book http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter5.pdf Paul Vikas Rawal Associate Professor Centre for Economic Studies and Planning Jawaharlal Nehru University New Delhi __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help With Sweave:
Matt, On 19 June 2007 at 21:23, M. Jankowski wrote: | Hi All, | | I am running Ubuntu Feisty (7.04) on a Thinkpad T41. I've installed | the nowebm package for Ubuntu. Working from this HowTo: | http://www.ci.tuwien.ac.at/~leisch/Sweave/example-1.Snw | I try to compile the example *.Snw as in the Sweave manual: | | [EMAIL PROTECTED]:~/Desktop/Sweave/example1$ noweb example-1.Snw | Can't open output file | | Despite the error, a *.tex file is produced. Now I am stuck because I | cannot seem to get the CTAN noweb package correctly installed for my | Latex installation. I guess I am somewhat spoiled by the Synaptic | package manager. Here is the result of my best attempt to get the | noweb package installed: i) No external noweb package is needed ii) Synaptic is not used to install CRAN / CTAN packages iii) Everything should be provided by r-base-core and tetex-extra. Since relatively recently, a 'Sweave' command has been added. So simply do $ R CMD Sweave example-1.Snw $ pdflatex example-1.tex $ kpdf example-1.pdf# or xpdf, or gv, or ... | A bunch of errors. What am I doing wrong? Any help is much | appreciated! You simply make your life too complicated when Debian and Ubuntu make it easier for you :) | Of course, if there is a better place for me to ask this question | please let me know where! Thanks! The r-sig-debian list is appropriate for problems with Debian / Ubuntu. Dirk PS I usually use simple shell wrappers like this one. Others prefer Makefile. [EMAIL PROTECTED]:~ cat /home/edd/bin/sweave #!/bin/bash -e function errorexit () { echo Error: $1 exit 1 } function filetest () { if [ ! -f $1 ]; then errorexit File $1 not found fi return 0 } if [ $# -lt 1 ]; then errorexit Need to specify argument file fi BASENAME=$(basename $1 .Rnw) RNWFILE=$BASENAME.Rnw filetest $RNWFILE echo library(tools); Sweave(\$RNWFILE\) \ | R --no-save --no-restore --slave LATEXFILE=$BASENAME.tex filetest $LATEXFILE pdflatex $LATEXFILE PDFFILE=$BASENAME.pdf #filetest $PDFFILE acroread $PDFFILE #filetest $PDFFILE xpdf $PDFFILE filetest $PDFFILE kpdf $PDFFILE -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help With Sweave:
Dirk, Your solution worked wonders! This is outstanding! Thank you! Matt On 6/19/07, Dirk Eddelbuettel [EMAIL PROTECTED] wrote: Matt, On 19 June 2007 at 21:23, M. Jankowski wrote: | Hi All, | | I am running Ubuntu Feisty (7.04) on a Thinkpad T41. I've installed | the nowebm package for Ubuntu. Working from this HowTo: | http://www.ci.tuwien.ac.at/~leisch/Sweave/example-1.Snw | I try to compile the example *.Snw as in the Sweave manual: | | [EMAIL PROTECTED]:~/Desktop/Sweave/example1$ noweb example-1.Snw | Can't open output file | | Despite the error, a *.tex file is produced. Now I am stuck because I | cannot seem to get the CTAN noweb package correctly installed for my | Latex installation. I guess I am somewhat spoiled by the Synaptic | package manager. Here is the result of my best attempt to get the | noweb package installed: i) No external noweb package is needed ii) Synaptic is not used to install CRAN / CTAN packages iii) Everything should be provided by r-base-core and tetex-extra. Since relatively recently, a 'Sweave' command has been added. So simply do $ R CMD Sweave example-1.Snw $ pdflatex example-1.tex $ kpdf example-1.pdf# or xpdf, or gv, or ... | A bunch of errors. What am I doing wrong? Any help is much | appreciated! You simply make your life too complicated when Debian and Ubuntu make it easier for you :) | Of course, if there is a better place for me to ask this question | please let me know where! Thanks! The r-sig-debian list is appropriate for problems with Debian / Ubuntu. Dirk PS I usually use simple shell wrappers like this one. Others prefer Makefile. [EMAIL PROTECTED]:~ cat /home/edd/bin/sweave #!/bin/bash -e function errorexit () { echo Error: $1 exit 1 } function filetest () { if [ ! -f $1 ]; then errorexit File $1 not found fi return 0 } if [ $# -lt 1 ]; then errorexit Need to specify argument file fi BASENAME=$(basename $1 .Rnw) RNWFILE=$BASENAME.Rnw filetest $RNWFILE echo library(tools); Sweave(\$RNWFILE\) \ | R --no-save --no-restore --slave LATEXFILE=$BASENAME.tex filetest $LATEXFILE pdflatex $LATEXFILE PDFFILE=$BASENAME.pdf #filetest $PDFFILE acroread $PDFFILE #filetest $PDFFILE xpdf $PDFFILE filetest $PDFFILE kpdf $PDFFILE -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help in ARIMA
Hi Roshan see inline for answer waiting time. Can I do this using any of the models used in R? /* i feel this sounds more or less like a queueing model. Try searching M/M/1 queueing model on internet. Further, i feel look at poission distribution may also be helpful. It was Long Long time back, more than a decade, when i used GPSS software as i cannot see anything susbstantial in help.search(queue)/help.search(queueingmodel)to model queues. i would be of little help in remembering all those, but i would exten help to whaever extent i can. */ Particularly forecast...Can I used ARIMA or ARMA for this? ...The problem /*** i doubt but may regularizing the series by either transformations and then imputing it may turn irregular series into a time series. but the possibilities are bleak. **/ Particularly forecast...Can I used ARIMA or ARMA for this? ...The problem is I don't think I'm dealing with time series because the measurements of waiting times (at a particular state i.e. job submission) ain't done at regular intervals. Could anyone please suggest a model for this? Thanking you, RS [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help: Upgrading to R2.5 on Ubuntu (Feisty)
Dear Matt, Did you issue: $ sudo apt-get update before running: $ sudo apt-get install r-base Now, let me tell you one thing about Linux and particularly Debian/Ubuntu. We are spoiled to the point that we love the official repositories. Because the official packages go through some testing, we tend to sacrifice a little bit of cutting edge for stability/reliability. If you don't think you need anything specific from version 2.5.0, I would recommend you to stick with the current version, 2.4.1. You'll also have several packages already compiled for you if you do that. I hope it helps. Paulo On 6/18/07, M. Jankowski [EMAIL PROTECTED] wrote: Thank you in advance for reading this help request. I am pretty new to R. I am experiencing some issues getting 2.5 installed on my Ubuntu Fiesty system and seek your advice. To the best of my ability I followed the instructions here: http://cran.r-project.org/bin/linux/ubuntu/README Setting this as the last line in my sources.list: deb http://cran.fhcrc.org/bin/linux/ubuntu feisty/ When I typed in: [EMAIL PROTECTED]:/usr/local/lib/R/site-library$ sudo apt-get install r-base Reading package lists... Done Building dependency tree Reading state information... Done r-base is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. [EMAIL PROTECTED]:/usr/local/lib/R/site-library$ But when I go to R and check my version: version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 4.1 year 2006 month 12 day18 svn rev40228 language R version.string R version 2.4.1 (2006-12-18) My version is still 2.4.1. I must be missing something. What do I need to do to get R version 2.5 installed on my ubuntu feisty (7.04) system? Let me know if there is any additional information I need to give to be helped out with this. Thank you for taking a look at this, Sincerely, Matt __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with simple R-question
--- Rina Miehs [EMAIL PROTECTED] wrote: hello what do i write for R to recognize both columns? In the R-script downunder you can see that i use tapply to get my information out of my data, and then i need to use it as a dataframe with both columns! It is like R is using the first column as an observationnumber or something, how can i change that?? It is using the names of the variables as rownames. try n.ant - names(antall) antal1 - data.frame(n.antal1, antal1) antal1 -tapply(l1$omlob1,l1$farid,length) antal1 1437987 1100 10007995 10008295 10008792 10010203 10018703 10033401 2 3 3 2 3 1 1 2 10048900 10050492 10055897 10076495 10081892 10094801 10100692 10101395 3 1 3 3 6 2 5 20 10101495 10101595 10104692 10113592 10113697 10114297 10120797 10120897 1 5 4 2 6 11 1 4 10121697 10121897 10121997 10133592 10142892 10142995 10146495 10150497 16 3 6 1 1 6 4 4 10150692 10157092 10157292 10164792 10170892 10171795 10171895 10172300 5 2 4 4 4 4 4 1 10175195 10187802 10192499 10192897 10198295 10200493 10201693 10211593 1 2 2 3 5 1 3 5 antal1 - data.frame(antal1) antal1 antal1 14379872 1100 3 10007995 3 10008295 2 10008792 3 10010203 NA 10018703 NA 10033401 2 10048900 3 10050492 1 10055897 3 10076495 3 10081892 6 10094801 2 10100692 5 Thanks Rina [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with conditional lagging of data
Seems you want to diff X, not lag it. We can either maintain the long form of the data and do it as in #1 or convert the data to wide form and do it as in #2 which is most convenient using zoo where we make the individual time series into zoo series, merge them and then apply diff: Lines - ID Year X AB12 2000100 AB12 2001120 AB12 2002140 AB12 200380 BL14 2000180 BL14 2001150 CR93 200045 CR93 200149 CR93 200256 CR93 200367 DF - read.table(textConnection(Lines), header = TRUE) # 1 f - function(DF) cbind(DF[,1:2], diff = c(NA, diff(DF$X))) DF.by - by(DF, DF$ID, f) do.call(rbind, DF.by) # 2 library(zoo) fz - function(DF) zoo(DF$X, DF$Year) diff(do.call(merge, by(DF, DF$ID, fz)), na.pad = TRUE) For more info on zoo: library(zoo) vignette(zoo) On 6/4/07, Anup Nandialath [EMAIL PROTECTED] wrote: Dear Friends, I have some data with three columns named ID, Year and Measure X. I need to create a column which gives me a lag for each ID (note not a continous lag), but a lag conditional on the id and the given year. Please find below a sample of the data Input file sample ID Year X AB12 2000100 AB12 2001120 AB12 2002140 AB12 200380 BL14 2000180 BL14 2001150 CR93 200045 CR93 200149 CR93 200256 CR93 200367 Expected output from this data ID Year Xlag AB12 2000 . AB12 2001 20 AB12 2002 20 AB12 2003 -60 BL12 2000. BL14 2001 -30 CR93 2000 . CR93 2001 5 CR93 2002 7 CR93 2003 9 Can somebody please help me with how to implement this in R. Thanks. Sincerely Anup - Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with optim
Hi, Unfortunately I don't think it is possible to do exactly what you want, but: If the numbers reported by 'optim' to the console are enough for you, then consider using 'capture.output'. Below I used the example from 'optim' help page, because I could not use yours directly. hth, Michal # -b-e-g-i-n---R---c-o-d-e- # this is from the 'optim' example fr - function(x) { ## Rosenbrock Banana function x1 - x[1] x2 - x[2] 100 * (x2 - x1 * x1)^2 + (1 - x1)^2 } # and now optim-ize capturing the output to 'out' and the results to 'o' out - capture.output( o - optim( c(-1.2, 1), fr, method=BFGS, control=c(REPORT=1, trace=1)) ) # 'out' is a character vector storing every line as a separate element out # 'o' is returned by optim o # to get a grip on the values you could use for example 'strsplit' and then # extract neccessary info optimout - function(out) { # split by spaces l - strsplit(out, ) # just return the numbers rval - sapply(l[-length(l)], function(x) x[length(x)] ) as.numeric(rval) } x - optimout(out) x plot(x) # -e-n-d---R---c-o-d-e- -Wiadomo¶æ oryginalna- Od: [EMAIL PROTECTED] w imieniu Anup Nandialath Wys³ano: Wt 2007-05-29 08:33 Do: r-help@stat.math.ethz.ch Temat: [R] Help with optim Dear Friends, I'm using the optim command to maximize a likelihood function. My optim command is as follows estim.out - optim(beta, loglike, X=Xmain, Y=Y, hessian=T, method=BFGS, control=c(fnscale=-1, trace=1, REPORT=1)) Setting the report=1, gives me the likelihood function value (if i'm correct) at each step. The output from running this is as follows initial value 3501.558347 iter 2 value 3247.277071 iter 3 value 3180.679307 iter 4 value 3157.201356 iter 5 value 3156.579887 iter 6 value 3017.715292 iter 7 value 2993.349538 iter 8 value 2987.181782 iter 9 value 2986.672719 iter 10 value 2986.658620 iter 11 value 2986.658266 iter 12 value 2986.658219 iter 13 value 2986.658156 iter 13 value 2986.658156 iter 13 value 2986.658135 final value 2986.658135 converged I just wanted to know if there was any way I could get the value of each iteration into an object. At present it is dumped on the screen. But is there a way to get hold of these values through an object?? Thanks in advance sincerely Anup - The fish are biting. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help about 2 way anova and tukey test
The form of your data is termed wide and you want to reshape it to long form and use aov with that. This uses the reshape command to produce the long form. Alternately you could use cast and melt in the reshape package to do that: # read data Lines - subjtherapy t0 t1 t2 1 a 80.582.254.23 2 a 84.985.656.83 3 a 81.581.454.30 1 b 83.895.259.67 2 b 83.394.359.20 3 b 86 91.559.17 1 c 80.780.253.63 2 c 89.480.156.50 3 c 91.886.459.40 DF - read.table(textConnection(Lines), header = TRUE) # reshape to long form nm - names(DF)[3:5] long - reshape(DF, dir = long, varying = list(nm), times = nm, v.names = value) long$time - factor(long$time) # calculate aov(value ~ therapy * time, data = long) # ...etc On 5/24/07, Sarti Maurizio [EMAIL PROTECTED] wrote: Dears members of R list, I have a technical question about conducting 2 way analysis of the variance (ANOVA) for repeated measures followed tukey test using R. my data are: There were 3 subj in all and 3 repeated measures for every time and therapy therapy = a,b,c time= t1,t2,t3 subj= 1,2,3 subjtherapy t0 t1 t2 1 a 80.582.254.23 2 a 84.985.656.83 3 a 81.581.454.30 1 b 83.895.259.67 2 b 83.394.359.20 3 b 86 91.559.17 1 c 80.780.253.63 2 c 89.480.156.50 3 c 91.886.459.40 the code that I use is: rm(list=ls(all=TRUE)) dati- read.table(dati.txt, T) attach(dati) subj- c( 1: 9, 1: 9,1:9) therapy- factor( c( rep( a, 3), rep( b, 3), rep( c, 3), rep( a, 3), rep( b, 3), rep( c, 3), rep( a,3), rep( b, 3), rep( c, 3))) time- factor( c( rep( t0, 9), rep( t1, 9),rep( t2, 9))) weight- c( t0,t1,t2) time - factor( time) therapy - factor( therapy) subj - factor( subj) summary( fm1-aov( weight~time*therapy)) fm1Tukey=TukeyHSD(fm1,therapy,ordered = TRUE) ; fm1Tukey fm1Tukey=TukeyHSD(fm1,time,ordered = TRUE) ; fm1Tukey fm1Tukey=TukeyHSD(fm1,time:therapy,ordered = TRUE) ; fm1Tukey My question is - is that the correct way to do it?? Very much obliged for your kind response Maurizio ** Maurizio Sarti, PhD IREA - CNR via Diocleziano,328 I-80124 Napoli (Italy) tel:+39-(0)81-5707999-(0)81-5704945 fax:+39-(0)81-5705734 cell:+39-3204397891 ** e-mail: [EMAIL PROTECTED] website: http://www.irea.cnr.it __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with this indexing
merge() javier garcia-pintado wrote: Hi all, Let's say I have a long data frame and a short one, both with three colums: $east, $north, $value And I need to fill in the short$value, extracting the corresponding value from long$value, for coinciding $east and $north in both tables. I know the possibility: for (i in 1:length(short$value)){ short$value[i] - long$value[long$east==short$east long$north==short$north] } How could I avoid this loop? Thanks and regards, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with executing instruction every i-th run of loop
if (i %% 1000 == 0) b On May 17, 2007, at 10:56 AM, Mark W Kimpel wrote: I am running a very long loop and would like to save intermediate results in case of a system or program crash. Here is the skeleton of what my code would be: for (i in 1:zillion) { results[[i]]-do.something.function() if (logical.test(i)) {save(results, results.tmp)} } logical.test would test to see if i/1000 has no remainder. What R function would test that? Is there an even better way to address my need? Thanks, Mark -- --- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 663-0513 Home (no voice mail please) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Benilton Carvalho PhD Candidate Department of Biostatistics Bloomberg School of Public Health Johns Hopkins University [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with executing instruction every i-th run of loop
Mark W Kimpel wrote: I am running a very long loop and would like to save intermediate results in case of a system or program crash. Here is the skeleton of what my code would be: for (i in 1:zillion) { results[[i]]-do.something.function() if (logical.test(i)) {save(results, results.tmp)} } logical.test would test to see if i/1000 has no remainder. What R function would test that? !(i %% 1000) Uwe Ligges Is there an even better way to address my need? Thanks, Mark __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with executing instruction every i-th run of loop
On 5/17/2007 10:56 AM, Mark W Kimpel wrote: I am running a very long loop and would like to save intermediate results in case of a system or program crash. Here is the skeleton of what my code would be: for (i in 1:zillion) { results[[i]]-do.something.function() if (logical.test(i)) {save(results, results.tmp)} } logical.test would test to see if i/1000 has no remainder. What R function would test that? (i %% 1000) == 0 Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with executing instruction every i-th run of loop
Mark W Kimpel wrote: I am running a very long loop and would like to save intermediate results in case of a system or program crash. Here is the skeleton of what my code would be: for (i in 1:zillion) I'm a bit worried about this line: 1:zillion Error: cannot allocate vector of size 4 zillion bytes hmm, lets try on a machine with a few more zillion bytes of RAM: 1:zillion Error: result would be too long a vector Is there an even better way to address my need? Looping over vectors like this involves the uneccesary creation of a long vector. For anything up to a million its probably okay, but once you start getting into the zillions... You can do it with less storage by just having a while loop: while (i != 100 ){print(i);i=i+1} Many modern computer languages have iterators for looping, which abstract all the looping functionality into an object. I started writing something for R a few years ago but never got round to finishing it. It let you do this: myLoop - loop(N=10,step=1,start=1) while(iterate(myLoop)){ doSomething() } The 'myLoop' object here is the iterator that controls the looping. You can use it to get the iteration number and then use the i %% 1000 test everyone else has told you about by now... Anyway, if anyone has a spare R programmer kicking around and would like all my looper code, just ask... Barry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with map
On Sat, 5 May 2007, Alberto Vieira Ferreira Monteiro wrote: [for those that worry about these things, this _is_ a homework assignment. However, it's not an R homework, it's a Geography and History homework... and I want to use R to create a pretty map] Roger Bivand wrote: Is there any way to associate one color to each country? Try: map_poly_obj - map(worldHires, c(Argentina, Brazil), plot=FALSE, fill=TRUE) str(map_poly_obj) and you'll see that the component of interest is the named polygons, of which there are 28, namely Ok, I guess I can see what you mean. It worked, but I don't think this is a practical way to draw things. For example, suppose [this would help homework mentioned above] I want to draw a series of maps showing the evolution of Communism in the XX century. I would like to start with a 1917 map, showing most countries as in... map(worldHires) ... but with the Soviet Union in red. I don't see how I could mix the two maps (BTW, there's no Russia in worldHires, but there is a USSR...) map(worldHires); map(worldHires, USSR, col=red, fill=T) [Please note that the worldHires database refers to a particular time cross section, probably late 1980's. The territorial extents of the former USSR in 1919, 1920, 1939, 1940, 1941, 1944, 1945, etc., etc. are not the same; the same consideration would apply to PRC's actual control over Tibet. So to do this, you need a sequence of maps showing the marginal increments, with 1917 actually only colouring Petrograd/St Petersburg and perhaps some other cities. I'm not aware of any publically available sequence of boundary files adequately representing the situation of say the Baltic states or Finland for the 1917-2007 period, if anyone has a suitable link, please say so. Geographical data are vintaged, not just where, but where when. Was for example Estonia occupied by the USSR 1940-1941, 1944-1991, or was it part of the USSR for the purposes of this exercise? Using disputed boundaries implies a choice of point of view, one that may not be intended.] Roger map_poly_obj$names So you can build a matching colours vector, or: library(sp) library(maptools) IDs - sapply(strsplit(map_poly_obj$names, :), function(x) x[1]) SP_AB - map2SpatialPolygons(map_poly_obj, IDs=IDs, proj4string=CRS(+proj=longlat +datum=wgs84)) but plot(SP_AB, col=c(cyan, green)) still misses, because some polygons have their rings of coordinates in counter-clockwise order, so: pl_new - lapply(slot(SP_AB, polygons), checkPolygonsHoles) slot(SP_AB, polygons) - pl_new # please forget the assignment to the slot and do not do it unless you can # replace what was there before plot(SP_AB, col=c(cyan, green), axes=TRUE) now works. Moreover, SP_AB is a SpatialPolygons object, which can be promoted to a SpatialPolygonsDataFrame object, for a data slot holding a data.frame with row names matching the Polygons ID values: sapply(slot(SP_AB, polygons), function(x) slot(x, ID)) So adding a suitable data frame gets you to the lattice graphics method spplot(SP_AB, my_var) Hope this helps, So, in the above mentioned case, I could do something like: library(mapdata) commies - c(USSR, Mongolia) # Mongolia was the 2nd communist country, in 1925 map_poly_obj - map(worldHires, plot=FALSE) map_poly_commies - map(worldHires, commies, plot=FALSE, fill=TRUE) plot(map_poly_obj, type=l) polygon(map_poly_commies, col=red, border=black) I guess I can keep going, unless there is a simpler solution. Alberto Monteiro -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with map
On Fri, 4 May 2007, Alberto Monteiro wrote: I have just learned how to play with map, but something weird (or not) is happening. Suppose I want to draw a map of two countries (that have disconnected components), like Argentina and Brazil. If I command: library(maps) library(mapdata) map(worldHires, c(Argentina, Brazil)) It works fine. However, if I want to _colour_ the interior: map(worldHires, c(Argentina, Brazil), c(cyan, green), fill=T) Then the colors will be assigned to the islands (Marajo in Brazil's North and Tierra del Fuego in Argentina's South) and there will be a recycling. Is there any way to associate one color to each country? Try: map_poly_obj - map(worldHires, c(Argentina, Brazil), plot=FALSE, fill=TRUE) str(map_poly_obj) and you'll see that the component of interest is the named polygons, of which there are 28, namely map_poly_obj$names So you can build a matching colours vector, or: library(sp) library(maptools) IDs - sapply(strsplit(map_poly_obj$names, :), function(x) x[1]) SP_AB - map2SpatialPolygons(map_poly_obj, IDs=IDs, proj4string=CRS(+proj=longlat +datum=wgs84)) but plot(SP_AB, col=c(cyan, green)) still misses, because some polygons have their rings of coordinates in counter-clockwise order, so: pl_new - lapply(slot(SP_AB, polygons), checkPolygonsHoles) slot(SP_AB, polygons) - pl_new # please forget the assignment to the slot and do not do it unless you can # replace what was there before plot(SP_AB, col=c(cyan, green), axes=TRUE) now works. Moreover, SP_AB is a SpatialPolygons object, which can be promoted to a SpatialPolygonsDataFrame object, for a data slot holding a data.frame with row names matching the Polygons ID values: sapply(slot(SP_AB, polygons), function(x) slot(x, ID)) So adding a suitable data frame gets you to the lattice graphics method spplot(SP_AB, my_var) Hope this helps, Roger Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help Installing R
I have unzipped the R-2.5.0.tar.gz gzip -dc R-x.y.z.tar.gz | tar xvf - 2. then #./configure 3. ./configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu loading site script './config.site' loading build specific script './config.site' checking for pwd... /bin/pwd checking whether builddir is srcdir... yes checking for working aclocal... found checking for working autoconf... found checking for working automake... found checking for working autoheader... found checking for gawk... gawk checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking whether ln -s works... yes checking for ranlib... ranlib checking for bison... no checking for byacc... no checking for ar... ar checking for a BSD-compatible install... /usr/bin/install -c checking for sed... /bin/sed checking for less... /usr/bin/less checking for perl... /usr/bin/perl checking whether perl version is at least 5.004... yes checking for dvips... /usr/bin/dvips checking for tex... /usr/bin/tex checking for latex... /usr/bin/latex checking for makeindex... /usr/bin/makeindex checking for pdftex... /usr/bin/pdftex checking for pdflatex... /usr/bin/pdflatex checking for makeinfo... /usr/bin/makeinfo checking whether makeinfo version is at least 4.7... yes checking for unzip... /usr/bin/unzip checking for zip... /usr/bin/zip checking for gzip... /bin/gzip checking for firefox... /usr/bin/firefox using default browser ... /usr/bin/firefox checking for acroread... no checking for acroread4... no checking for xpdf... no checking for gv... no checking for gnome-gv... no checking for ggv... /usr/bin/ggv checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking whether gcc needs -traditional... no checking how to run the C preprocessor... gcc -E checking for g77... g77 checking whether we are using the GNU Fortran 77 compiler... yes checking whether g77 accepts -g... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking how to run the C++ preprocessor... g++ -E checking whether __attribute__((visibility())) is supported... yes checking whether gcc accepts -fvisibility... yes checking whether g77 accepts -fvisibility... yes checking for gcc... gcc checking whether we are using the GNU Objective C compiler... no checking whether gcc accepts -g... no checking whether g++ can compile ObjC++... yes checking for Objective C++ compiler... g++ checking for a sed that does not truncate output... /bin/sed checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for /usr/bin/ld option to reload object files... -r checking for BSD-compatible nm... /usr/bin/nm -B checking how to recognise dependent libraries... pass_all checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking the maximum length of command line arguments... 32768 checking command to parse /usr/bin/nm -B output from gcc object... ok checking for objdir... .libs checking for ranlib... (cached) ranlib checking for strip... strip checking if gcc static flag works... yes checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC checking if gcc PIC flag -fPIC works... yes checking if gcc supports -c -o file.o... yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no configure: creating libtool appending configuration tag CXX to libtool checking for ld used by g++... /usr/bin/ld -m elf_x86_64 checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking for g++ option to produce PIC... -fPIC checking if g++ PIC flag -fPIC works... yes checking if g++
Re: [R] Help Installing R
On Fri, 2007-05-04 at 10:06 -0500, Pramod Anugu wrote: I have unzipped the R-2.5.0.tar.gz gzip -dc R-x.y.z.tar.gz | tar xvf - 2. then #./configure 3. ./configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu loading site script './config.site' loading build specific script './config.site' checking for pwd... /bin/pwd checking whether builddir is srcdir... yes checking for working aclocal... found checking for working autoconf... found checking for working automake... found checking for working autoheader... found checking for gawk... gawk checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking whether ln -s works... yes checking for ranlib... ranlib checking for bison... no checking for byacc... no checking for ar... ar checking for a BSD-compatible install... /usr/bin/install -c checking for sed... /bin/sed checking for less... /usr/bin/less checking for perl... /usr/bin/perl checking whether perl version is at least 5.004... yes checking for dvips... /usr/bin/dvips checking for tex... /usr/bin/tex checking for latex... /usr/bin/latex checking for makeindex... /usr/bin/makeindex checking for pdftex... /usr/bin/pdftex checking for pdflatex... /usr/bin/pdflatex checking for makeinfo... /usr/bin/makeinfo checking whether makeinfo version is at least 4.7... yes checking for unzip... /usr/bin/unzip checking for zip... /usr/bin/zip checking for gzip... /bin/gzip checking for firefox... /usr/bin/firefox using default browser ... /usr/bin/firefox checking for acroread... no checking for acroread4... no checking for xpdf... no checking for gv... no checking for gnome-gv... no checking for ggv... /usr/bin/ggv checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking whether gcc needs -traditional... no checking how to run the C preprocessor... gcc -E checking for g77... g77 checking whether we are using the GNU Fortran 77 compiler... yes checking whether g77 accepts -g... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking how to run the C++ preprocessor... g++ -E checking whether __attribute__((visibility())) is supported... yes checking whether gcc accepts -fvisibility... yes checking whether g77 accepts -fvisibility... yes checking for gcc... gcc checking whether we are using the GNU Objective C compiler... no checking whether gcc accepts -g... no checking whether g++ can compile ObjC++... yes checking for Objective C++ compiler... g++ checking for a sed that does not truncate output... /bin/sed checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for /usr/bin/ld option to reload object files... -r checking for BSD-compatible nm... /usr/bin/nm -B checking how to recognise dependent libraries... pass_all checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking the maximum length of command line arguments... 32768 checking command to parse /usr/bin/nm -B output from gcc object... ok checking for objdir... .libs checking for ranlib... (cached) ranlib checking for strip... strip checking if gcc static flag works... yes checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC checking if gcc PIC flag -fPIC works... yes checking if gcc supports -c -o file.o... yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no configure: creating libtool appending configuration tag CXX to libtool checking for ld used by g++... /usr/bin/ld -m elf_x86_64 checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes checking whether the g++ linker
Re: [R] Help with map
[for those that worry about these things, this _is_ a homework assignment. However, it's not an R homework, it's a Geography and History homework... and I want to use R to create a pretty map] Roger Bivand wrote: Is there any way to associate one color to each country? Try: map_poly_obj - map(worldHires, c(Argentina, Brazil), plot=FALSE, fill=TRUE) str(map_poly_obj) and you'll see that the component of interest is the named polygons, of which there are 28, namely Ok, I guess I can see what you mean. It worked, but I don't think this is a practical way to draw things. For example, suppose [this would help homework mentioned above] I want to draw a series of maps showing the evolution of Communism in the XX century. I would like to start with a 1917 map, showing most countries as in... map(worldHires) ... but with the Soviet Union in red. I don't see how I could mix the two maps (BTW, there's no Russia in worldHires, but there is a USSR...) map(worldHires); map(worldHires, USSR, col=red, fill=T) map_poly_obj$names So you can build a matching colours vector, or: library(sp) library(maptools) IDs - sapply(strsplit(map_poly_obj$names, :), function(x) x[1]) SP_AB - map2SpatialPolygons(map_poly_obj, IDs=IDs, proj4string=CRS(+proj=longlat +datum=wgs84)) but plot(SP_AB, col=c(cyan, green)) still misses, because some polygons have their rings of coordinates in counter-clockwise order, so: pl_new - lapply(slot(SP_AB, polygons), checkPolygonsHoles) slot(SP_AB, polygons) - pl_new # please forget the assignment to the slot and do not do it unless you can # replace what was there before plot(SP_AB, col=c(cyan, green), axes=TRUE) now works. Moreover, SP_AB is a SpatialPolygons object, which can be promoted to a SpatialPolygonsDataFrame object, for a data slot holding a data.frame with row names matching the Polygons ID values: sapply(slot(SP_AB, polygons), function(x) slot(x, ID)) So adding a suitable data frame gets you to the lattice graphics method spplot(SP_AB, my_var) Hope this helps, So, in the above mentioned case, I could do something like: library(mapdata) commies - c(USSR, Mongolia) # Mongolia was the 2nd communist country, in 1925 map_poly_obj - map(worldHires, plot=FALSE) map_poly_commies - map(worldHires, commies, plot=FALSE, fill=TRUE) plot(map_poly_obj, type=l) polygon(map_poly_commies, col=red, border=black) I guess I can keep going, unless there is a simpler solution. Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with map
On 04/05/2007 9:00 PM, Alberto Vieira Ferreira Monteiro wrote: [for those that worry about these things, this _is_ a homework assignment. However, it's not an R homework, it's a Geography and History homework... and I want to use R to create a pretty map] Roger Bivand wrote: Is there any way to associate one color to each country? Try: map_poly_obj - map(worldHires, c(Argentina, Brazil), plot=FALSE, fill=TRUE) str(map_poly_obj) and you'll see that the component of interest is the named polygons, of which there are 28, namely Ok, I guess I can see what you mean. It worked, but I don't think this is a practical way to draw things. For example, suppose [this would help homework mentioned above] I want to draw a series of maps showing the evolution of Communism in the XX century. I would like to start with a 1917 map, showing most countries as in... map(worldHires) ... but with the Soviet Union in red. I don't see how I could mix the two maps (BTW, there's no Russia in worldHires, but there is a USSR...) map(worldHires); map(worldHires, USSR, col=red, fill=T) map_poly_obj$names So you can build a matching colours vector, or: library(sp) library(maptools) IDs - sapply(strsplit(map_poly_obj$names, :), function(x) x[1]) SP_AB - map2SpatialPolygons(map_poly_obj, IDs=IDs, proj4string=CRS(+proj=longlat +datum=wgs84)) but plot(SP_AB, col=c(cyan, green)) still misses, because some polygons have their rings of coordinates in counter-clockwise order, so: pl_new - lapply(slot(SP_AB, polygons), checkPolygonsHoles) slot(SP_AB, polygons) - pl_new # please forget the assignment to the slot and do not do it unless you can # replace what was there before plot(SP_AB, col=c(cyan, green), axes=TRUE) now works. Moreover, SP_AB is a SpatialPolygons object, which can be promoted to a SpatialPolygonsDataFrame object, for a data slot holding a data.frame with row names matching the Polygons ID values: sapply(slot(SP_AB, polygons), function(x) slot(x, ID)) So adding a suitable data frame gets you to the lattice graphics method spplot(SP_AB, my_var) Hope this helps, So, in the above mentioned case, I could do something like: library(mapdata) commies - c(USSR, Mongolia) # Mongolia was the 2nd communist country, in 1925 map_poly_obj - map(worldHires, plot=FALSE) map_poly_commies - map(worldHires, commies, plot=FALSE, fill=TRUE) plot(map_poly_obj, type=l) polygon(map_poly_commies, col=red, border=black) I guess I can keep going, unless there is a simpler solution. Here's the sloppy code I used to put together the map in the persp3d example in rgl 0.71. I've just made a few edits; I hope it still runs. The idea is to do a lot of calculations on a vector of colours, then plot them all at once. library(mapdata) names - map(worldHires, plot=FALSE, namesonly=TRUE) countries - gsub(:.*, , names) # the first part of the name lakes - grep(Lake, names) lakes - lakes[-15] lakes - unique(c(lakes, grep(Ozero, names), grep(Vodokh, names), grep(Nuur, names), grep(Ostrov Ol'khon, names), grep(Hayk, names), grep(Lago, names))) # The map doesn't distinguish these seas - grep(Sea, names) nfld - grep(^Newfoundland$, names) # nfld should be coloured as Canada canada - grep(^Canada$, names) svalbard - grep(Svalbard, names) # Svalbard coloured as Norway norway - grep(^Norway$, names) nums - as.numeric(factor(countries)) N - max(nums) set.seed(3) col - hcl(h=sample((1:N)*360/N), c=sample(seq(35,45,len=N)), l=sample(seq(75,85,len=N)))[nums] # random colours by country col[c(lakes,seas)] - white # with lakes and seas white col[nfld] - col[canada] col[svalbard] - col[norway] png(width=2200, height=2200, file='world.png') map('worldHires', fill = TRUE, col = col, ylim=c(-90,90)) abline(h=c(-90, 90)) abline(v=c(-180.05, 180.05)) dev.off() I hope this gives you some ideas. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with saptial analysis (cluster)
ONKELINX, Thierry Thierry.ONKELINX at inbo.be writes: Dear Fransico, The distance matrix would be 102000 x 102000. So it would contain 1040400 values. If you need one bit for each value, this would requier 9,7 GB. So the distance matrix won't fit in the RAM of your computer. Perhaps you could make progress by using a 2D kernel density - there are functions among others in the MASS and splancs packages, or by binning - Bioconductor's hexbin package comes to mind. Then you would be looking for areas of increased density on the grid (in points per unit area or equivalently counts per bin) rather than at the interpoint distances. The kernel2d() function in splancs handles a data set of your size with no problems. Roger (with apologies for pruning, gmane is very dictatorial) Cheers, Thierry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help
Natalie O'Toole wrote: Hi, Would anyone know how to calculate the modal value of LeafArea? Thank-you very much!! Nat __ Hi all, I have 2 questions: 1)How do I calculate the mean on an imported txt file? I've imported the file below and that's what it looks like imported. How do I then calcuate the mean, median, or mode on the column LeafArea using the desktop R package? Hi Nat, Try this: leaf.df-read.table(leafdata.csv,header=TRUE) library(prettyR) describe(leaf.df) Mode(leaf.df$LeafArea) Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with saptial analysis (cluster)
Dear Fransico, The distance matrix would be 102000 x 102000. So it would contain 1040400 values. If you need one bit for each value, this would requier 9,7 GB. So the distance matrix won't fit in the RAM of your computer. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach 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 Francisco Pastor Verzonden: woensdag 25 april 2007 12:34 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] Help with saptial analysis (cluster) Hi R-users I'm a beginner with R and statistics, so I need some help to start my data analysis. I've been reading some docs and tutorials on R and cluster analysis. I've got a large dataset (102000 points) with values of longitude, latitude and temperature and want to see if I can find groups (clusters). Following some tutorials I can look for principal components but get an error with calculation of distances: matriz.distancias-dist(comp.obs) Error in vector(double, length) : specified vector size is too big (translated from spanish) So, my questions are: is the dataset too big? could you point me to any docs explaining how to study spatially distributed data (lon,lat,data)? Thanks in advance __ _ Francisco Pastor Meteorology department Fundación CEAM [EMAIL PROTECTED] http://www.gva.es/ceamet http://www.gva.es/ceam Paterna, Valencia, Spain __ _ Usuario Linux registrado: 363952 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help on 'find.BIB' function
Jason Parcon wrote: Hello everyone, I am trying to use the 'find.BIB' function to construct a balanced incomplete block design. When I ran the example given in the help file (find.BIB(10,30,4)), I obtained the following error message: Error in optBlock(~., withinData = factor(1:trt), blocksize = rep(k, b)) : object .Random.seed not found I investigated what the optBlock function is doing but the manual / help files did not give me any information regarding the above error. I hope somebody can help me regarding this matter. The following seems to work for me: library(crossdes) Loading required package: AlgDesign Loading required package: gtools Loading required package: MASS set.seed(671969) find.BIB(10,30,4) [,1] [,2] [,3] [,4] [1,]457 10 [2,]123 10 [3,]156 10 [4,]289 10 [5,]3567 [6,]349 10 [7,]1589 [8,]1679 [9,]1247 [10,]268 10 [11,]2357 [12,]1679 [13,]267 10 [14,]1239 [15,]2568 [16,]2459 [17,]3468 [18,]158 10 [19,]2478 [20,]369 10 [21,]1246 [22,]378 10 [23,]2359 [24,]145 10 [25,]4689 [26,]479 10 [27,]1378 [28,]3456 [29,]5789 [30,]1348 I get the same error you report if I don't do the set.seed() step. sessionInfo() R version 2.4.1 Patched (2007-03-31 r41127) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base other attached packages: crossdes MASSgtools AlgDesign 1.0-7 7.2-33 2.3.1 1.0-7 Best regards, Jason Parcon - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help interpreting the output of functions - any sources of information
Hi, If you look at the documentation for the function you are interested in, in this case ?cor.test, it will generally give you an explanation of the return values (often brief, and not too helpful if you aren't already familiar with the test), but also one or more references that you can turn to for further information. Most likely, though, you'll want to absorb a general introductory stats book before you delve into the gory details of many of those references. Sarah On 4/24/07, Y G [EMAIL PROTECTED] wrote: Hi, I am looking for documentation, reference guides, etc. that explain the output of functions... For example using cor.test(, method=pearson) with Pearson's corr coeff the output is: Pearson's product-moment correlation data: a and b t = 0.2878, df = 14, p-value = 0. alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: -0.4355690 0.5514366 sample estimates: cor 0.07669612 What are all these? Apologies but I am new in R and statistics in general but a textbook I was looking at, regarding SPSS, explains only the r coeff and the conf interval Any help with sources I can refer to? Particularly in a broader context as it would not be nice to post all the time such questions... Thanks in advance, GM -- Sarah Goslee http://www.functionaldiversity.org __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help interpreting the output of functions - any sources of information
On 24/04/07, Sarah Goslee [EMAIL PROTECTED] wrote: Hi, If you look at the documentation for the function you are interested in, in this case ?cor.test, it will generally give you an explanation of the return values (often brief, and not too helpful if you aren't already familiar with the test), but also one or more references that you can turn to for further information. Most likely, though, you'll want to absorb a general introductory stats book before you delve into the gory details of many of those references. Sarah Thanks for the hint, that will do... On 4/24/07, Y G [EMAIL PROTECTED] wrote: Hi, I am looking for documentation, reference guides, etc. that explain the output of functions... For example using cor.test(, method=pearson) with Pearson's corr coeff the output is: Pearson's product-moment correlation data: a and b t = 0.2878, df = 14, p-value = 0. alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: -0.4355690 0.5514366 sample estimates: cor 0.07669612 What are all these? Apologies but I am new in R and statistics in general but a textbook I was looking at, regarding SPSS, explains only the r coeff and the conf interval Any help with sources I can refer to? Particularly in a broader context as it would not be nice to post all the time such questions... Thanks in advance, GM -- Sarah Goslee http://www.functionaldiversity.org [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help about princomp
On Mon, 23 Apr 2007, annina wrote: Hello, I have a problem with the princomp method, it seems stupid but I don't know how to handle it. I have a dataset with some regular data and some outliers. I want to calculate a PCA on the regular data and get the scores for all data, including the outliers. Is this possible on R? Yes. Do you know which are the outliers? You can either fit to the 'regular data' with princomp and use predict() to get the 'scores' for all the data, or use a robust method to find the 'covmat' argument (as the help page says, you could use cov.mcd from MASS) and call princomp() on all the data. -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.