[R] Weighted Multivariate Kernel density estimation with adaptative bandwidth
Bonjour, Est ce qu'il y a un package sous R qui permet de calculer la Kernel density estimation en 2 dimensions avec fentetre variable (calcul du bandwidth avec la méthode du kth nearest neighbor) et possibilité d'ajouter des poids (weight) j'ai cru savoir que le package "locfit" peut faire ceci mais je n'ai pas réussi à le faire Est ce que qq'un peut m'aider en me fournissant un exemple Merci [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] "Update in Mac OS"
Dear R-ers, I'm using R 2.7.1 Mac OS. What is the best way for update to 2.7.2 to keep my previous libraries? Fredrik Fredrik Lundgren [EMAIL PROTECTED] Obs! Ny adress och mail Engelbrektsgatan 31 582 21 Linköping 013 - 47 30 117 0706 - 86 39 29 Sommarhus: Ljungnäs 158 380 30 Rockneby 0480 - 650 98 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Sexy Little Number :-)-O
Got me the Asus EEE PC 1000 (the one with the 8 and 32 GIG solid state drives, and added a 4GiG SD for the swap space. Will add another Gig of RAM for a total of 2). Threw the old (Xandros) Linux off and the EEE specific Ubuntu 8.04.1 onto it. Got an atom Intel processor which apparently has two cores. Quite impressive... Does anyone know, off hand, how I set up the CRAN repository so it updates from the latest packages (2.7.2)? What happenend to the South African mirror by the way? greetings, el -- Dr. Eberhard W. Lisse \/ Obstetrician & Gynaecologist (Saar) [EMAIL PROTECTED] el108-ARIN / * | Telephone: +264 81 124 6733 (cell) PO Box 8421 \ / Please send DNS/NA-NiC related e-mail Bachbrecht, Namibia ;/ to [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Shadowed Plot
segun ogundimu wrote: Hello R-users Kindly assist me with the following plot problem in R- My data looks like this (shortened because I have about 5000 observations). dat <- read.table(textConnection("Id Time Y 1 0 194 1 5.22 179 1 5.97 190 2 1.61 265 2 2.1 234 2 16.4 300 2 29.5 345 3 0212 3 0.36 213 4 0199 4 1.23 203 5 0 212 5 13.5 216 6 0222 6 1.6 234" ), header = TRUE) closeAllConnections() The measurements are not taken at equal time points. I want to avoid overly cluttered plots in making individual profile. So, I will like the profile plot to appear grey (not completely visible) and about 30 randomly selected 'lucky subjects' to appear dark(very visible). Hi segun, Will this do the job? luckyones<-sample(unique(dat$Id),3) plot(dat$Time,dat$Y,type="n",main="The luck of the drawing",) for(subid in unique(dat$Id)) lines(dat$Time[dat$Id == subid],dat$Y[dat$Id == subid], col=ifelse(subid %in% luckyones,"black","lightgray")) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] "Update in Mac OS"
Hi Fredrik, Fredrik Lundgren wrote: Dear R-ers, I'm using R 2.7.1 Mac OS. What is the best way for update to 2.7.2 to keep my previous libraries? Not of immediate help: perhaps you could send your message to [EMAIL PROTECTED] Cheers, Ricardo -- Ricardo Rodríguez Your XEN ICT Team __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] color code from csv
kerfuffle wrote: hi folks, this is driving me up the wall. Apologies for posting twice in the same week, I'm writing up a thesis. I wish to color-code some dots in an xy plot. I've got a csv file with various elements, one of which is the color-key (with the header 'color'). If the color-key is decimal (eg. 1,2,3) then I can use plot (X ~ Y, col=data$color) The problem, however, is that using decimal numbers I can only produce 8 colors. It starts to recyle them after that (so, if possible values of my color column are 1,2,3,4,5,6,7,8,9,10,11, the values 1 and 9 both produce red, 2 and 10 produce black). However, I knew I could get more colors by using hexadecimal (tested with the legend) So, I carefully produced a csv file with hexadecimal values instead of decimal ones (eg. elements in the column are #ff, #ff) but if I use col=data$color it doesn't work, the entire plot is white. If I use these set of hexadecimal values in the legend, it works fine and I get lovely colors. Hi kerfuffle, You might want to look at color.scale in the plotrix package that transforms numeric values into colors as well as the rainbow function that Sarah mentioned. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Shadowed Plot
I'm Indeed grateful! The code did a perfect job. regards. --- On Sun, 10/5/08, Jim Lemon <[EMAIL PROTECTED]> wrote: From: Jim Lemon <[EMAIL PROTECTED]> Subject: Re: [R] Shadowed Plot To: [EMAIL PROTECTED] Cc: R-help@r-project.org Date: Sunday, October 5, 2008, 3:31 AM segun ogundimu wrote: > Hello R-users > > > Kindly assist me with the following plot problem in R- > My data looks like this (shortened because I have about 5000 observations). > > dat <- read.table(textConnection("Id Time Y > 1 0 194 > 1 5.22 179 > 1 5.97 190 > 2 1.61 265 > 2 2.1 234 > 2 16.4 300 > 2 29.5 345 > 3 0212 > 3 0.36 213 > 4 0199 > 4 1.23 203 > 5 0 212 > 5 13.5 216 > 6 0222 > 6 1.6 234" ), header = TRUE) > closeAllConnections() > > The measurements are not taken at equal time points. I want to avoid overly cluttered plots in making individual profile. So, I will like the profile plot to appear grey (not completely visible) and about 30 randomly selected 'lucky subjects' to appear dark(very visible). > Hi segun, Will this do the job? luckyones<-sample(unique(dat$Id),3) plot(dat$Time,dat$Y,type="n",main="The luck of the drawing",) for(subid in unique(dat$Id)) lines(dat$Time[dat$Id == subid],dat$Y[dat$Id == subid], col=ifelse(subid %in% luckyones,"black","lightgray")) Jim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] "Update in Mac OS"
Load the 2.7.2 mini DMBG and install over the top. Finish and klaar. el On 05 Oct 2008, at 11:28 , Fredrik Lundgren wrote: Dear R-ers, I'm using R 2.7.1 Mac OS. What is the best way for update to 2.7.2 to keep my previous libraries? Fredrik -- Dr. Eberhard W. Lisse \/ Obstetrician & Gynaecologist (Saar) [EMAIL PROTECTED] el108-ARIN / * | Telephone: +264 81 124 6733 (cell) PO Box 8421 \ / Please send DNS/NA-NiC related e-mail Bachbrecht, Namibia ;/ to [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sexy Little Number :-)-O
On 05-Oct-08 10:26:29, Dr Eberhard W Lisse wrote: > Got me the Asus EEE PC 1000 (the one with the 8 and 32 GIG solid state > drives, and added a 4GiG SD for the swap space. Will add another Gig > of RAM for a total of 2). Threw the old (Xandros) Linux off and the > EEE specific Ubuntu 8.04.1 onto it. Got an atom Intel processor which > apparently has two cores. Quite impressive... > > Does anyone know, off hand, how I set up the CRAN repository so it > updates from the latest packages (2.7.2)? > > What happenend to the South African mirror by the way? > > greetings, el I'll be interested in responses too! (Though mine is "only" the EEE PC 900, still a nice little thing). And in expereinces of replacing the Xandros with the Ubuntu. Meanwhile, I was tickled by your subject line, so could not resist: sexyNo<-function(){ for(i in (1:20)){ S<-paste(makeNstr(" ",i),"0",makeNstr(" ",(40-2*i)),"<--1\n",sep="") cat(S); Sys.sleep(1) } cat(paste(makeNstr(" ",21),"0~1\n",sep="")); Sys.sleep(2) for(i in (1:9)){ cat(paste(makeNstr(" ",22),"|\n",sep="")); Sys.sleep(2) } cat(" ***!!! 0.1 !!!***\n") } sexyNo() :-) Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 05-Oct-08 Time: 13:18:10 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [OOPS!]Sexy Little Number :-)-O
[OOPS! By oversight I perpetrated a show-stopper! (Overlooked that I already had Hmisc loaded). Corrected below] On 05-Oct-08 12:18:13, Ted Harding wrote: > On 05-Oct-08 10:26:29, Dr Eberhard W Lisse wrote: >> Got me the Asus EEE PC 1000 (the one with the 8 and 32 GIG solid state >> drives, and added a 4GiG SD for the swap space. Will add another Gig >> of RAM for a total of 2). Threw the old (Xandros) Linux off and the >> EEE specific Ubuntu 8.04.1 onto it. Got an atom Intel processor which >> apparently has two cores. Quite impressive... >> >> Does anyone know, off hand, how I set up the CRAN repository so it >> updates from the latest packages (2.7.2)? >> >> What happenend to the South African mirror by the way? >> >> greetings, el > > I'll be interested in responses too! (Though mine is "only" the > EEE PC 900, still a nice little thing). And in expereinces of > replacing the Xandros with the Ubuntu. > > Meanwhile, I was tickled by your subject line, so could not resist: library(Hmisc) sexyNo<-function(){ for(i in (1:20)){ S<-paste(makeNstr(" ",i),"0",makeNstr(" ",(40-2*i)),"<--1\n",sep="") cat(S); Sys.sleep(1) } cat(paste(makeNstr(" ",21),"0~1\n",sep="")); Sys.sleep(2) for(i in (1:9)){ cat(paste(makeNstr(" ",22),"|\n",sep="")); Sys.sleep(2) } cat(" ***!!! 0.1 !!!***\n") } sexyNo() >:-) > Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 05-Oct-08 Time: 13:49:49 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plyr package: passing further arguments fail
Dear list and Hadley, The new plyr package seems to provide a clean and consistent way to apply a function on several arguments. However, I don't understand why the following example does not work like the standard mapply, library(plyr) df <- data.frame(a=1:10 , b=1:10) foo1 <- function(a, b, cc=0, d=0){ a + b + cc + d } mdply(df, foo1, cc=1) # fine mdply(df, foo1, d=1) # fails mdply(df, foo1, cc=1, d=2) # fails mapply(foo1, a=df$a, b=df$b, MoreArgs=list(cc=1)) mapply(foo1, a=df$a, b=df$b, MoreArgs=list(d=1)) mapply(foo1, a=df$a, b=df$b, MoreArgs=list(cc=1, d=2)) Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cannot open connection: Authorization Required
Em Sex, 2008-10-03 às 11:22 -0700, Spencer Graves escreveu: > Hi, All: > > Is there a way in R to access a file / web site that requires > permission? > > Consider for example the following: > > > > readLines('http://www.r-project.org/', 4) > [1] "" > [2] "" > [3] "" > [4] "The R Project for Statistical Computing" > > > readLines(URL) # URL = web address, which I can see via manual access. > Error in file(con, "r") : cannot open the connection > In addition: Warning message: > In file(con, "r") : > cannot open: HTTP status was '401 Authorization Required' > > > Thanks, > Spencer Graves Spencer, this is a local problem in my system > > > readLines('http://www.r-project.org/') > [1] "" > > [2] "" > > [3] "" > > [4] "The R Project for Statistical Computing" > > [5] "" > > [6] " type=\"image/x-icon\">" > [7] "" > > [8] "" > > [9] "" > > [10] "" > > [11] "" > > [12] "" > > [13] "" > > [14] "" > > [15] "" > > [16] "" > > [17] "The R Project for Statistical Computing" > > [18] "" > > [19] "Your browser seems not to support frames," > > [20] "here is the contents page of the R > Project's" > [21] "website." > > [22] "" > > [23] "" > > [24] "" > > [25] "" > > [26] "" > I run R.2.7.2 in Ubuntu AMD 64 machine -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plyr package: passing further arguments fail
On Sun, Oct 5, 2008 at 8:02 AM, Auguie, Baptiste <[EMAIL PROTECTED]> wrote: > Dear list and Hadley, > > The new plyr package seems to provide a clean and consistent way to apply a > function on several arguments. However, I don't understand why the following > example does not work like the standard mapply, > > library(plyr) > df <- data.frame(a=1:10 , b=1:10) > > foo1 <- function(a, b, cc=0, d=0){ >a + b + cc + d > } > > mdply(df, foo1, cc=1) # fine > > mdply(df, foo1, d=1) # fails > mdply(df, foo1, cc=1, d=2) # fails Unfortunately this bug is R's partial name matching: d = 2 -> data. = 2. You should be able to fix this by manually specifying mdply(data. = df, foo1, cc=1, d=2) but there are some bugs in the current version that prevent this from happening. I've fixed this in the development version, available from http://github.com/hadley/plyr (click the download link) However, the whole point of plyr is that you should have to think about this kind of thing, so I'll revisit my naming scheme - probably to use . prefixes instead of suffixes. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package for stochastic frontier models?
Hi Aaron! I hope that my answer is not too late. On Friday 30 May 2008 00:31, aaront wrote: > I need to estimate maximum tree crown radius and am looking for a package > to prepare stochastic frontier models in R. I have not found any package > references on Nabble R help, google, or R help. Any tips on a package for > this? The "micEcon" package [1,2,3] provides the functions "front41WriteInput" and "front41ReadOutput", which write input files and read output files for Tim Coelli's FRONTIER 4.1 software, respectively. This software does stochastic frontier analysis. A slightly modified version of it, which can be run non-interactively [5], can be used to estimate frontier functions in R with the micEcon package pretty conveniently. Furthermore, I have created an R package "frontier" [5] that includes and uses the Fortran code of FRONTIER 4.1 as dynamic library. However, this package has not been thoroughly tested yet and I haven't received a permission of the author of FRONTIER 4.1 to release the package under an open source license and/or to upload it to CRAN (provisionally, he permitted me to make this software available on my website [5]). I am happy to receive bug (and success!) reports for this new package. (If somebody creates binary packages for MS-Windows and MacOS X, I would be happy to receive them to make them available also on my web site [5] :-) ). [1] http://www.micecon.org/ [2] http://cran.r-project.org/web/packages/micEcon/index.html [3] http://r-forge.r-project.org/projects/micecon/ [4] http://www.uq.edu.au/economics/cepa/frontier.htm [5] http://www.uni-kiel.de/agrarpol/ahenningsen/frontier/index.html Best wishes, Arne > With regards, > > Aaron Trowbridge > > Researcher > BV Research Centre > Smithers B.C. -- Arne Henningsen http://www.arne-henningsen.name __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] efficient use of lm over a matrix vs. using apply over rows
I have a large matrix, each row of which needs lm applied. I am certain than I read an article in R-news about this within the last year or two that discussed the application of lm to matrices but I'll be darned if I can find it with Google. Probably using the wrong search terms. Can someone steer me to this article of just tell me if this is possible and, if so, how to do it? My simplistic attempts have failed. 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) 399-1219 Home Skype: mkimpel ** [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] efficient use of lm over a matrix vs. using apply over rows
On 05/10/2008 10:08 AM, Mark Kimpel wrote: I have a large matrix, each row of which needs lm applied. I am certain than I read an article in R-news about this within the last year or two that discussed the application of lm to matrices but I'll be darned if I can find it with Google. Probably using the wrong search terms. Can someone steer me to this article of just tell me if this is possible and, if so, how to do it? My simplistic attempts have failed. You don't give a lot of detail on what you mean by applying lm to a row of a matrix, but I'll assume you have fixed predictor variables, and each row is a different response vector. Then you can use apply() like this: x <- 1:10 mat <- matrix(rnorm(200), nrow=20, ncol=10) resultlist <- apply(mat, 1, function(y) lm(y ~ x)) resultcoeffs <- apply(mat, 1, function(y) lm(y ~ x)$coefficients) "resultlist" will contain a list of 20 different lm() results, "resultcoeffs" will be a matrix holding just the coefficients. lm() also allows the response to be a matrix, where the columns are considered different components of a multivariate response. So if you transpose your matrix you can do it all in one call: resultmulti <- lm(t(mat) ~ x) The coefficients of resultmulti will match resultcoeffs. Duncan Murdoch Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [OOPS!]Sexy Little Number :-)-O
Ok, I give up: what's that supposed to look like? I tried to replace makeNstr with paste(rep(..)) but got garbage. (my own fault: I still like 10.3.9, so can't install a new enough version of R to install the Hmisc package) Carl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] ggplot2 - version 0.7
ggplot2 ggplot2 is a plotting system for R, based on the grammar of graphics, which tries to take the good parts of base and lattice graphics and avoid bad parts. It takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce complex multi-layered graphics. Find out more at http://had.co.nz/ggplot2, and check out the nearly 500 examples of ggplot in use. ggplot2 0.7 introduces a new theming system which allows you to control (almost) every aspect of the appearance of the plot. This system is documented in the book chapter "Polishing your plots for publication", available from http://had.co.nz/ggplot2/book/polishing.pdf. Bugs fixed * geom_boxplot: now displays outliers even if only one present * geom_jitter: setting one jitter direction to 0 now works * geom_segment: should now work correctly in all coordinate systems (note that arrows only work in Cartesian coordinates) * ggsave: correctly uses dpi for raster devices and default dpi changed to 72 (thanks to Brian Ripley for pointing this out) * ggsave: current device no longer closes if error occurs * position_jitter: now works correctly with 0 jitter * remove_missing: some statistics were calculated incorrectly when missing values were present * scales: extra scales ignored (again) * scales: legends respect fixed parameters of the layer * scales: legends won't appear when aesthetics are mapped to NULL, or set to fixed value * scales: xend and yend now transformed correctly * scale_date: breaks are now rounded to correct position New functionality * geom_point: can now control colour and fill separately for point glyphs with borders * geom_step: now has parameter direction which can take values vh (vertical then horizontal) or hv (horizontal then vertical) describing the shape of the stairs * qplot: new asp argument to set aspect ratio * qplot: now captures the environment in which it was run, which should make it much more robust at finding the variables you expect it to find * qplot: now treats any arguments wrapped in I() as parameters, not aesthetics, e.g. qplot(mpg, wt, data=mtcars, colour = I("red")) or qplot(mpg, wt, data=mtcars, size = I(5)) * scale_continuous: new minor_breaks argument to controls position of minor breaks * scale_discrete: new discrete position scales which make it possible to manually position elements * scale_gradientn: new colour scale which creates gradient between any list of colours More consistent interfaces * can use color instead of colour, and old R names throughout ggplot2 * geom_jitter: Arguments changed to height and width to match other position adjustments * scales: any point outside of limits is dropped (this was previously the behaviour for discrete scales, but not continuous scales) * scales: limits are consistent across discrete and continuous scales (limits c(1, NA) form no longer works for continuous scales) * scales: order of legends reversed to match order of x axis (and to be consistent with previous versions) * scale_date: new limits argument to set axis limits * scale_discrete: all discrete scales accept breaks argument * scale_discrete: all discrete scales have limits and labels argument to better control legends * scale_discrete: character and logical vectors now reliably treated as discrete scales * stat_density2d, geom_density2d: density2d used consistently (instead of density_2d in some places) Improved aesthetics * coord_polar: more tweaks to grid lines to enhance appearance * coord_polar: new expand argument to control whether axes should be expanded outside the range of the data * geom_contour, geom_smooth, geom_quantile: now use blue lines * position_stack, position_dodge: should be more informative if conditions for stacking/dodging not met * position_jitter: default amount of jittering tweaked to align with boxplots etc. * scales: background colour of legends key matches plot * themes: Complete rewrite of theming system, see new book chapter for details * themes: direct access to plot options via $ is now disabled Improved documentation and error messages * facet_grid: documentation improved * qplot: Better error messages when needed variables are missing * scale_discrete: improved error message for too many values in domain * scale_size: improved documentation for discrete variables * online documentation generally tweaked and primped to work a little better and look a little nicer * website now includes a search box * links from rdoc now point to correct pages -- http://had.co.nz/ ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/postin
Re: [R] [OOPS!]Sexy Little Number :-)-O
2008/10/5 Ted Harding <[EMAIL PROTECTED]>: > sexyNo() How puerile. R should be used for serious purposes. Here is a plot that shows a log-log-log feasible region symmetric about x=0, within a sinusoidal left and right-bound envelope: # set up plot xrange=c(-15,15) yrange=c(0,16) plot(0,xlim=xrange,ylim=yrange,type='n') # draw outer envelope yr=seq(yrange[1],yrange[2],len=50) offsetFn=function(y){2*sin(0+y/3)} offset=offsetFn(yr) leftE = function(y){-10-offsetFn(y)} rightE = function(y){10+offsetFn(y)} xp=c(leftE(yr),rev(rightE(yr))) yp=c(yr,rev(yr)) polygon(xp,yp,col="#ffeecc",border=NA) #abline(v=0) # feasible region upper limit: h=9 # left and right defined by triple-log function: xt=seq(0,rightE(h),len=100) yt=log(1+log(1+log(xt+1))) yt=yt-min(yt) yt=h*yt/max(yt) x=c(leftE(h),rightE(h),rev(xt),-xt) y=c(h,h,rev(yt),yt) polygon(x,y,col="red",border=NA) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] building packages: "R Help for package foo" vs. "HTML Help"?
In building a package, what are the settings in the package files or the build commands that determine whether the compiled HTML help windows have the window title "R Help for package foo" vs. "HTML Help"? I often have quite a few help files active, and it is much more convenient to navigate among them if the window has an informative title. If this is simple to test for in the build process, can/should this be tested for (with a warning) or even enforced/automatically generated in the scripts? -Michael -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] barchart for aggregated (sum) data in lattice?
Hi list, I have data in a dataframe t1, with a column for different amounts spent, a column what it was spent on, and a column with dates, from which I create a new column with months. Example: amount <- rep(c(10,20,30),3) what <- rep(c("food","books","cycling"),3) when <- c(rep("2008-09-05",5),rep("2008-10-07",4)) t1 <- data.frame(amount,what,when) t1$when <- as.Date(t1$when) t1$month <- format(as.Date(t1$when),"%b") I want to have a barplot for each month, showing the sum spent in the different categories. I figured I can do this with traditional graphics using: barplot(xtabs(amount~what+month, data=t1),beside=T) But I'd like to be able to do this in lattice. I tried: barchart(amount~what|month,t1) But that doesn't sum the data for t1$amount for each month first. How could I do that? Thanks, Marianne -- Marianne Promberger Graduate student in Psychology http://www.psych.upenn.edu/~mpromber __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Number format in log-scaled lattice xyplots
Thanks - I wasn't thinking about it the right way, and I didn't know where to focus my investigation of the examples. Thank you very much for pointing me at the specific example that solved my problem. For others who might have the same question, that would be the part of the example that transforms the label values using 2^value, which turns the label from something that looks like "2^3" into an actual 8. Actually, other parts of the example are also very enlightening for other useful things to do with tick labels. Brian -Original Message- From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Sent: Saturday, October 04, 2008 6:53 PM To: Desany, Brian {454_~Branford} Cc: r-help@r-project.org Subject: Re: [R] Number format in log-scaled lattice xyplots On 10/4/08, Desany, Brian <[EMAIL PROTECTED]> wrote: > For a non-log-scaled y-axis, I was able to change the appearance of the > y tick labels in an xyplot by using a custom function for > yscale.components. However I couldn't get that approach to work for when > scales=list(y=list(log=TRUE)). > > What I'm trying to do is make the y-tick labels show up as something > like (10, 100, 1000, etc.) rather than the default (10^1.0, 10^2.0, > 10^3.0, etc.). Doesn't the first (densityplot) example in ?yscale.components.default do this? Other relevant examples are http://lmdvr.r-forge.r-project.org/figures/figures.html?chapter=08;figur e=08_04 and http://lmdvr.r-forge.r-project.org/figures/figures.html?chapter=08;figur e=08_05 -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] efficient use of lm over a matrix vs. using apply over rows
Sorry for the vagueness of my question, your interpretation, however, was spot on. Correct me if I am wrong, but my impression is that apply is a more compact way of a for loop, but that the way R handles them computationally are the same. In the article I seem to remember, there was a significant increase in speed with your second approach, presumably because function calls are avoided in R and the heavy lifting is done in C. I will use your second approach anyway, but can I expect increased computational efficiency with it and, if so, is my reasoning in the prior sentence correct? BTW, it appears as though my own attempt was almost correct, but I did not transpose the matrix. In genomics, our response variables (genes) are the rows and the predictor values are the column names. The BioConductor packages I routinely use are very good at hiding this and I just didn't come to mind. 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) 399-1219 Home Skype: mkimpel ** On Sun, Oct 5, 2008 at 10:28 AM, Duncan Murdoch <[EMAIL PROTECTED]>wrote: > On 05/10/2008 10:08 AM, Mark Kimpel wrote: > >> I have a large matrix, each row of which needs lm applied. I am certain >> than >> I read an article in R-news about this within the last year or two that >> discussed the application of lm to matrices but I'll be darned if I can >> find >> it with Google. Probably using the wrong search terms. >> >> Can someone steer me to this article of just tell me if this is possible >> and, if so, how to do it? My simplistic attempts have failed. >> > > You don't give a lot of detail on what you mean by applying lm to a row of > a matrix, but I'll assume you have fixed predictor variables, and each row > is a different response vector. Then you can use apply() like this: > > x <- 1:10 > mat <- matrix(rnorm(200), nrow=20, ncol=10) > > resultlist <- apply(mat, 1, function(y) lm(y ~ x)) > resultcoeffs <- apply(mat, 1, function(y) lm(y ~ x)$coefficients) > > > "resultlist" will contain a list of 20 different lm() results, > "resultcoeffs" will be a matrix holding just the coefficients. > > lm() also allows the response to be a matrix, where the columns are > considered different components of a multivariate response. So if you > transpose your matrix you can do it all in one call: > > resultmulti <- lm(t(mat) ~ x) > > The coefficients of resultmulti will match resultcoeffs. > > Duncan Murdoch > > Duncan Murdoch > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plyr package: passing further arguments fails
I've found a temporary workaround that may be useful to nail down the problem (if problem there is), If I quote() each additional argument to be passed to fun., everything works fine: df <- data.frame(a=1:10 , b=1:10) foo1 <- function(a, b, cc=0, d=0){ a + b + cc + d } mdply(df, foo1, cc=1, d=2) # obscure (to me) failure mdply(df, foo1, quote(cc=1), quote(d=2)) Best wishes, baptiste From: Auguie, Baptiste Sent: 05 October 2008 14:02 To: r-help@r-project.org Cc: [EMAIL PROTECTED] Subject: plyr package: passing further arguments fail Dear list and Hadley, The new plyr package seems to provide a clean and consistent way to apply a function on several arguments. However, I don't understand why the following example does not work like the standard mapply, library(plyr) df <- data.frame(a=1:10 , b=1:10) foo1 <- function(a, b, cc=0, d=0){ a + b + cc + d } mdply(df, foo1, cc=1) # fine mdply(df, foo1, d=1) # fails mdply(df, foo1, cc=1, d=2) # fails mapply(foo1, a=df$a, b=df$b, MoreArgs=list(cc=1)) mapply(foo1, a=df$a, b=df$b, MoreArgs=list(d=1)) mapply(foo1, a=df$a, b=df$b, MoreArgs=list(cc=1, d=2)) Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [SOLVED] barchart for aggregated (sum) data in lattice?
Arrgh. I spent so long fiddling with this, and two minutes after I mail to the list I find the solution. barchart(xtabs(amount~month+what, data=t1),stack=F,auto.key=T) (It took me a long time to discover the extended xtabs formula, and before I had kept trying to combine xtabs with the "|" factor notation in lattice, like barchart(xtabs(amount~what)|month or so. Sorry for the clutter. m. On Sunday, 05 October 2008, 18:12 (UTC+0100), Marianne Promberger wrote: > Hi list, > > I have data in a dataframe t1, with a column for different amounts > spent, a column what it was spent on, and a column with dates, from > which I create a new column with months. > > Example: > > amount <- rep(c(10,20,30),3) > what <- rep(c("food","books","cycling"),3) > when <- c(rep("2008-09-05",5),rep("2008-10-07",4)) > t1 <- data.frame(amount,what,when) > t1$when <- as.Date(t1$when) > t1$month <- format(as.Date(t1$when),"%b") > > I want to have a barplot for each month, showing the sum spent in the > different categories. > > I figured I can do this with traditional graphics using: > > barplot(xtabs(amount~what+month, data=t1),beside=T) > > But I'd like to be able to do this in lattice. > > I tried: > > barchart(amount~what|month,t1) > > But that doesn't sum the data for t1$amount for each month first. > > How could I do that? > > Thanks, > > Marianne > > -- > Marianne Promberger > Graduate student in Psychology > http://www.psych.upenn.edu/~mpromber > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Marianne Promberger Graduate student in Psychology http://www.psych.upenn.edu/~mpromber PGP/GnuPG public key: http://promberger.info/mpromber-pgp.asc __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] efficient use of lm over a matrix vs. using apply over rows
Sorry, I missed the fact that Duncan had this solution as well at the end of his response. On Sun, Oct 5, 2008 at 1:31 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > In that case, using the example data from the prior response all you need > is: > > coef(lm(t(mat) ~ x)) > > > On Sun, Oct 5, 2008 at 1:18 PM, Mark Kimpel <[EMAIL PROTECTED]> wrote: >> Sorry for the vagueness of my question, your interpretation, however, was >> spot on. Correct me if I am wrong, but my impression is that apply is a more >> compact way of a for loop, but that the way R handles them computationally >> are the same. In the article I seem to remember, there was a significant >> increase in speed with your second approach, presumably because function >> calls are avoided in R and the heavy lifting is done in C. I will use your >> second approach anyway, but can I expect increased computational efficiency >> with it and, if so, is my reasoning in the prior sentence correct? >> >> BTW, it appears as though my own attempt was almost correct, but I did not >> transpose the matrix. In genomics, our response variables (genes) are the >> rows and the predictor values are the column names. The BioConductor >> packages I routinely use are very good at hiding this and I just didn't come >> to mind. >> >> 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) 399-1219 Home >> Skype: mkimpel >> >> ** >> >> >> On Sun, Oct 5, 2008 at 10:28 AM, Duncan Murdoch <[EMAIL PROTECTED]>wrote: >> >>> On 05/10/2008 10:08 AM, Mark Kimpel wrote: >>> I have a large matrix, each row of which needs lm applied. I am certain than I read an article in R-news about this within the last year or two that discussed the application of lm to matrices but I'll be darned if I can find it with Google. Probably using the wrong search terms. Can someone steer me to this article of just tell me if this is possible and, if so, how to do it? My simplistic attempts have failed. >>> >>> You don't give a lot of detail on what you mean by applying lm to a row of >>> a matrix, but I'll assume you have fixed predictor variables, and each row >>> is a different response vector. Then you can use apply() like this: >>> >>> x <- 1:10 >>> mat <- matrix(rnorm(200), nrow=20, ncol=10) >>> >>> resultlist <- apply(mat, 1, function(y) lm(y ~ x)) >>> resultcoeffs <- apply(mat, 1, function(y) lm(y ~ x)$coefficients) >>> >>> >>> "resultlist" will contain a list of 20 different lm() results, >>> "resultcoeffs" will be a matrix holding just the coefficients. >>> >>> lm() also allows the response to be a matrix, where the columns are >>> considered different components of a multivariate response. So if you >>> transpose your matrix you can do it all in one call: >>> >>> resultmulti <- lm(t(mat) ~ x) >>> >>> The coefficients of resultmulti will match resultcoeffs. >>> >>> Duncan Murdoch >>> >>> Duncan Murdoch >>> >> >>[[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Time Interval calculation using R
Seems to work fine for me: > times <- c("10:12:34", "14:23:15") > Ptime <- as.POSIXct(strptime(times, "%H:%M:%S")) > > Ptime [1] "2008-10-05 10:12:34 GMT" "2008-10-05 14:23:15 GMT" > difftime(Ptime[2], Ptime[1], units='min') Time difference of 250.6833 mins > You just have to be careful that all your times are for the same day since you do not have a 'date' associated with the time. On Sun, Oct 5, 2008 at 1:25 AM, Gouri Shankar Mishra <[EMAIL PROTECTED]> wrote: > Hi > > I have two columns of data with time in form of HH:MM:SS - representing > start time and end time of an activity. I am trying to calculate the time > difference (duration of the activity). > > (1) I first tried >> difftime(btime, etime, units = "mins") > This however gave me the error - Error in > as.POSIXlt.character(as.character(x)) : character string is not in a > standard unambiguous format > > (2) The above error message indicated some problem in format. So I tried >> etime1=as.date(etime, %H:%M:%S") > This gave me the Error: unexpected SPECIAL in "etime1=as.date(etime, %H:%" > > I also tried >>etime1=format(etime, %H:%M:%S") > But this gave a similar error - unexpected SPECIAL in "etime1=format(etime, > %H:%" > > Any suggestions? > > Regards > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] efficient use of lm over a matrix vs. using apply over rows
In that case, using the example data from the prior response all you need is: coef(lm(t(mat) ~ x)) On Sun, Oct 5, 2008 at 1:18 PM, Mark Kimpel <[EMAIL PROTECTED]> wrote: > Sorry for the vagueness of my question, your interpretation, however, was > spot on. Correct me if I am wrong, but my impression is that apply is a more > compact way of a for loop, but that the way R handles them computationally > are the same. In the article I seem to remember, there was a significant > increase in speed with your second approach, presumably because function > calls are avoided in R and the heavy lifting is done in C. I will use your > second approach anyway, but can I expect increased computational efficiency > with it and, if so, is my reasoning in the prior sentence correct? > > BTW, it appears as though my own attempt was almost correct, but I did not > transpose the matrix. In genomics, our response variables (genes) are the > rows and the predictor values are the column names. The BioConductor > packages I routinely use are very good at hiding this and I just didn't come > to mind. > > 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) 399-1219 Home > Skype: mkimpel > > ** > > > On Sun, Oct 5, 2008 at 10:28 AM, Duncan Murdoch <[EMAIL PROTECTED]>wrote: > >> On 05/10/2008 10:08 AM, Mark Kimpel wrote: >> >>> I have a large matrix, each row of which needs lm applied. I am certain >>> than >>> I read an article in R-news about this within the last year or two that >>> discussed the application of lm to matrices but I'll be darned if I can >>> find >>> it with Google. Probably using the wrong search terms. >>> >>> Can someone steer me to this article of just tell me if this is possible >>> and, if so, how to do it? My simplistic attempts have failed. >>> >> >> You don't give a lot of detail on what you mean by applying lm to a row of >> a matrix, but I'll assume you have fixed predictor variables, and each row >> is a different response vector. Then you can use apply() like this: >> >> x <- 1:10 >> mat <- matrix(rnorm(200), nrow=20, ncol=10) >> >> resultlist <- apply(mat, 1, function(y) lm(y ~ x)) >> resultcoeffs <- apply(mat, 1, function(y) lm(y ~ x)$coefficients) >> >> >> "resultlist" will contain a list of 20 different lm() results, >> "resultcoeffs" will be a matrix holding just the coefficients. >> >> lm() also allows the response to be a matrix, where the columns are >> considered different components of a multivariate response. So if you >> transpose your matrix you can do it all in one call: >> >> resultmulti <- lm(t(mat) ~ x) >> >> The coefficients of resultmulti will match resultcoeffs. >> >> Duncan Murdoch >> >> Duncan Murdoch >> > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] building packages: "R Help for package foo" vs. "HTML Help"?
Michael Friendly wrote: In building a package, what are the settings in the package files or the build commands that determine whether the compiled HTML help windows have the window title "R Help for package foo" vs. "HTML Help"? Michael, can you give an example for a page with title "HTML Help"? I only found the "R Help for package foo" version during a quick inspection of a few examples. Best wishes, Uwe I often have quite a few help files active, and it is much more convenient to navigate among them if the window has an informative title. If this is simple to test for in the build process, can/should this be tested for (with a warning) or even enforced/automatically generated in the scripts? -Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] building packages: "R Help for package foo" vs. "HTML Help"?
Uwe Ligges wrote: Michael Friendly wrote: In building a package, what are the settings in the package files or the build commands that determine whether the compiled HTML help windows have the window title "R Help for package foo" vs. "HTML Help"? Michael, can you give an example for a page with title "HTML Help"? I only found the "R Help for package foo" version during a quick inspection of a few examples. Sure: library(vcd); ?mosaic library(heplots); ?heplot library(car); ?Anova library(rgl); ?shade3d # --- I believe up until just the latest version (rgl_0.81.708) I downloaded from R-Forge Here's my sessionInfo: > sessionInfo() R version 2.7.2 (2008-08-25) 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] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] vcd_1.1-1 colorspace_0.95 MASS_7.2-44 rgl_0.81.708 [5] heplots_0.8-0 car_1.2-8 I often have quite a few help files active, and it is much more convenient to navigate among them if the window has an informative title. If this is simple to test for in the build process, can/should this be tested for (with a warning) or even enforced/automatically generated in the scripts? -Michael -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [SOLVED] barchart for aggregated (sum) data in lattice?
You can also do it with ggplot2: install.packages("ggplot2") library(ggplot2) qplot(month, weight = amount, fill = what, data=t1, geom="bar") You can find out more at http://had.co.nz/ggplot2 (And you probably want to set the levels of the months so they don't appear in alphabetical order) Hadley On Sun, Oct 5, 2008 at 12:32 PM, Marianne Promberger <[EMAIL PROTECTED]> wrote: > Arrgh. I spent so long fiddling with this, and two minutes after I mail > to the list I find the solution. > > barchart(xtabs(amount~month+what, data=t1),stack=F,auto.key=T) > > (It took me a long time to discover the extended xtabs formula, and > before I had kept trying to combine xtabs with the "|" factor notation > in lattice, like barchart(xtabs(amount~what)|month or so. > > Sorry for the clutter. > m. > > > > On Sunday, 05 October 2008, 18:12 (UTC+0100), Marianne Promberger wrote: >> Hi list, >> >> I have data in a dataframe t1, with a column for different amounts >> spent, a column what it was spent on, and a column with dates, from >> which I create a new column with months. >> >> Example: >> >> amount <- rep(c(10,20,30),3) >> what <- rep(c("food","books","cycling"),3) >> when <- c(rep("2008-09-05",5),rep("2008-10-07",4)) >> t1 <- data.frame(amount,what,when) >> t1$when <- as.Date(t1$when) >> t1$month <- format(as.Date(t1$when),"%b") >> >> I want to have a barplot for each month, showing the sum spent in the >> different categories. >> >> I figured I can do this with traditional graphics using: >> >> barplot(xtabs(amount~what+month, data=t1),beside=T) >> >> But I'd like to be able to do this in lattice. >> >> I tried: >> >> barchart(amount~what|month,t1) >> >> But that doesn't sum the data for t1$amount for each month first. >> >> How could I do that? >> >> Thanks, >> >> Marianne >> >> -- >> Marianne Promberger >> Graduate student in Psychology >> http://www.psych.upenn.edu/~mpromber >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > -- > Marianne Promberger > Graduate student in Psychology > http://www.psych.upenn.edu/~mpromber > PGP/GnuPG public key: http://promberger.info/mpromber-pgp.asc > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Graph in vector format to OpenOffice
Hello, I know this topic has been discussed already several times. Is it a workable solution that emerged? I would like to place R graph in vector format in an OpenOffice Writer document (solution working in Linux AND Mac OS X AND Windows). I have tried to play with pstoedit to convert .ps file produced by R into .svm, .dxf, etc... but without success. PhG -- ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Graph in vector format to OpenOffice
Philippe Grosjean wrote: > I know this topic has been discussed already several times. Is it a > workable solution that emerged? I would like to place R graph in vector > format in an OpenOffice Writer document (solution working in Linux AND > Mac OS X AND Windows). I have tried to play with pstoedit to convert .ps > file produced by R into .svm, .dxf, etc... but without success. Just use the SVG device instead of the postscript one. OpenOffice Draw can load and edit SVG files. If you want to do more complicated editing of SVG files, give Inkscape a try. Simon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plot3d - could not find function "xlim"
when I tried to apply xlim, ylim, zlim functions to the plot3d/decorate3d, inspite all the help documentation I got this errormessage: ERROR: could not find function "xlim" Is it a bug or possibly my fault? regards tomas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 mix different font styles in axis label of lattice plot?
Hi Judith Flores wrote: > Hello, > > I have a y-axis label that reads: "S. schenckii yeast cells". The > part that reads "S. schenckii" needs to be in italic style, the rest > of the text is normal style. How can I specify the different font > styles for each part of the y-axis label? You can use R's 'plotmath' facility to do this ... plot(1, ylab=expression(paste(italic("S. schenckii"), " yeast cells"))) Paul > Thank you, > > Judith > > __ R-help@r-project.org > mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot3d - could not find function "xlim"
Seems to work fine for me: plot3d(x, y, z, col=rainbow(1000), size=2, xlim=c(-5,5)) It would help if you "read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code." Since you did not post your code, I assume that there is an unknown error in it. On Sun, Oct 5, 2008 at 1:32 PM, Tomas Lanczos <[EMAIL PROTECTED]> wrote: > when I tried to apply xlim, ylim, zlim functions to the plot3d/decorate3d, > inspite all the help documentation I got this errormessage: > > ERROR: could not find function "xlim" > > Is it a bug or possibly my fault? > > regards > > tomas > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Conditioning variables in lattice - not all combinations
Hello, I have a shingle A and B. A has 5 levels and B has 4 levels. Also, I have 8 levels of a factor C. I wish to xyplot( x ~ y | C *A *B,data=data), I think this is how the lattice conditioning works: If i'm not mistaken, all possible combinations of C,A,B , a subset of the data is accordingly taken and x~y is plotted. However, I have empty sets for some levels and these are plotted as empty panels. (e.g for A=1, there are only 2 levels of B). (I saw the solution A:B on the mailing list, which does not work in my case, since I'd like the multi-level strip titles.) Is there a way to solve this? Also, each level of C appears in exactly one combination of A and B (the combinations that appear in the data set, not the ones produced by lattice) Kind regards Saptarshi Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] trouble with character \u00e2
Greetings R-wizards: For historical reasons I have filenames with the character "â" and have successfully used "\u00e2" in its place, with the hoped-for result on all my on-screen plots. However since R2.7.0 I have trouble with savePlot() when the file name includes that character as it does in this example: savePlot(paste("diagnostic â vs a ", file.label, ".jpg", sep = ""), type = "jpg") In R2.6.0 and earlier, R would ignore a dot ('.') in the file name and supply the extension. Since R2.7.0 if filename does include a dot, savePlot() will not add the file type as an extension. Thus my apparent redundancy in the file name. The problem I have is that the example command will substitute an unwanted character for â, yet if I use "File, save as, jpg ... " and type in a name containing the troublesome character, R saves the on-screen plot with that character in the name with no complaints. I have tried using iconv() with no success, as can be seen with the following code: file.name <- paste("diagnostic â vs a ", file.label, ".jpg", sep = "") iconv.List <- iconvlist() for(encoding in iconv.List) { print(iconv(file.name, "", encoding, ""))} So, here's the question: How can I save, with a non-interactive R command, an existing plot with the troublesome character in the file name? Thanks. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot3d - could not find function "xlim"
On 6/10/2008, at 6:32 AM, Tomas Lanczos wrote: when I tried to apply xlim, ylim, zlim functions to the plot3d/decorate3d, inspite all the help documentation I got this errormessage: ERROR: could not find function "xlim" Is it a bug or possibly my fault? (a) RTFM. (b) Read the posting guide. (c) xlim is not a function; it is an *argument* (to the plot3d() function. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Conditioning variables in lattice - not all combinations
On 10/5/08, Saptarshi Guha <[EMAIL PROTECTED]> wrote: > Hello, > I have a shingle A and B. A has 5 levels and B has 4 levels. > Also, I have 8 > levels of a factor C. I wish to xyplot( x ~ y | C *A *B,data=data), > > I think this is how the lattice conditioning works: > If i'm not mistaken, all possible combinations of C,A,B > , a subset of the data is accordingly taken and x~y is plotted. > However, I > have empty sets for some levels and these are plotted as empty panels. > (e.g for A=1, there are only 2 levels of B). > > (I saw the solution A:B on the mailing list, which does not work in my > case, since I'd like the multi-level strip titles.) With some simple string manipulation, you should be able to write a strip function that reproduces multi-level annotation even with interactions. > Is there a way to solve this? No. Your situation is analogous to a matrix (or array) with NA entries. You cannot omit NA cells without omitting entire rows or columns (margins). On the other hand, you can convert the array into a vector (analogous to conditioning on A:B:C) and then omit individual NA cells. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot3d - could not find function "xlim"
On Sun, 05 Oct 2008 19:32:41 +0200 Tomas Lanczos wrote: TL> when I tried to apply xlim, ylim, zlim functions to the TL> plot3d/decorate3d, inspite all the help documentation I got this TL> errormessage: TL> TL> ERROR: could not find function "xlim" TL> TL> Is it a bug or possibly my fault? More probably the latter one but hard to tell without any example. Thats why: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. is attached to mails... Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Sample mean in R
I am having issues with the following: (muhat = 1/n^2(sum of all the xi's) ) essentially if xbar = the sample mean, muhat = sample mean but square the n. Question: Use R to run a Monte Carlo simulation which compares the finite-sample performance of xbar and muhat. Specifically generate 1000 samples n=30 from a standard normal distribution. For each sample calculate xbar and muhat. I have no problem calculating the mean of the xbar's - however I cannot figure out how to set up the muhat variable and find the means. My code is as follows: # R code starts here rm(list=ls()) set.seed(100) n<-30 s<-1000 xbar<-rep(0,s) muhat<-rep(0,s) for (i in 1:s) { x<-rnorm(0,n=10) xbar[i]<-mean(x) muhat[i]<-mean(x^(-1/2)) } cat("Estimated mean of xbar:",mean(xbar),"\n") cat("Estimated mean of muhat:",mean(muhat),"\n") Any help would be greatly appreciated. -- View this message in context: http://www.nabble.com/Sample-mean-in-R-tp19828546p19828546.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the meaning of "segfault 'memory not mapped' " ?
On Fri, 3 Oct 2008, Ubuntu.Diego wrote: I'm trying to get some "easy coding" to reproduce the error. In the meantime I have R code that run for 20 or more hours and suddenly i got a "segfault 'memory not mapped'" error. I have to clarify that the error not alway occurs and sometimes the process end satisfactorily. The process is basically a search using an MCMC strategy, sometimes the algorithm converge and stops others I got the error message. I was wondering if it could be meaning that I run out of RAM. The 'memory not mapped' error means that your code is reading from or writing to memory that it doesn't own. This should have nothing to do with running out of RAM. If this is pure R code you have found a bug in R. If you are calling your own C code it is more likely to be a bug there. If your C code uses PROTECT/UNPROTECT it is even more likely to be there. Usually the best way to track down these bugs is to run the code under Valgrind, but this is slow, which will be a problem for code that already takes many hours. If you are extremely lucky, the crash will have happened on the first incorrect memory access. Running R under a debugger such as gdb you can use backtrace after the crash occurs to find where the bug happened. Unfortunately it is quite likely that the crash happened because some earlier piece of code overwrote a stored variable or something similar. The fact that the segfault occurs only some of the time reinforces this, especially if you don't always get the crash even with the same sequence of random numbers. If you have a Linux computer that you can use for a week or so it would be worth running your code under Valgrind to see if it finds the problem. -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sample mean in R
On 05-Oct-08 20:00:00, dilian wrote: > I am having issues with the following: > > (muhat = 1/n^2(sum of all the xi's) ) > > essentially if xbar = the sample mean, muhat = sample mean but square > the n. > > Question: > Use R to run a Monte Carlo simulation which compares the finite-sample > performance of xbar and muhat. Specifically generate 1000 samples n=30 > from a standard normal distribution. For each sample calculate xbar and > muhat. I have no problem calculating the mean of the xbar's - however > I cannot figure out how to set up the muhat variable and find the > means. My code is as follows: > ># R code starts here > rm(list=ls()) > set.seed(100) > > n<-30 > s<-1000 > > xbar<-rep(0,s) > muhat<-rep(0,s) > > for (i in 1:s) { > x<-rnorm(0,n=10) > xbar[i]<-mean(x) > muhat[i]<-mean(x^(-1/2)) > } The line muhat[i]<-mean(x^(-1/2)) is anomalous -- in more than one way! [1] It does not match up with your stated definition of muhat (there is no "x^(-1/2)" there); [2] x^(-1/2) is going to give a bad result for negative values of x anyway (as will be the case with your rnorm(0,n=10)). To achieve what you defined as muhat, surely muhat[i] <- mean(x)/n (where n <- length(x) somewhere, or simply n <- 10). But in any case I am wondering why you are interested in that "muhat = 1/n^2(sum of all the xi's)" definition of muhat. Part of your message seems to be going into one ear, and part into my other; when they meet in the middle, they compare notes and being to wonder if you are getting Mean mixed up with Standard Error (SE^2 = var(x)/n). Hmmm. Hoping this helps, Ted. > cat("Estimated mean of xbar:",mean(xbar),"\n") > cat("Estimated mean of muhat:",mean(muhat),"\n") > > Any help would be greatly appreciated. > -- > View this message in context: > http://www.nabble.com/Sample-mean-in-R-tp19828546p19828546.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 05-Oct-08 Time: 21:37:21 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the meaning of "segfault 'memory not mapped' " ?
One thing I have often done with code (including C and R) that falls through the ice unexpectedly is to plant (as a temporary measure) "debug prints" which emit information about where they are in the program, how many times they have gone round a particular loop, values of any potentially suspect variables, etc. Then you can look at the tail end of what they print and begin to localise the place where things go wrong. Having approximately located it, one can then replace the debug prints with more narrowly focussed ones. Often, just a few at a time will work fine. One can often wrap such a print into a function. Exactly how it is best done depends on how the code is written, and on what seems to be going wrong. Hoping this helps, Ted. On 05-Oct-08 20:22:53, Thomas Lumley wrote: > On Fri, 3 Oct 2008, Ubuntu.Diego wrote: >> I'm trying to get some "easy coding" to reproduce the error. In the >> meantime I have R code that run for 20 or more hours and suddenly i >> got >> a "segfault 'memory not mapped'" error. I have to clarify that the >> error >> not alway occurs and sometimes the process end satisfactorily. The >> process is basically a search using an MCMC strategy, sometimes the >> algorithm converge and stops others I got the error message. I was >> wondering if it could be meaning that I run out of RAM. > > The 'memory not mapped' error means that your code is reading from or > writing to memory that it doesn't own. This should have nothing to do > with > running out of RAM. > > If this is pure R code you have found a bug in R. If you are calling > your > own C code it is more likely to be a bug there. If your C code uses > PROTECT/UNPROTECT it is even more likely to be there. > > Usually the best way to track down these bugs is to run the code under > Valgrind, but this is slow, which will be a problem for code that > already > takes many hours. > > If you are extremely lucky, the crash will have happened on the first > incorrect memory access. Running R under a debugger such as gdb you can > use backtrace after the crash occurs to find where the bug happened. > Unfortunately it is quite likely that the crash happened because some > earlier piece of code overwrote a stored variable or something similar. > The fact that the segfault occurs only some of the time reinforces > this, > especially if you don't always get the crash even with the same > sequence > of random numbers. > > If you have a Linux computer that you can use for a week or so it would > be > worth running your code under Valgrind to see if it finds the problem. > > > -thomas > > > Thomas Lumley Assoc. Professor, Biostatistics > [EMAIL PROTECTED] University of Washington, Seattle > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 05-Oct-08 Time: 21:46:27 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot3d - could not find function "xlim"
Hello, thank You for Your reply. You are absolutely right, I am a bit tired, forgot to attach the code. I am very sorry about that, as well as I did not recognize that the error message came as a consequence of misstyping the code, my fault again (a real guru maybe recognize this as a misstype error as the error message is mentioning xlim as a function and not an **argument*, *I am apparently far to be a guru ... yet* *;-)). Have a nice day tomas jim holtman wrote: > Seems to work fine for me: > > plot3d(x, y, z, col=rainbow(1000), size=2, xlim=c(-5,5)) > > > It would help if you "read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code." > > Since you did not post your code, I assume that there is an unknown error in > it. > > On Sun, Oct 5, 2008 at 1:32 PM, Tomas Lanczos <[EMAIL PROTECTED]> wrote: > >> when I tried to apply xlim, ylim, zlim functions to the plot3d/decorate3d, >> inspite all the help documentation I got this errormessage: >> >> ERROR: could not find function "xlim" >> >> Is it a bug or possibly my fault? >> >> regards >> >> tomas >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] partial matching and dots?
I'm writing a new predict method and would like to be able to pass an argument called "se" via the "..." mechanism. However, predict has a "se.fit" argument that wants to interpret my specification of "se" as a partially matched version of se.fit. Surely there a standard treatment for this ailment, but I can't seem to find it. url:www.econ.uiuc.edu/~rogerRoger Koenker email [EMAIL PROTECTED] Department of Economics vox:217-333-4558University of Illinois fax:217-244-6678Champaign, IL 61820 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] partial matching and dots?
On Sun, 5 Oct 2008, roger koenker wrote: I'm writing a new predict method and would like to be able to pass an argument called "se" via the "..." mechanism. However, predict has a "se.fit" argument that But it doesn't! Some of its methods such as predict.lm and predict.glm do. So without a more complete example it is hard to know exactly what the issue is. wants to interpret my specification of "se" as a partially matched version of se.fit. Surely there a standard treatment for this ailment, but I can't seem to find it. Pass se.fit as well as se to the methods concerned. To do this you may need to check that se.fit is not part of ... . url:www.econ.uiuc.edu/~rogerRoger Koenker email [EMAIL PROTECTED] Department of Economics vox:217-333-4558University of Illinois fax:217-244-6678Champaign, IL 61820 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.