[R] How to store the parameter estimated by nls( ) to a variable?
Dear Colleagues. I believe this should be a problem encountered by many: nls( ) is a very useful and efficient function to use if we are just to display the estimated value on screen. What if we need R to store the estimated parameter in a variable? For example: x=rnorm(10, mean=1000, sd=10) y=x^2+100+rnorm(10) a=nls(y~(x^2+para),control=list(maxiter = 1000, minFactor=0.5 ^1024),start=list(para=0.0)) How to store the estimated value of para in this case, in a variable, say, b? It is easy to display a and find all the information. How ever, I need to fit a different set of x and y in every loop of my code and I need to store the estimated values for further use. I have checked both the online manual and several S-plus books but no example as such showed up. Your help will be highly appreciated! Best Wishes Yuchen Luo [[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] Convert factor to numeric vector of labels
Hi, I have imported a data file to R. Unfortunately R has interpreted some numeric variables as factors. Therefore I want to reconvert these to numeric vectors whose values are the factor levels' labels. I tried as.numeric(factor), but it returns a vector of factor levels (i.e. 1,2,3,...) instead of labels (i.e. 0.71, 1.34, 2.61, ). What can I do instead? Best wishes, Falk [[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] Convert factor to numeric vector of labels
See the FAQ Q7.10 (and please study the posting guide) On Sun, 12 Aug 2007, Falk Lieder wrote: Hi, I have imported a data file to R. Unfortunately R has interpreted some numeric variables as factors. Therefore I want to reconvert these to numeric vectors whose values are the factor levels' labels. I tried as.numeric(factor), but it returns a vector of factor levels (i.e. 1,2,3,...) instead of labels (i.e. 0.71, 1.34, 2.61, ). What can I do instead? Best wishes, Falk [[alternative HTML version deleted]] PLEASE do read the posting guide http://www.R-project.org/posting-guide.html -- 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.
[R] question on glmmML compared to NLMIXED
Hello! Can anyone help me. I am using the posterior.mode from the result of glmmML. It apears to be different from the BLUe estimate of the RANDOM statement in PROC NLMIXED in SAS. Why is that? Thank you Ronen [[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] R Weka and cobweb
adschai at optonline.net writes: Hi, I never use cobweb before and I'm quite new to this. I have a couple of questions around the cobweb implementation in R Weka. If you could supply answer or insight, I would really appreciate. 1. From Fisher's paper in 1987, it seems that Cobweb only deals with nominal data. In R Weka cobweb, is it allowed to accommodate real/continuous value? 2. My understanding is that Cobweb clusters based on Category Utility function. However, if I would like to specify my own objective function, how can I do so? 3. I have about 130,000 data points (each with about 50 attributes) for training and another same amount for testing. Would this cause any memory or performance problem? Thank you, - adschai RWeka is simply an interface to the WEKA data mining software. Why don't you just put your question to the Weka mailing list at https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist? From my own former experience I would say that Cobweb is never applicable to large data sets (and was not meant for that) and for numerical attributes the results are not very meaningful. Hans Werner Borchers __ 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] Artifacts in pdf() of image() (w/o comments)
Michael Kubovy wrote: Dear r-helpers, In my previous message there were comments in the code that may have made cutting and pasting awkward. Here it is w/o them. I have two questions: (1) The following produces a pdf with artifacts. How do I prevent them? What artifacts do you see? It looks like a smoothly varying field when produced by R 2.5.1 and viewed in Acrobat Reader 6.0 on Windows. Duncan Murdoch require(grDevices) imSize - 200 lambda - 10 theta - 15 sigma - 40 x - 1:imSize x0 - x / imSize -.5 freq = imSize/lambda xf = x0 * freq * 2 * pi f - function(x, y){r - -((x^2 + y^2)/(sigma ^2)); exp(r)} z - outer(xf, xf, f) f1 - function(x, y){cos(.1 * x)} z1 - outer(xf, xf, f1) pdf('gabor.pdf') image(xf, xf, z * z1, col = gray(250:1000/1000), xlab = '', ylab = '', bty = 'n', axes = FALSE, asp = 1) dev.off() (2) I would like the output to be clipped to a circle, i.e., anything outside the circle tangent to the sides of the square should be transparent. How can I do that? Set the values there to NA? I'm not sure how ragged that will make the edge... __ 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] How to store the parameter estimated by nls( ) to a variable?
Yuchen Luo wrote: Dear Colleagues. I believe this should be a problem encountered by many: nls( ) is a very useful and efficient function to use if we are just to display the estimated value on screen. What if we need R to store the estimated parameter in a variable? For example: x=rnorm(10, mean=1000, sd=10) y=x^2+100+rnorm(10) a=nls(y~(x^2+para),control=list(maxiter = 1000, minFactor=0.5 ^1024),start=list(para=0.0)) How to store the estimated value of para in this case, in a variable, say, b? It is easy to display a and find all the information. How ever, I need to fit a different set of x and y in every loop of my code and I need to store the estimated values for further use. I have checked both the online manual and several S-plus books but no example as such showed up. Your help will be highly appreciated! coef(a) will get what you want. coef() works for most modelling functions where it makes sense. 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.
[R] Write values on y axe
Hi, I have values on y axe from 0.0001 to 3.086. When I do plot I have writen values: 0.001, 0.050,1.000 ..., but how I can write on graph the minimum value and maximum value, with all decimals (I don't want to use the format 1e-0x)? I am using log scale. For example, if I have the values: 0.0001 0.0015 0.0256 0.0236 0.0201 2.9668 3.0086 I need have each 'x' value put on y axe, and add the value minimum and maximum on my graph. How can I do it? I do: plot(o$a, log=y, type=l, col=colors[1], xlab=a_x, ylab=a_y, cex.lab=0.8) lines(o$b, type=l, pch=1, lty=1, col=colors[2]) lines(o$c, type=l, pch=2, lty=2, col=colors[3]) to I draw my graph. Thanks in advance. [[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] Write values on y axe
Does this do what you want: x - runif(10) plot(x) # put min/max in red axis(2, at=round(range(x), 4), col.axis='red', las=2) On 8/12/07, akki [EMAIL PROTECTED] wrote: Hi, I have values on y axe from 0.0001 to 3.086. When I do plot I have writen values: 0.001, 0.050,1.000 ..., but how I can write on graph the minimum value and maximum value, with all decimals (I don't want to use the format 1e-0x)? I am using log scale. For example, if I have the values: 0.0001 0.0015 0.0256 0.0236 0.0201 2.9668 3.0086 I need have each 'x' value put on y axe, and add the value minimum and maximum on my graph. How can I do it? I do: plot(o$a, log=y, type=l, col=colors[1], xlab=a_x, ylab=a_y, cex.lab=0.8) lines(o$b, type=l, pch=1, lty=1, col=colors[2]) lines(o$c, type=l, pch=2, lty=2, col=colors[3]) to I draw my graph. Thanks in advance. [[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. -- 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] Legend on graph
Hi, I have a problem when I want to put a legend on the graph. I do: legend(topright, names(o), cex=0.9, col=plot_colors,lty=1:5, bty=n) but the legend is writen into the graph (graphs' top but into the graph), because I have values on this position. How can I write the legend on top the graph without the legend writes on graph's values. 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] need help to manipulate function and time interval
Matthew Walker wrote: Uwe Ligges wrote: Henrique Dallazuanna wrote: Hi, Try whit: if(time[j] = 18:00:00 23:59:59) This code is obviously wrong and does not help for the next few lines in the questioner's message, please do not post unsensible stuff. Uwe Ligges Actually, I would have said that was quite an interesting solution. If the time is guaranteed to be in this 8 character format, then that idea's quite easily implemented: # Returns true if time is between 18:00:00 and 23:59:59 check_time - function(time_string) { if (nchar(time_string)!=8) stop (Incorrect format) time_string = 18:00:00 time_string = 23:59:59 } check_time(19:59:00) [1] TRUE check_time(16:59:00) [1] FALSE check_time(18:00:00) [1] TRUE check_time(23:59:59) [1] TRUE check_time(24:00:00) [1] FALSE check_time(18:05) Error in check_time(18:05) : Incorrect format Perhaps there is an issue if the locale does not sort character-based numbers in the same way as ASCII? But Otherwise, I can't see why this solution wouldn't do the job. A more robust solution solution would parse the strings (?strptime) and then check their days/hours/mins/seconds (?DateTimeClasses). But perhaps the above is sufficient? Well, the interesting part of the original question that everynody seems to omit now was the second part: if (time[j] is between 22:00:00 and 05:59:59) hence the answer is still not sufficient (even if the syntax error has been corrected) - and hence I asked for the format the time is originally in. Uwe Ligges Cheers, Matthew __ 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] competing risk p value in a figure
Dear R users Is there a way to include in a figure the 2 sided p value obtained with the crr function in the package cmprsk Such as the one for cuminc: text(3.5,0.05, adj=0, paste(Gray test: p-value = , round(fit1$Tests[1,2],3))) thanks for your help ? Phil [[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 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] Artifacts in pdf() of image() (w/o comments)
On Aug 12, 2007, at 6:24 AM, Duncan Murdoch wrote: Michael Kubovy wrote: Dear r-helpers, In my previous message there were comments in the code that may have made cutting and pasting awkward. Here it is w/o them. I have two questions: (1) The following produces a pdf with artifacts. How do I prevent them? What artifacts do you see? It looks like a smoothly varying field when produced by R 2.5.1 and viewed in Acrobat Reader 6.0 on Windows. Duncan Murdoch require(grDevices) imSize - 200 lambda - 10 theta - 15 sigma - 40 x - 1:imSize x0 - x / imSize -.5 freq = imSize/lambda xf = x0 * freq * 2 * pi f - function(x, y){r - -((x^2 + y^2)/(sigma ^2)); exp(r)} z - outer(xf, xf, f) f1 - function(x, y){cos(.1 * x)} z1 - outer(xf, xf, f1) pdf('gabor.pdf') image(xf, xf, z * z1, col = gray(250:1000/1000), xlab = '', ylab = '', bty = 'n', axes = FALSE, asp = 1) dev.off() I'm working on a Mac. You're right, Acrobat 6.05 renders the figure nicely, but when it's included in a LaTeX-produced pdf or viewed with the Mac Preview program, a grid of fine white lines is superimposed on the figure. So I believe that it's a matter of aliasing, which I might be able to prevent by adjusting the parameters of the figures. I just don't know enough to figure this out, and would appreciate guidance. _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ 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] How to store the parameter estimated by nls( ) to a variable?
Dear Professor Murdoch. Thank you so much Best Wishes Yuchen Luo On 8/12/07, Duncan Murdoch [EMAIL PROTECTED] wrote: Yuchen Luo wrote: Dear Colleagues. I believe this should be a problem encountered by many: nls( ) is a very useful and efficient function to use if we are just to display the estimated value on screen. What if we need R to store the estimated parameter in a variable? For example: x=rnorm(10, mean=1000, sd=10) y=x^2+100+rnorm(10) a=nls(y~(x^2+para),control=list(maxiter = 1000, minFactor=0.5 ^1024),start=list(para=0.0)) How to store the estimated value of para in this case, in a variable, say, b? It is easy to display a and find all the information. How ever, I need to fit a different set of x and y in every loop of my code and I need to store the estimated values for further use. I have checked both the online manual and several S-plus books but no example as such showed up. Your help will be highly appreciated! coef(a) will get what you want. coef() works for most modelling functions where it makes sense. Duncan Murdoch [[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] Legend on graph
If you are asking to have the values plotted on top of the legend, then you can do the following: plot(x, y, type='n', ...) # create plot, but don't plot legend('topright', ...) lines(x,y) # now plot the data If you want it outside the plot, check the archives for several examples. On 8/12/07, akki [EMAIL PROTECTED] wrote: Hi, I have a problem when I want to put a legend on the graph. I do: legend(topright, names(o), cex=0.9, col=plot_colors,lty=1:5, bty=n) but the legend is writen into the graph (graphs' top but into the graph), because I have values on this position. How can I write the legend on top the graph without the legend writes on graph's values. 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. -- 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] deldir package - voronoi
On 12/08/2007, at 1:22 PM, zubin wrote: Hello! I am using the deldir package to visualize my data, pretty neat. However, i need to fill the colors using polycol =, fill with colors like a heatmap - more of a gradient fill. The only colors i get are very blocky - how do i assign the correct colors for a gradient, even a grayscale? i tried the chart of R colors, using 200 numbers for grayscale but not getting them. The polycol = colors the cells in the tesselation with the value a specific vector for color. snip I'm sorry, but I can't help here. I've been struggling with colors, in a different context, recently myself, and I'm unclear as to how they work. There are a bunch of functions --- palette(), colorRamp(), colorRampPalette() that probably relate to what you want to do, but I'm not sure just *how* they relate. With a bit of luck, someone cleverer than I will come to your rescue. cheers, Rolf Turner ## 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.
[R] How to control the number format on plot axes ?
Dear R-users, Basically, everything is in the title of my e-mail. I know that some threads from the archives have already addressed this question but they did not really give a clear solution. Here is a series of short codes that will illustrate the problem: # First a-1:10 plot(x=a,y=a,log=y,type=p) # Second a-1:10 myTicks-c(1,2,5,10) plot(x=a,y=a,log=y,type=p,yaxt=n) axis(side=2,at=myTicks) # Third a-1:10 myTicks-c(0.1,1,2,5,10) plot(x=a,y=a,log=y,type=p,yaxt=n) axis(side=2,at=myTicks) # Forth a-0.1:10 plot(x=a,y=a,log=y,type=p) In the first and second examples, the plots are identical and the tick labels are 1, 2, 5 and 10. In the third, the labels are number in the x.0 format (1.0, 2.0, 5.0 and 10.0), even if there is no point below 1. The only reason I see is because the first element of myTicks is 0.1. And, the forth example is self-explanatory. Interestingly, the 'scales' argument of xyplot in the lattice package do not add these (unnecessary) decimals on labels greater than 1. Do you know how I could transpose the behavior of the lattice 'scales' argument to the 'axis' function ? Thank you PS: No offense, but please don't suggest I use lattice. I have to go for base R graphics in my full-scale project (it is a speed issue). __ 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] Colours in R, was: deldir package - voronoi
Dear Rolf and Binabina perhaps this is of use to some: Colour for Presentation Graphics. Ross Ihaka. www.stat.auckland.ac.nz/~ihaka/colour/color.pdf Choosing Color Palettes for Statistical Graphics Achim Zeileis and Kurt Hornik. eeyore.ucdavis.edu/stat250/epub-wu-01_abd.pdf Best wishes Wolfgang -- Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber Turner ha scritto: On 12/08/2007, at 1:22 PM, zubin wrote: Hello! I am using the deldir package to visualize my data, pretty neat. However, i need to fill the colors using polycol =, fill with colors like a heatmap - more of a gradient fill. The only colors i get are very blocky - how do i assign the correct colors for a gradient, even a grayscale? i tried the chart of R colors, using 200 numbers for grayscale but not getting them. The polycol = colors the cells in the tesselation with the value a specific vector for color. snip I'm sorry, but I can't help here. I've been struggling with colors, in a different context, recently myself, and I'm unclear as to how they work. There are a bunch of functions --- palette(), colorRamp(), colorRampPalette() that probably relate to what you want to do, but I'm not sure just *how* they relate. With a bit of luck, someone cleverer than I will come to your rescue. cheers, Rolf Turner ## 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. __ 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] Colours in R, was: deldir package - voronoi
On 13/08/2007, at 11:27 AM, Wolfgang Huber wrote: Dear Rolf and Binabina perhaps this is of use to some: Colour for Presentation Graphics. Ross Ihaka. www.stat.auckland.ac.nz/~ihaka/colour/color.pdf Choosing Color Palettes for Statistical Graphics Achim Zeileis and Kurt Hornik. eeyore.ucdavis.edu/stat250/epub-wu-01_abd.pdf Best wishes Wolfgang -- Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber Thanks very much; I'll have a look at these resources. cheers, Rolf ## 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] How to control the number format on plot axes ?
Here is a way that you can put the formatting that you want; you were not clear on exactly what you were after. You can setup the 'labels' argument for whatever you want. a-1:10 myTicks-c(0.1,1,2,5,10) # set ylim to range of myTicks that you want plot(x=a,y=a,log=y,type=p,yaxt=n, ylim=range(myTicks)) # change the sprintf to whatever formatting you want axis(side=2,at=myTicks, labels=ifelse(myTicks = 1, sprintf(%.0f, myTicks), sprintf(%0.1f, myTicks))) On 8/12/07, Sébastien [EMAIL PROTECTED] wrote: Dear R-users, Basically, everything is in the title of my e-mail. I know that some threads from the archives have already addressed this question but they did not really give a clear solution. Here is a series of short codes that will illustrate the problem: # First a-1:10 plot(x=a,y=a,log=y,type=p) # Second a-1:10 myTicks-c(1,2,5,10) plot(x=a,y=a,log=y,type=p,yaxt=n) axis(side=2,at=myTicks) # Third a-1:10 myTicks-c(0.1,1,2,5,10) plot(x=a,y=a,log=y,type=p,yaxt=n) axis(side=2,at=myTicks) # Forth a-0.1:10 plot(x=a,y=a,log=y,type=p) In the first and second examples, the plots are identical and the tick labels are 1, 2, 5 and 10. In the third, the labels are number in the x.0 format (1.0, 2.0, 5.0 and 10.0), even if there is no point below 1. The only reason I see is because the first element of myTicks is 0.1. And, the forth example is self-explanatory. Interestingly, the 'scales' argument of xyplot in the lattice package do not add these (unnecessary) decimals on labels greater than 1. Do you know how I could transpose the behavior of the lattice 'scales' argument to the 'axis' function ? Thank you PS: No offense, but please don't suggest I use lattice. I have to go for base R graphics in my full-scale project (it is a speed issue). __ 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] Data structure in R
Hi, I have a question around how to build data structure in R. I have to implement a tree structure of data. I'm wondering if R already has something like a tree where I can extend from or I need to start from scratch. If so, what would be the most effective way to represent parent and child node relationship? I realize that R is not based on pointer so it's quite a different paradigm for me to code this. Thank you. - adschai __ 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] How to write to a table column by column?
Dear friends. Every loop of my program will result in a list that is very long, with a structure similar to the one below: Lst - list(name=Fred, wife=Mary, daily.incomes=c(1:850)) Please notice the large size of daily.incomes. I need to store all such lists in a csv file so that I can easily view them in Excel. Excel cannot display a row of more than 300 elements, therefore, I have to store the lists as columns. It is not hard to store one list as a column in the csv file. The problem is how to store the second list as a second column, so that the two columns will lie side by side to each other and I can easily compare their elements. ( If I use 'appened=TRUE', the second time series will be stored in the same column. ) Thank you for your tine and your help will be highly appreciated!! Best Yuchen Luo [[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] How to control the number format on plot axes ?
Thanks Jim, This sprintf function was exactly what I was looking for. jim holtman a écrit : Here is a way that you can put the formatting that you want; you were not clear on exactly what you were after. You can setup the 'labels' argument for whatever you want. a-1:10 myTicks-c(0.1,1,2,5,10) # set ylim to range of myTicks that you want plot(x=a,y=a,log=y,type=p,yaxt=n, ylim=range(myTicks)) # change the sprintf to whatever formatting you want axis(side=2,at=myTicks, labels=ifelse(myTicks = 1, sprintf(%.0f, myTicks), sprintf(%0.1f, myTicks))) On 8/12/07, Sébastien [EMAIL PROTECTED] wrote: Dear R-users, Basically, everything is in the title of my e-mail. I know that some threads from the archives have already addressed this question but they did not really give a clear solution. Here is a series of short codes that will illustrate the problem: # First a-1:10 plot(x=a,y=a,log=y,type=p) # Second a-1:10 myTicks-c(1,2,5,10) plot(x=a,y=a,log=y,type=p,yaxt=n) axis(side=2,at=myTicks) # Third a-1:10 myTicks-c(0.1,1,2,5,10) plot(x=a,y=a,log=y,type=p,yaxt=n) axis(side=2,at=myTicks) # Forth a-0.1:10 plot(x=a,y=a,log=y,type=p) In the first and second examples, the plots are identical and the tick labels are 1, 2, 5 and 10. In the third, the labels are number in the x.0 format (1.0, 2.0, 5.0 and 10.0), even if there is no point below 1. The only reason I see is because the first element of myTicks is 0.1. And, the forth example is self-explanatory. Interestingly, the 'scales' argument of xyplot in the lattice package do not add these (unnecessary) decimals on labels greater than 1. Do you know how I could transpose the behavior of the lattice 'scales' argument to the 'axis' function ? Thank you PS: No offense, but please don't suggest I use lattice. I have to go for base R graphics in my full-scale project (it is a speed issue). __ 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] Data structure in R
Hi Adschai, R has a class for tree-like structures. See the 'tree' package. Julian On Mon, 13 Aug 2007, [EMAIL PROTECTED] wrote: Hi, I have a question around how to build data structure in R. I have to implement a tree structure of data. I'm wondering if R already has something like a tree where I can extend from or I need to start from scratch. If so, what would be the most effective way to represent parent and child node relationship? I realize that R is not based on pointer so it's quite a different paradigm for me to code this. Thank you. - adschai __ 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] Artifacts in pdf() of image() (w/o comments)
Michael Kubovy wrote: On Aug 12, 2007, at 6:24 AM, Duncan Murdoch wrote: Michael Kubovy wrote: Dear r-helpers, In my previous message there were comments in the code that may have made cutting and pasting awkward. Here it is w/o them. I have two questions: (1) The following produces a pdf with artifacts. How do I prevent them? What artifacts do you see? It looks like a smoothly varying field when produced by R 2.5.1 and viewed in Acrobat Reader 6.0 on Windows. Duncan Murdoch require(grDevices) imSize - 200 lambda - 10 theta - 15 sigma - 40 x - 1:imSize x0 - x / imSize -.5 freq = imSize/lambda xf = x0 * freq * 2 * pi f - function(x, y){r - -((x^2 + y^2)/(sigma ^2)); exp(r)} z - outer(xf, xf, f) f1 - function(x, y){cos(.1 * x)} z1 - outer(xf, xf, f1) pdf('gabor.pdf') image(xf, xf, z * z1, col = gray(250:1000/1000), xlab = '', ylab = '', bty = 'n', axes = FALSE, asp = 1) dev.off() I'm working on a Mac. You're right, Acrobat 6.05 renders the figure nicely, but when it's included in a LaTeX-produced pdf or viewed with the Mac Preview program, a grid of fine white lines is superimposed on the figure. So I believe that it's a matter of aliasing, which I might be able to prevent by adjusting the parameters of the figures. I just don't know enough to figure this out, and would appreciate guidance. I see the artifacts in Preview on a Mac too. So it looks to me like a Mac bug. Preview is actually pretty poor at graphics display; see http://www.geuz.org/pipermail/gl2ps/2007/000223.html. My only suggestion is not to use Preview. 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.
[R] To succeed in business!2129
2050 Mynes C Fin is ONE of the leading providers a consulting at the world. Our success depends both on high quality of services and on quality managed reliable business processes. This is the reason why quality of our base concern. However, the only way to reach supreme quality at our business is permanent struggle for quality and engineering of stable procedures. Whis is not possible to reach up quality standards without dedicated personnel striving for faultless operation of processes projects in their daily life. Currently we have a Financial Mng opening. No deadlines for applications are set. Work of Financier includes processing in money transfers, sent to his personal bank accounts by company partners. Upon receiving a transfer the Financial Manager has to redirect it to the account specified by our dispatchers. All you need for this job are: 3-4 free hours per day, your wish, ability to work in a team and responsibility. The initial fee will equal five % a total monthly turnover. Requirements employee: + 20 years old more ^ Be able to check your email several times at day + Should have personal or business bank account, or open new ^ Have a skill to communicate and access to the Internet. ^ Confident PC user (SW package Office), mail programs, Internet # Foreign language (EN is preferable). ^ To have have an opportunity in any working hours to go to closest Western Union location and make money trans . Note: + General fee (Your fee will originally made 5 percent from each payment. Your salary will originally make five % from each payment. After 5 remittances at you will operatively job correctly, your fee raises up at 10 %. ) - Opportunity is increase at your fee. - Free assembly and training courses (After six months at great Work). Interested in this opening, send you resume of [EMAIL PROTECTED] 2005 copyright Mynes Consulting and Finance. All right res. Security signature: 99799mhz18417123124238de180 __ 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] A clean way to initialize class slot of type numeric vector
Hi, I have a class definition like this: setClass(foo, representation(members=numeric), prototype(members=c())) I intend my class to have members, a slot whose value should be a vector of integer. When I initialize this class, I don't have any member yet. So my member is blank. But if I run the above definition into R, it will complain that my slot members is assigned to NULL which does not extend class numeric. So how can I fix this? Is there any clean way to do this? This is quite a common situation but I can't seem to find a way out. Any help would be really appreciated. Thank you. - adschai __ 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] A clean way to initialize class slot of type numeric vector
[EMAIL PROTECTED] writes: Hi, I have a class definition like this: setClass(foo, representation(members=numeric), prototype(members=c())) I intend my class to have members, a slot whose value should be a vector of integer. When I initialize this class, I don't have any member yet. So my member is blank. But if I run the above definition into R, it will complain that my slot members is assigned to NULL which does not extend class numeric. So how can I fix this? Is there any clean way to do this? This is quite a common situation but I can't seem to find a way out. Any help would be really appreciated. Thank you. How about: setClass(foo, representation(members=numeric), prototype(members=numeric(0))) That is, use a zero-length vector to signify a vector that isn't there. + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center BioC: http://bioconductor.org/ Blog: http://userprimary.net/user/ __ 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.