[R] spline for implicit functions
Hello list, is there any R function for generating spline for implicit functions, for example a spline for an two-column data frame where for one value for one variable there maybe several correspondent values for another? Many thanks. Currently I'm using this home-made one: spline2d - function(df, ...) { xname - colnames(df)[1] yname - colnames(df)[2] df - data.frame(c(1 : nrow(df)), df[1], df[2]) colnames(df) - c(index, xname, yname) df - data.frame( spline(df[c(index, xname)], ...)$y, spline(df[c(index, yname)], ...)$y ) colnames(df) - c(xname, yname) return(df) } -- Using GPG/PGP? Please get my current public key (ID: 0xAEF6A134, valid from 2010 to 2013) from a key server. signature.asc Description: Digital signature __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tcltk freezes R
hi, problem solved. it was a problem of the x-server. after installing the xquartz 2.6.3 for snow leopard (i have lion, but there is no such version), logging in and out to make it the default x-server, it worked. cheers, t -- View this message in context: http://r.789695.n4.nabble.com/tcltk-freezes-R-tp3828263p3829102.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot map by region using kasc and adehabitat
On 09/21/2011 01:39 AM, Alex Olssen wrote: Dear R-help, I have a raster map which has a measure of profitability of land by parcel over several regions of geographic aggregation (think of counties). This data is stored in an ASCII file. If I type plot(profit) I get a raster map of profit per parcel for all regions. I want to plot separate maps for each county. I used kasc to combine the profit map with a county map from a separate ASCII file. data.kasc - as.kasc(list(profit, county)) Can anyone help me plot profit maps for each county separately? Kind regards, Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ...to make us more willing to answer the question: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and *provide commented, minimal, self-contained, reproducible code.* Paul -- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 crash
Dear users, I have already sent this email last week, but haven't received an answer. So here is my second try. By running the script below, R crashes systematically at the last command, namely dev.off(), on Windows 7, but not on Windows XP. I therefore don't provide a reproducible example and do not really extract the relevant parts of the script because it has most likely nothing to do with the script itself. I can do it though if you think it might be relevant. R crashes on Windows 7, sessionInfo(): R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] splines stats graphics grDevices utils datasets methods [8] base other attached packages: [1] doBy_4.4.0 MASS_7.3-13snow_0.3-7 lme4_0.999375-41 [5] Matrix_0.9996875-3 lattice_0.19-30multcomp_1.2-7 mvtnorm_0.9-9991 [9] R2HTML_2.2 survival_2.36-9RSvgDevice_0.6.4.1 R.utils_1.7.8 [13] R.oo_1.8.1 R.methodsS3_1.2.1 loaded via a namespace (and not attached): [1] grid_2.13.1 nlme_3.1-101 stats4_2.13.1 But it works perfectly on Windows XP, sessionInfo(): R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] splines stats graphics grDevices utils datasets methods [8] base other attached packages: [1] doBy_4.4.0 MASS_7.3-14snow_0.3-6 lme4_0.999375-41 [5] Matrix_0.9996875-3 lattice_0.19-33multcomp_1.2-7 mvtnorm_0.9-9991 [9] R2HTML_2.2 survival_2.36-9RSvgDevice_0.6.4.1 R.utils_1.7.8 [13] R.oo_1.8.1 R.methodsS3_1.2.1 loaded via a namespace (and not attached): [1] grid_2.13.1 nlme_3.1-102 stats4_2.13.1 Except the locale, I don't see any difference and I don't really understand how that would make R crash by running dev.off(). I would guess that the problem comes from RSvgDevice on Windows 7. Can someone help me to solve this issue? Thank you for your help, Ivan script - library(R.utils) library(RSvgDevice) library(doBy) primate_med - loadObject(primate_med.Rbin) select - primate_med seq.yvar - c(5,12,8,9) ind.xvar - 4 filename - paste(regression, names(datobj)[ind.xvar], paste(names(datobj)[seq.yvar],collapse=_), paste(selvarstr,collapse=_), sep=_) filename - gsub(.median, , filename) select_mean - summaryBy(as.formula(paste(.~,names(select)[ind.xvar])), data=select, FUN=mean) devSVG(file=paste(filename, .svg, sep=)) par(mfrow=c(2,2)) diff_len - length(select)-length(select_mean) for (i in seq_along(seq.yvar)){ k - seq.yvar[i] plot(select[[k]]~select[[ind.xvar]], type=p, pch=1, xlab=names(select)[ind.xvar], ylab=names(select)[k], las=1) points(select_mean[[ind.xvar-diff_len]], select_mean[[k-diff_len]], pch=18, cex=2) two_reg(dat=select, xvar=ind.xvar, yvar=k) } dev.off() - -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tcltk freezes R
On Tue, 20 Sep 2011, tm wrote: Hi there, I have the following problem on my macbook air with mac os x lion on it. when any program tries to load the tcltk library the R GUI or R command line freezes. also happens if I just use library(tcltk) changing versions of tcltk and/or R doesn't help. currently I have the following: R version 2.13.2 beta (2011-09-19 r57030) Pre-built or built youself? tcltk 8.5.10 any suggestions? Use the recommended version of Tcl/Tk at http://cran.r-project.org/bin/macosx/tools/ (which is 8.5.5: and uses X11 not Aqua: I use Aqua Tcl/Tk with command-line R). And please do as you were asked and use r-sig-mac for OS X-specific questions. thanks a lot already, t. -- View this message in context: http://r.789695.n4.nabble.com/tcltk-freezes-R-tp3828263p3828263.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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ARIMA - Skipping intermediate lags
On Tue, 20 Sep 2011, leighton155 wrote: Hello, I am a new R user. I am trying to use the arima command, but I have a question on intermediate lags. I want to run in R the equivalent Stata command of ARIMA d.yyy, AR(5) MA(5 7). This would tell the program I am interested in AR lag 5, MA lag 5, and MA lag 7, all while skipping the intermediate lags of AR 1-4, and MA 1-4, 6. Is there any way to do this in R? Thank you. Yes. See the 'fixed' argument on the help page. Note that this is not recommended in general -- View this message in context: http://r.789695.n4.nabble.com/ARIMA-Skipping-intermediate-lags-tp3828449p3828449.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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with predict and lines in plotting binomial glm
Problems with predict and lines in plotting binomial glm Dear R-helpers I have found quite a lot of tips on how to work with glm through this mailing list, but still have a problem that I can't solve. I have got a data set of which the x-variable is count data and the y-variable is proportional data, and I want to know what the relationship between the variables are. The data was overdispersed (the residual deviance is much larger than the residual degrees of freedom) therefore I am using the quasibinomial family, thus the y-variable is a matrix of successes and failures (20 trials for every sample, thus each y-variable row counts up to 20). x - c(1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1800, 1800, 1800, 1800, 1800, 1800, 1800, 1800, 1800, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 3000, 3000, 3600, 3600, 3600, 3600, 4200, 4200, 4800, 4800, 5400, 6600, 6600, 7200, 7800, 7800, 8400, 8400, 8400, 9000, 9600, 10200, 13200, 18000, 20400, 24000, 25200, 36600) successes - c(6, 16, 11, 14, 11, 16, 13, 13, 14, 16, 12, 12, 11, 15, 12, 9, 7, 7, 17, 15, 13, 9, 9, 12, 14, 8, 9, 16, 7, 9, 14, 11, 8, 8, 13, 6, 16, 11, 9, 7, 9, 8, 4, 14, 7, 3, 3, 9, 12, 8, 4, 6) failures - c(14, 4, 9, 6, 9, 4, 7, 7, 6, 4, 8, 8, 9, 5, 8, 11, 13, 13, 3, 5, 7, 11, 11, 8, 6, 12, 11, 4, 13, 11, 6, 9, 12, 12, 7, 14, 4, 9, 11, 13, 11, 12, 16, 6, 13, 17, 17, 11, 8, 12, 16, 14) y - cbind(successes, failures) data - data.frame(y, x) glm1 - glm(y ~ x, family= quasibinomial, data= data) glm2 - glm(y ~ log(x), family=quasibinomial, data= data) # residual deviance is lower with log transformed x-value plot(x, successes) lines(x, predict(glm1, type= response), lwd=2) Firstly, because of the skewed distribution of the x variable I am not sure whether it should be log transformed or not. When I do log transform it, the residual deviance and the p-value for the slope is lower. Either way, the lines command does not plot any line and neither does it give any error messages. On some of my other data it plots a line way below all the data points. From what I can gather, the predict function as it is now uses the fitted values because no newdata argument is specified. I want the line to be predicted from the same x-values. I tried two ways of adding the newdata argument: ## a data.frame using the original x-values lines(x, predict(glm2, type= response, newdata= as.data.frame(x))) ## or a data.frame with values (the same length as y) from the range of x values newdf - data.frame(seq(min(x), max(x), length=52)) lines(x, predict(glm2, type=response, newdata= newdf)) Only the second option plotted a line once, but then I could never get it to do the same again on a new plot even though I used the same variables and same code. Thank you very much for your time and patient Anina Heystek BSc Honours student Department of Botany and Zoology University of Stellenbosch, Stellenbosch, South Africa 15418...@sun.ac.za [[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] R crash
On Wed, Sep 21, 2011 at 8:57 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Dear users, I therefore don't provide a reproducible example and do not really extract the relevant parts of the script because it has most likely nothing to do with the script itself. I can do it though if you think it might be relevant. In which case you could reduce your code to something we can all try - does this crash for you: library(RSvgDevice) devSVG(file=foo.svg) plot(1:10) dev.off() - if not then something I've taken from your script is causing the problem. Add bits back until it crashes. - if it does still crash then its likely a fundamental devSVG problem, and you've now got something that hundreds of people reading this can just cut n paste and go 'me too' or 'crashes for me'. Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 CMD build and vignettes
Dear R-helpers, www.statistik.lmu.de/~*leisch*/*Sweave*/*Sweave*-Rnews-2003-2.pdf says that R CMD build creates the pdf from a .Rnw file. But when I do R CMD build followed by R CMD check it gives me a warning that there is a vignette without a PDF. My query is : when R CMD build works it creates a pdf in the doc subdirectory of the directory returned by system.file(package = mypackage) and not in the inst/doc directory of the package that we are creating. Do we have to Sweave and create the pdf in the inst/doc subdirectory on our own ? Please clarify. Regards, Ashim [[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] R crash
Dear Barry, Thanks for your input, that is indeed a very good idea (shame on me not to have thought about it...). As expected, it works fine on Windows XP, but crashes on Windows 7 at dev.off (which means that the svg file is correctly created, but R crashes every time, a bit annoying). This is therefore a devSVG problem on Windows 7. Now, does anyone know how to fix this? TIA, Ivan Le 9/21/2011 10:34, Barry Rowlingson a écrit : On Wed, Sep 21, 2011 at 8:57 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Dear users, I therefore don't provide a reproducible example and do not really extract the relevant parts of the script because it has most likely nothing to do with the script itself. I can do it though if you think it might be relevant. In which case you could reduce your code to something we can all try - does this crash for you: library(RSvgDevice) devSVG(file=foo.svg) plot(1:10) dev.off() - if not then something I've taken from your script is causing the problem. Add bits back until it crashes. - if it does still crash then its likely a fundamental devSVG problem, and you've now got something that hundreds of people reading this can just cut n paste and go 'me too' or 'crashes for me'. Barry -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with predict and lines in plotting binomial glm
Hi Anina, predict.glm returns predicted probabilities, when used with type=response, so you have to either scale the probs to the number of trials for any x or you plot probs from start: par(mfcol=c(1,2)) plot(x, successes) lines(x, (successes+failures)*predict(glm1, type= response), lwd=2) plot(x, successes/(successes+failures)) lines(x, predict(glm1, type= response), lwd=2) If you use predict with new data, please name the rows accordingly, when you actually want to use them: newdf - data.frame(seq(min(x), max(x), length=20)) #you would expect 20 predictions, but *surprise* you get length(predict(glm2, type=response, newdata= newdf)) #52! newdf - data.frame(x=seq(min(x), max(x), length=20)) length(predict(glm2, type=response, newdata= newdf)) #ok And you should use the appropriate x in lines as well: plot(x,successes/(successes+failures)) lines(newdf$x, predict(glm2, type=response, newdata= newdf),col=red) Cheers Am 21.09.2011 09:55, schrieb Heystek, A, Me 15418...@sun.ac.za: Problems with predict and lines in plotting binomial glm Dear R-helpers I have found quite a lot of tips on how to work with glm through this mailing list, but still have a problem that I can't solve. I have got a data set of which the x-variable is count data and the y-variable is proportional data, and I want to know what the relationship between the variables are. The data was overdispersed (the residual deviance is much larger than the residual degrees of freedom) therefore I am using the quasibinomial family, thus the y-variable is a matrix of successes and failures (20 trials for every sample, thus each y-variable row counts up to 20). x - c(1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1800, 1800, 1800, 1800, 1800, 1800, 1800, 1800, 1800, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 3000, 3000, 3600, 3600, 3600, 3600, 4200, 4200, 4800, 4800, 5400, 6600, 6600, 7200, 7800, 7800, 8400, 8400, 8400, 9000, 9600, 10200, 13200, 18000, 20400, 24000, 25200, 36600) successes - c(6, 16, 11, 14, 11, 16, 13, 13, 14, 16, 12, 12, 11, 15, 12, 9, 7, 7, 17, 15, 13, 9, 9, 12, 14, 8, 9, 16, 7, 9, 14, 11, 8, 8, 13, 6, 16, 11, 9, 7, 9, 8, 4, 14, 7, 3, 3, 9, 12, 8, 4, 6) failures - c(14, 4, 9, 6, 9, 4, 7, 7, 6, 4, 8, 8, 9, 5, 8, 11, 13, 13, 3, 5, 7, 11, 11, 8, 6, 12, 11, 4, 13, 11, 6, 9, 12, 12, 7, 14, 4, 9, 11, 13, 11, 12, 16, 6, 13, 17, 17, 11, 8, 12, 16, 14) y - cbind(successes, failures) data - data.frame(y, x) glm1 - glm(y ~ x, family= quasibinomial, data= data) glm2 - glm(y ~ log(x), family=quasibinomial, data= data) # residual deviance is lower with log transformed x-value plot(x, successes) lines(x, predict(glm1, type= response), lwd=2) Firstly, because of the skewed distribution of the x variable I am not sure whether it should be log transformed or not. When I do log transform it, the residual deviance and the p-value for the slope is lower. Either way, the lines command does not plot any line and neither does it give any error messages. On some of my other data it plots a line way below all the data points. From what I can gather, the predict function as it is now uses the fitted values because no newdata argument is specified. I want the line to be predicted from the same x-values. I tried two ways of adding the newdata argument: ## a data.frame using the original x-values lines(x, predict(glm2, type= response, newdata= as.data.frame(x))) ## or a data.frame with values (the same length as y) from the range of x values newdf - data.frame(seq(min(x), max(x), length=52)) lines(x, predict(glm2, type=response, newdata= newdf)) Only the second option plotted a line once, but then I could never get it to do the same again on a new plot even though I used the same variables and same code. Thank you very much for your time and patient Anina Heystek BSc Honours student Department of Botany and Zoology University of Stellenbosch, Stellenbosch, South Africa 15418...@sun.ac.za [[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. -- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender), Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus __ R-help@r-project.org mailing list
[R] Poisson-Gamma computation (parameters and likelihood)
Good afternoon/morning readers. This is the first time I am trying to run some Bayesian computation in R, and am experiencing a few problems. I am working on a Poisson model for cancer rates which has a conjugate Gamma prior. 1) The first question is precisely how I work out the parameters. #Suppose I assign values to theta with seq() theta-seq(0,1,len=500) #Then I try out the parameters that seem to fit with a certain prior idea on theta (see next) a=182 b=3530 gaprior-dgamma(theta,a,b) It should work by trial-and-error (according to Bayesian Computation with R) , but how can I check the parameters turned out well: should I just look at the plot, or evaluate it through the 1 - pgamma(x,a,b) function, having knowledge of the 5th percentile (data from US Cancer Statistics)? 2) Then, the next problem I have regards the likelihood distribution. #Having the react table, I name the columns (with y=deaths, and x=exposures) react x y 1 6 15 2 5 16 3 3 12 4 4 6 5 27 77 6 7 17 7 4 11 8 5 10 9 23 63 10 11 29 yr - react[,2] xr - react[,1] #I then compute the likelihood poislike=dpois(yr, theta*xr) #And this is what I come up with, which I really don't understand. poislike [1] 0 0 0 0 0 0 0 0 0 0 The values shouldn't be all null, otherwise my posterior cannot be computed properly. Does anyone have any idea on where I could possibly have messed it up? Thank you very much for your attention. Regards, Sebastiano Putoto (University of Pavia, Italy) [[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] problem with function Truncate in package distr
Hello all, Can someone tell me why the following mixture of two log-normal distributions does not get truncated? What puzzles me is that the function works almost always, but for certain combinations (like the one below), it does not. # R code example library(distr) mix-UnivarMixingDistribution(Lnorm(3.2,0.5),Lnorm(5.4,0.6),mixCoeff=c(0.3,0.7)) mix.trunc-Truncate(mix,lower=0.001,upper=3000) distr.sample-r(mix.trunc)(100) range(distr.sample) Why do I get values over 3000 (which was the defoned upper limit)? Some help would be greatly appreciated. Duarte Viana __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Cannot allocate vector of size x
Dear all, I am running a simulation in which I randomly generate a series of vectors to test whether they fulfill a certain condition. In most cases, there is no problem. But from time to time, the (randomly) generated vectors are too large for my system and I get the error message: Cannot allocate vector of size x. The problem is that in those cases my simulation stops and I have to start it again manually. What I would like to do is to simply ignore that the error happened (or probably report that it did) and then continue with another (randomly) generated vector. So my question: Is there a way to avoid that R stops in such a case and just restarts the program from the beginning as if nothing happened? I hope I'm making myself clear here ... Thanks, Michael [[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] Cannot allocate vector of size x
Check one of the examples in ?try It has this heading: ## run a simulation, keep only the results that worked. If your system is Windows, you can also try to increase the memory available for one application, in order to avoid the problem. Do a search for 3GB switch HTH Dr. Ruben H. Roa-Ureta Senior Researcher, AZTI Tecnalia, Marine Research Division, Txatxarramendi Ugartea z/g, 48395, Sukarrieta, Bizkaia, Spain -Mensaje original- De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] En nombre de Michael Haenlein Enviado el: miércoles, 21 de septiembre de 2011 11:54 Para: r-help@r-project.org Asunto: [R] Cannot allocate vector of size x Dear all, I am running a simulation in which I randomly generate a series of vectors to test whether they fulfill a certain condition. In most cases, there is no problem. But from time to time, the (randomly) generated vectors are too large for my system and I get the error message: Cannot allocate vector of size x. The problem is that in those cases my simulation stops and I have to start it again manually. What I would like to do is to simply ignore that the error happened (or probably report that it did) and then continue with another (randomly) generated vector. So my question: Is there a way to avoid that R stops in such a case and just restarts the program from the beginning as if nothing happened? I hope I'm making myself clear here ... Thanks, Michael [[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] Cannot allocate vector of size x
how much memory do you have on your system? How large are the vectors you are creating? How many other large vectors do you have in memory? Remove all unused objects and do gc() to reclaim some of the memory. Remember all objects are in memory and you have to understand how large they are and how many you have. Ther is more information you have to provide and some more inspection you have to do. Sent from my iPad On Sep 21, 2011, at 5:53, Michael Haenlein haenl...@escpeurope.eu wrote: Dear all, I am running a simulation in which I randomly generate a series of vectors to test whether they fulfill a certain condition. In most cases, there is no problem. But from time to time, the (randomly) generated vectors are too large for my system and I get the error message: Cannot allocate vector of size x. The problem is that in those cases my simulation stops and I have to start it again manually. What I would like to do is to simply ignore that the error happened (or probably report that it did) and then continue with another (randomly) generated vector. So my question: Is there a way to avoid that R stops in such a case and just restarts the program from the beginning as if nothing happened? I hope I'm making myself clear here ... Thanks, Michael [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Statmath-R-Forge: Request denied
Dear All, I want to subscribe for Statmath-R-Forge mailing list. But I am getting the following reply and I am unable to subscribe. Any insight on this would be appreciated. Regards Vikram Bahure __ Your request to the Statmath-R-Forge mailing list Subscription request has been rejected by the list moderator. The moderator gave the following reason for rejecting your request: This list is not public. Please register trackers and forums instead. Any questions or comments should be directed to the list administrator at: statmath-r-forge-ow...@wu.ac.at [[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] Strucchange gbreakpoints
Hi, I am a new user to R. I am using strucchange to generate breakpoints: -- res - gbreakpoints(GDP.new ~ 1,data=a,h=2,breaks=5) print(res) Optimal 6-segment partition for `lm' fit: Call: gbreakpoints(formula = GDP.new ~ 1, data = a, h = 2, breaks = 5) Breakpoints at observation number: 10 19 25 38 48 Corresponding to breakdates: 1960 1969 1975 1988 1998 -- I want to access the breakdates. I can access the breakpoints by: res[[1]] I wish to access breakpoints dates but still struggling. I hope get some help. Thanks in advance. Regards Vikram [[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] R CMD build and vignettes
Hi Ashim, after 'R CMD build' the vignettes are in the pkg*.tar.gz file, not in your package directory. So if you run 'R CMD build pkg' and then 'R CMD check pkg*.tar.gz', you should not get that warning. For such questions you may get better answers on R-devel; see, eg, this thread here https://stat.ethz.ch/pipermail/r-devel/2011-May/060775.html Regards, Enrico Am 21.09.2011 11:01, schrieb Ashim Kapoor: Dear R-helpers, www.statistik.lmu.de/~*leisch*/*Sweave*/*Sweave*-Rnews-2003-2.pdf says that R CMD build creates the pdf from a .Rnw file. But when I do R CMD build followed by R CMD check it gives me a warning that there is a vignette without a PDF. My query is : when R CMD build works it creates a pdf in the doc subdirectory of the directory returned by system.file(package = mypackage) and not in the inst/doc directory of the package that we are creating. Do we have to Sweave and create the pdf in the inst/doc subdirectory on our own ? Please clarify. Regards, Ashim [[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. -- Enrico Schumann Lucerne, Switzerland http://nmof.net/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 allocate vector of size x
Yes, on a recent heavy-duty job -profile likelihood of Tweedie power parameter for a relatively complex glm with hundreds of thousands rows dataframe- I had the cannot allocate vector ... error, then I just closed-saved the main workspace, full of large objects, then I did the profiling on a fresh and almost empty (with strictly necessary objects) workspace, and it run successfully. Then I just loaded the two workspaces to one session, and continued happily to the end of the job. :-) Dr. Ruben H. Roa-Ureta Senior Researcher, AZTI Tecnalia, Marine Research Division, Txatxarramendi Ugartea z/g, 48395, Sukarrieta, Bizkaia, Spain -Mensaje original- De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] En nombre de Jim Holtman Enviado el: miércoles, 21 de septiembre de 2011 12:11 Para: Michael Haenlein CC: r-help@r-project.org Asunto: Re: [R] Cannot allocate vector of size x how much memory do you have on your system? How large are the vectors you are creating? How many other large vectors do you have in memory? Remove all unused objects and do gc() to reclaim some of the memory. Remember all objects are in memory and you have to understand how large they are and how many you have. Ther is more information you have to provide and some more inspection you have to do. Sent from my iPad On Sep 21, 2011, at 5:53, Michael Haenlein haenl...@escpeurope.eu wrote: Dear all, I am running a simulation in which I randomly generate a series of vectors to test whether they fulfill a certain condition. In most cases, there is no problem. But from time to time, the (randomly) generated vectors are too large for my system and I get the error message: Cannot allocate vector of size x. The problem is that in those cases my simulation stops and I have to start it again manually. What I would like to do is to simply ignore that the error happened (or probably report that it did) and then continue with another (randomly) generated vector. So my question: Is there a way to avoid that R stops in such a case and just restarts the program from the beginning as if nothing happened? I hope I'm making myself clear here ... Thanks, Michael [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 CMD build and vignettes
Dear Enrico, Many thanks for your reply.I was doing R CMD check pkg ( where pkg is the directory name and NOT the tar ball ). May I ask another query or should this goto R-devel ? Once I do a R CMD build the vignette PDF's are inside the tar ball ,how will I put the PDF for the vignette in the pkg/inst/doc/ of my svn folder so I can commit it and other people can see no bugs when the check the directory. Perhaps I am misunderstanding something much more basic. Best Regards, Ashim On Wed, Sep 21, 2011 at 3:53 PM, Enrico Schumann enricoschum...@yahoo.dewrote: Hi Ashim, after 'R CMD build' the vignettes are in the pkg*.tar.gz file, not in your package directory. So if you run 'R CMD build pkg' and then 'R CMD check pkg*.tar.gz', you should not get that warning. For such questions you may get better answers on R-devel; see, eg, this thread here https://stat.ethz.ch/**pipermail/r-devel/2011-May/**060775.htmlhttps://stat.ethz.ch/pipermail/r-devel/2011-May/060775.html Regards, Enrico Am 21.09.2011 11:01, schrieb Ashim Kapoor: Dear R-helpers, www.statistik.lmu.de/~*leisch***/*Sweave*/*Sweave*-Rnews-2003-**2.pdfhttp://www.statistik.lmu.de/%7E*leisch*/*Sweave*/*Sweave*-Rnews-2003-2.pdf says that R CMD build creates the pdf from a .Rnw file. But when I do R CMD build followed by R CMD check it gives me a warning that there is a vignette without a PDF. My query is : when R CMD build works it creates a pdf in the doc subdirectory of the directory returned by system.file(package = mypackage) and not in the inst/doc directory of the package that we are creating. Do we have to Sweave and create the pdf in the inst/doc subdirectory on our own ? Please clarify. Regards, Ashim [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Enrico Schumann Lucerne, Switzerland http://nmof.net/ [[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] Strucchange gbreakpoints
On Wed, 21 Sep 2011, Vikram Bahure wrote: Hi, I am a new user to R. I am using strucchange to generate breakpoints: The answer is still the same as last week: https://stat.ethz.ch/pipermail/r-help/2011-September/289944.html -- res - gbreakpoints(GDP.new ~ 1,data=a,h=2,breaks=5) print(res) Optimal 6-segment partition for `lm' fit: Call: gbreakpoints(formula = GDP.new ~ 1, data = a, h = 2, breaks = 5) Breakpoints at observation number: 10 19 25 38 48 Corresponding to breakdates: 1960 1969 1975 1988 1998 -- I want to access the breakdates. I can access the breakpoints by: res[[1]] I wish to access breakpoints dates but still struggling. I hope get some help. Thanks in advance. Regards Vikram [[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] R crash
On Wed, Sep 21, 2011 at 10:12 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Dear Barry, Thanks for your input, that is indeed a very good idea (shame on me not to have thought about it...). As expected, it works fine on Windows XP, but crashes on Windows 7 at dev.off (which means that the svg file is correctly created, but R crashes every time, a bit annoying). This is therefore a devSVG problem on Windows 7. Now, does anyone know how to fix this? Why are you using that svg device when there's a perfectly good one included in R? See help(svg). Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 CMD build and vignettes
There are various options, and it depends on your work flow and the people that you expect to use the code. If they get a working copy of the directory (with only the Rnw-files*) and then build/install the package, they get the pdfs; so you do not need to add the pdfs. (If they don't build the package, you could also distribute the tarball.) You can also build the vignettes through 'Sweave' (in the utils package; or use 'R CMD Sweave'). Or, after you ran 'R CMD check', go to the 'pkg.Rcheck' directory it created: there you will also find the pdfs (under /pkg/doc). Or simply extract the pdfs from the *.tar.gz. As I said, it depends on your work flow and the work flow of your coworkers. If you need to provide the pdfs, you can decide on one way and then write some batch-file that automates the procedure. Regards, Enrico * and other required files like bib-files Am 21.09.2011 12:38, schrieb Ashim Kapoor: Dear Enrico, Many thanks for your reply.I was doing R CMD check pkg ( where pkg is the directory name and NOT the tar ball ). May I ask another query or should this goto R-devel ? Once I do a R CMD build the vignette PDF's are inside the tar ball ,how will I put the PDF for the vignette in the pkg/inst/doc/ of my svn folder so I can commit it and other people can see no bugs when the check the directory. Perhaps I am misunderstanding something much more basic. Best Regards, Ashim On Wed, Sep 21, 2011 at 3:53 PM, Enrico Schumannenricoschum...@yahoo.dewrote: Hi Ashim, after 'R CMD build' the vignettes are in thepkg*.tar.gz file, not in your package directory. So if you run 'R CMD buildpkg' and then 'R CMD checkpkg*.tar.gz', you should not get that warning. For such questions you may get better answers on R-devel; see, eg, this thread here https://stat.ethz.ch/**pipermail/r-devel/2011-May/**060775.htmlhttps://stat.ethz.ch/pipermail/r-devel/2011-May/060775.html Regards, Enrico Am 21.09.2011 11:01, schrieb Ashim Kapoor: Dear R-helpers, www.statistik.lmu.de/~*leisch***/*Sweave*/*Sweave*-Rnews-2003-**2.pdfhttp://www.statistik.lmu.de/%7E*leisch*/*Sweave*/*Sweave*-Rnews-2003-2.pdf says that R CMD build creates the pdf from a .Rnw file. But when I do R CMD build followed by R CMD check it gives me a warning that there is a vignette without a PDF. My query is : when R CMD build works it creates a pdf in the doc subdirectory of the directory returned by system.file(package = mypackage) and not in the inst/doc directory of the package that we are creating. Do we have to Sweave and create the pdf in the inst/doc subdirectory on our own ? Please clarify. Regards, Ashim [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Enrico Schumann Lucerne, Switzerland http://nmof.net/ -- Enrico Schumann Lucerne, Switzerland http://nmof.net/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 crash
On 11-09-21 5:12 AM, Ivan Calandra wrote: Dear Barry, Thanks for your input, that is indeed a very good idea (shame on me not to have thought about it...). As expected, it works fine on Windows XP, but crashes on Windows 7 at dev.off (which means that the svg file is correctly created, but R crashes every time, a bit annoying). This is therefore a devSVG problem on Windows 7. Now, does anyone know how to fix this? RSvgDevice is a contributed package; you should contact the maintainer of it. There's also an svg() device in the upcoming R 2.14.0 on Windows (it has been on Unix-alikes for longer, I think); perhaps it will do what you need. Duncan Murdoch TIA, Ivan Le 9/21/2011 10:34, Barry Rowlingson a écrit : On Wed, Sep 21, 2011 at 8:57 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Dear users, I therefore don't provide a reproducible example and do not really extract the relevant parts of the script because it has most likely nothing to do with the script itself. I can do it though if you think it might be relevant. In which case you could reduce your code to something we can all try - does this crash for you: library(RSvgDevice) devSVG(file=foo.svg) plot(1:10) dev.off() - if not then something I've taken from your script is causing the problem. Add bits back until it crashes. - if it does still crash then its likely a fundamental devSVG problem, and you've now got something that hundreds of people reading this can just cut n paste and go 'me too' or 'crashes for me'. Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 CMD build and vignettes
On Wed, Sep 21, 2011 at 5:15 PM, Enrico Schumann enricoschum...@yahoo.dewrote: There are various options, and it depends on your work flow and the people that you expect to use the code. If they get a working copy of the directory (with only the Rnw-files*) and then build/install the package, they get the pdfs; so you do not need to add the pdfs. (If they don't build the package, you could also distribute the tarball.) You can also build the vignettes through 'Sweave' (in the utils package; or use 'R CMD Sweave'). Or, after you ran 'R CMD check', go to the 'pkg.Rcheck' directory it created: there you will also find the pdfs (under /pkg/doc). Or simply extract the pdfs from the *.tar.gz. As I said, it depends on your work flow and the work flow of your coworkers. If you need to provide the pdfs, you can decide on one way and then write some batch-file that automates the procedure. Thank you Enrico that was very interesting to hear. Regards, Ashim Am 21.09.2011 12:38, schrieb Ashim Kapoor: Dear Enrico, Many thanks for your reply.I was doing R CMD check pkg ( where pkg is the directory name and NOT the tar ball ). May I ask another query or should this goto R-devel ? Once I do a R CMD build the vignette PDF's are inside the tar ball ,how will I put the PDF for the vignette in the pkg/inst/doc/ of my svn folder so I can commit it and other people can see no bugs when the check the directory. Perhaps I am misunderstanding something much more basic. Best Regards, Ashim On Wed, Sep 21, 2011 at 3:53 PM, Enrico Schumannenricoschumann@yahoo.** de enricoschum...@yahoo.dewrote: Hi Ashim, after 'R CMD build' the vignettes are in thepkg*.tar.gz file, not in your package directory. So if you run 'R CMD buildpkg' and then 'R CMD checkpkg*.tar.gz', you should not get that warning. For such questions you may get better answers on R-devel; see, eg, this thread here https://stat.ethz.ch/pipermail/r-devel/2011-May/060775.htmlhttps://stat.ethz.ch/**pipermail/r-devel/2011-May/**060775.html https://stat.ethz.**ch/pipermail/r-devel/2011-May/**060775.htmlhttps://stat.ethz.ch/pipermail/r-devel/2011-May/060775.html Regards, Enrico Am 21.09.2011 11:01, schrieb Ashim Kapoor: Dear R-helpers, www.statistik.lmu.de/~*leisch*/*Sweave*/*Sweave*-Rnews-** 2003-**2.pdfhttp://www.statistik.lmu.de/%7E*leisch***/*Sweave*/*Sweave*-Rnews-2003-**2.pdf http://www.**statistik.lmu.de/%7E*leisch*/*** Sweave*/*Sweave*-Rnews-2003-2.**pdfhttp://www.statistik.lmu.de/%7E*leisch*/*Sweave*/*Sweave*-Rnews-2003-2.pdf says that R CMD build creates the pdf from a .Rnw file. But when I do R CMD build followed by R CMD check it gives me a warning that there is a vignette without a PDF. My query is : when R CMD build works it creates a pdf in the doc subdirectory of the directory returned by system.file(package = mypackage) and not in the inst/doc directory of the package that we are creating. Do we have to Sweave and create the pdf in the inst/doc subdirectory on our own ? Please clarify. Regards, Ashim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.htmlhttp://www.**R-project.org/posting-guide.**htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Enrico Schumann Lucerne, Switzerland http://nmof.net/ -- Enrico Schumann Lucerne, Switzerland http://nmof.net/ [[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] R crash
I think Duncan answered it: because there is no svg() in R2.13.1 for Windows. Thank you for your help Ivan Le 9/21/2011 13:40, Barry Rowlingson a écrit : On Wed, Sep 21, 2011 at 10:12 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Dear Barry, Thanks for your input, that is indeed a very good idea (shame on me not to have thought about it...). As expected, it works fine on Windows XP, but crashes on Windows 7 at dev.off (which means that the svg file is correctly created, but R crashes every time, a bit annoying). This is therefore a devSVG problem on Windows 7. Now, does anyone know how to fix this? Why are you using that svg device when there's a perfectly good one included in R? See help(svg). Barry -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 crash
Dear Duncan, Thanks for the info. I'll be waiting for it then. I once tried to contact the maintainer of this package, but never got an answer; so I haven't tried this time. I'll try again. Ivan Le 9/21/2011 13:45, Duncan Murdoch a écrit : On 11-09-21 5:12 AM, Ivan Calandra wrote: Dear Barry, Thanks for your input, that is indeed a very good idea (shame on me not to have thought about it...). As expected, it works fine on Windows XP, but crashes on Windows 7 at dev.off (which means that the svg file is correctly created, but R crashes every time, a bit annoying). This is therefore a devSVG problem on Windows 7. Now, does anyone know how to fix this? RSvgDevice is a contributed package; you should contact the maintainer of it. There's also an svg() device in the upcoming R 2.14.0 on Windows (it has been on Unix-alikes for longer, I think); perhaps it will do what you need. Duncan Murdoch TIA, Ivan Le 9/21/2011 10:34, Barry Rowlingson a écrit : On Wed, Sep 21, 2011 at 8:57 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Dear users, I therefore don't provide a reproducible example and do not really extract the relevant parts of the script because it has most likely nothing to do with the script itself. I can do it though if you think it might be relevant. In which case you could reduce your code to something we can all try - does this crash for you: library(RSvgDevice) devSVG(file=foo.svg) plot(1:10) dev.off() - if not then something I've taken from your script is causing the problem. Add bits back until it crashes. - if it does still crash then its likely a fundamental devSVG problem, and you've now got something that hundreds of people reading this can just cut n paste and go 'me too' or 'crashes for me'. Barry -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help in interpreting paired t-test
Ted Harding wrote on 09/20/2011 05:26:58 PM: Further to the plot suggested below, the plot plot(log(A),log(B/A),pch=+,col=blue) reveals an interesting structure to the data. Distinct curved sequences are clearly visible. While their curved form is a consequence of the fact that, for large A, A/B is close to 1 and so they tend to approach 1 asymptotically (hence the curving over towards flatness), what is really interesting is the appearance of distinct curves, as if there were at least 7 (or at least 8) distinct subsets to the data, each subset following a different curve. Perhaps these are related to observed variables? Ted. The distinct curves that you observed are a side effect of the data being rounded to the nearest thousandth. They disappear if noise is added to the data. a - A + runif(length(A), -0.0005, 0.0005) b - B + runif(length(B), -0.0005, 0.0005) plot(a, b/a, log=xy) Jean On 20-Sep-11 18:15:50, Ted Harding wrote: As can be seen by plotting as follows: plot(A,B,pch=+,col=blue) ## The raw data plot(A,B-A,pch=+,col=blue) ## The differences versus A lines(c(0,0.7),c(0,0)) Ted. On 20-Sep-11 17:54:15, Timothy Bates wrote: Yes, in over 3/4s of the data points A is B? which suggests the A measure is reading higher than the B measuring system. length(A[AB])/length(A) On 20 Sep 2011, at 6:46 PM, Pedro Mardones wrote: Dear all; A very basic question. I have the following data: ** * * A - 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163, 62,112,334,249,45,244,211,175,174,26,375,346,153,32, 89,32,358,202,123,131,88,36,30,67,96,135,219,122, 89,117,86,169,179,54,48,40,54,568,664,277,91,290, 116,80,107,401,225,517,90,133,36,50,174,103,192,150, 225,29,80,199,55,258,97,109,137,90,236,109,204,160, 95,54,50,78,98,141,508,144,434,100,37,22,304,175, 72,71,111,60,212,73,50,92,70,148,28,63,46,85, 111,67,234,65,92,59,118,202,21,17,95,86,296,45, 139,32,21,70,185,172,151,129,42,14,13,75,303,119, 128,106,224,241,112,395,78,89,247,122,212,61,165,30, 65,261,415,159,316,182,141,184,124,223,39,141,103,149, 104,71,259,86,85,214,96,246,306,11,129) B - 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162, 60,108,325,240,44,242,208,168,170,27,356,341,150,31, 85,29,363,185,124,131,85,35,27,63,92,147,217,117, 87,119,81,161,178,53,45,38,50,581,661,254,87,281, 110,76,100,401,220,507,94,123,36,47,154,99,184,146, 232,26,77,193,53,264,94,110,128,87,231,110,195,156, 95,51,50,75,93,134,519,139,435,96,37,21,293,169, 70,80,104,64,210,70,48,88,67,140,26,52,45,90, 106,63,219,62,91,56,113,187,18,14,95,86,284,39, 132,31,22,69,181,167,150,117,42,14,11,73,303,109, 129,106,227,249,111,409,71,88,256,120,200,60,159,27, 63,268,389,150,311,175,136,171,116,220,30,145,95,148, 102,70,251,88,83,199,94,245,305,9,129) ** * * plot(A,B) abline(0,1) At a glance, the data look very similar. Data A and B are two measurements of the same variable but using different devices (on a same set of subjects). Thus, I thought that a paired t-test could be appropriate to check if the diff between measurement devices = 0. t.test(A-B) ** * * One Sample t-test data: A - B t = 7.6276, df = 178, p-value = 1.387e-12 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.002451622 0.004162903 sample estimates: mean of x 0.003307263 ** * * The mean diff is 0.0033 but the p-value indicates a strong evidence to reject H0. I was expecting to find no differences so I'm wondering whether the t-test is the appropriate test to use. I'll appreciate any comments or suggestions. E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 20-Sep-11 Time: 19:15:47 E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 20-Sep-11 Time: 23:26:53 [[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] Statmath-R-Forge: Request denied
On 09/21/2011 10:11 AM, Vikram Bahure wrote: Dear All, I want to subscribe for Statmath-R-Forge mailing list. But I am getting the following reply and I am unable to subscribe. Any insight on this would be appreciated. Regards Vikram Bahure __ Your request to the Statmath-R-Forge mailing list Subscription request has been rejected by the list moderator. The moderator gave the following reason for rejecting your request: This list is not public. Please register trackers and forums instead. Any questions or comments should be directed to the list administrator at: statmath-r-forge-ow...@wu.ac.at [[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. I think your problem is that: This list is not public Just my 2ct...and Any questions or comments should be directed to the list administrator... Paul -- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-help Digest, Vol 103, Issue 20
Szeptember 12-től 26-ig irodán kívül vagyok, és az emailjeimet nem érem el. Sürgős esetben kérem forduljon Kárpáti Edithez (karpati.e...@gyemszi.hu). Üdvözlettel, Mihalicza Péter I will be out of the office from 12 till 26 September with no access to my emails. In urgent cases please contact Ms. Edit Kárpáti (karpati.e...@gyemszi.hu). With regards, Peter Mihalicza __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with caret + foreach + M5 combination
Hello, I often use the caret package to develop regression models and compare their performance. The foreach package is integrated in caret and can be used to speed up the process through parallel computations. Since caret version 5.01-001, one just need to register the cores with one of the do packages (doMC,etc). This works fine in most of the situations, but there is a problem when I use the M5 algorithm. Everything works well with only one core but computations seem to be stuck with 2 or more registered cores. I am using Rstudio with R 2.13.1 on a Redhat Linux 64-bit machine. Here is an example: library(doMC);library(randomForest);library(RWeka); library(caret) library(mlbench) data(BostonHousing) registerDoMC() options(cores=1) withoutMC - train(medv ~ ., data = BostonHousing, rf)#Works with random forest options(cores=2) usingMC - train(medv ~ ., data = BostonHousing, rf)#Works with random forest options(cores=1) withoutMC - train(medv ~ ., data = BostonHousing, M5)#Works with M5 options(cores=2) usingMC - train(medv ~ ., data = BostonHousing, M5)#Does not work So I tried with another parallel backend (doSNOW), but got another error. library(doSNOW) cl - makeCluster(2, type = SOCK) clusterEvalQ(cl,library(caret)) clusterEvalQ(cl,library(RWeka)) [[1]] [1] RWeka caret foreach codetools iterators cluster reshape plyr [9] lattice snow methods stats graphics grDevices utils datasets [17] base [[2]] [1] RWeka caret foreach codetools iterators cluster reshape plyr [9] lattice snow methods stats graphics grDevices utils datasets [17] base registerDoSNOW(cl) usingSNOW - train(medv ~ ., data = BostonHousing, M5)# Does not work Error in { : task 1 failed - could not find function predictionFunction Here, it does not find predictionFunction (part of the caret package I believe), while I loaded the package into the clusters with clusterEvalQ. Any suggestions? Here are my sessionInfo() and package versions: sessionInfo() R version 2.13.1 (2011-07-08) Platform: x86_64-redhat-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] doSNOW_1.0.5 snow_0.3-7 caret_5.01-001 cluster_1.14.0 reshape_0.8.4 [6] plyr_1.6 lattice_0.19-30mlbench_2.1-0 RWeka_0.4-8 randomForest_4.6-2 [11] doMC_1.2.3 multicore_0.1-7foreach_1.3.2 codetools_0.2-8iterators_1.0.5 loaded via a namespace (and not attached): [1] compiler_2.13.1 grid_2.13.1 rJava_0.9-1 RWekajars_3.7.4-1 tools_2.13.1 packageDescription(caret) Package: caret Version: 5.01-001 Date: 2011-09-01 Title: Classification and Regression Training Author: Max Kuhn. Contributions from Jed Wing, Steve Weston, Andre Williams, Chris Keefer and Allan Engelhardt Description: Misc functions for training and plotting classification and regression models Maintainer: Max Kuhn max.k...@pfizer.com Depends: R (= 2.10), lattice, reshape, stats, plyr, cluster, foreach URL: http://caret.r-forge.r-project.org/ Suggests: gbm, pls, mlbench, rpart, ellipse, ipred, klaR, randomForest, gpls, pamr, kernlab, mda, mgcv, nnet, class, MASS, mboost, earth (= 2.2-3), party (= 0.9-2), ada, affy, proxy, e1071, grid, elasticnet, SDDA, caTools, RWeka (= 0.4-1), superpc, penalized, sparseLDA (= 0.1-1), spls, sda, glmnet, relaxo, lars, vbmp, nodeHarvest, rrcov, gam, stepPlr, GAMens (= 1.1.1), rocc, foba, partDSA, hda, fastICA, neuralnet, quantregForest, rda, HDclassif, LogicReg, LogicForest, logicFS, RANN, qrnn, Boruta, Hmisc, Cubist, bst, leaps License: GPL-2 Packaged: 2011-09-02 14:09:50 UTC; kuhna03 Repository: CRAN Date/Publication: 2011-09-02 18:25:30 Built: R 2.13.1; x86_64-redhat-linux-gnu; 2011-09-16 18:51:38 UTC; unix Thank you very much, Antoine Stevens Earth and Life Institute UCLouvain 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.
[R] Reading data in lisp format
Hi, I am trying to read the credit.lisp file of the Japanese credit database in UCI repository, but it is in lisp format which I do not know how to read. I have not found how to do that in the foreign library http://archive.ics.uci.edu/ml/datasets/Japanese+Credit+Screening http://archive.ics.uci.edu/ml/datasets/Japanese+Credit+Screening Could anyone help me? Best regards, Esteban Alfaro PS: This is my first time in r-help so I apologize for possible inconveniences. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R help on write.csv
Hi, I wanted to write the data created using R on existing csv file. However everytime I use write.csv, it overwrites the values already there in the existing csv file. Any workaround on this. Thanks for your help Ashish Kumar Estee Advisors Pvt. Ltd. Email: ashish.ku...@esteeadvisors.com Cell: +91-9654072144 Direct: +91-124-4637-713 [[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] Data
On 09/20/2011 10:28 PM, barb wrote: Hey everybody, i am using the rugarch-package and its great! I have a pretty easy problem, but i just dont get it, so thanks if you can help me. Normally i use: / data(DATANAME) spec = ugarchspec() fit = ugarchfit(data = x[,1], spec = spec) fit slotNames(fit) names(fit@fit) coef(fit) infocriteria(fit) likelihood(fit) nyblom(fit) signbias(fit) head(as.data.frame(fit)) head(sigma(fit)) head(residuals(fit)) head(fitted(fit)) gof(fit,c(20,30,40,50)) uncmean(fit) uncvariance(fit) plot(fit,which=all)/ I want to use my data now. I figured out how to load excel sheets. setwd(C:/Users/UserofComputer/Desktop) data - read.csv2(Dataname.csv,header=T) attach(data) You do not need to attach 'data', this makes the columns of data available as objects, which is generally not needed. Just refer to the columns as data$column_name. x - CGE[200:1] dx - diff(log(x)) How is my Dataname now safed? I cant use it as data(dataname) unfortunately. The information in Dataname.csv is now in the object data, see summary(data) or str(data). Btw, data is also an R function. Redefining data is not regarded as good programming practice. Furthermore, the use of the data function (as I've used it) is primarily to load datasets which have been packaged along side R. As you've already loaded the dataset using read.csv2, the data(dataname) command is not needed. It seems to me that, no insult intended, you do not know what you are doing. I would recommend you either read some more online introductory material [1], buy some R books, do some kind of R course or find someone that can tutor you. The kind of assistance you need is hard to give via a mailing list. Again, I do not mean to be harsh (we where all R noobs at some stage). good luck, Paul [1] see e.g. http://cran.r-project.org/manuals.html and http://cran.r-project.org/other-docs.html Where is my mistake? Thank you -- View this message in context: http://r.789695.n4.nabble.com/Data-tp3828343p3828343.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. -- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help on write.csv
The append argument of write.csv()? Michael On Sep 21, 2011, at 8:01 AM, Ashish Kumar ashish.ku...@esteeadvisors.com wrote: Hi, I wanted to write the data created using R on existing csv file. However everytime I use write.csv, it overwrites the values already there in the existing csv file. Any workaround on this. Thanks for your help Ashish Kumar Estee Advisors Pvt. Ltd. Email: ashish.ku...@esteeadvisors.com Cell: +91-9654072144 Direct: +91-124-4637-713 [[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] R help on write.csv
I don't think there is an append argument to write.csv() (well, actually there is one, but set to FALSE). There is however one to write.table() Ivan Le 9/21/2011 14:54, R. Michael Weylandt michael.weyla...@gmail.com a écrit : The append argument of write.csv()? Michael On Sep 21, 2011, at 8:01 AM, Ashish Kumarashish.ku...@esteeadvisors.com wrote: Hi, I wanted to write the data created using R on existing csv file. However everytime I use write.csv, it overwrites the values already there in the existing csv file. Any workaround on this. Thanks for your help Ashish Kumar Estee Advisors Pvt. Ltd. Email: ashish.ku...@esteeadvisors.com Cell: +91-9654072144 Direct: +91-124-4637-713 [[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. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Making ?source act as if it is run through the terminal
Hello dear R help, The motivation for my question is wanting to run HTMLStart {R2HTML package} from source. *Background:* I was happy to discover the [ HTMLStart/HTMLStop, HTMLplot] functions in the R2HTML package. They allow my R code to run almost as is, but while writing most of the output (including the figures, when using HTMLplot) into an external HTML file. This method works rather well, but only when the script is running from the terminal. When I try using the code from ?source, the functions fails completely (with both output and especially with figures) I assume the reason is because of what is said in the help file: Note that running code via source differs in a few respects from entering it at the R command line. Since expressions are not executed at the top level, auto-printing is not done. So you will need to include explicit print calls for things you want to be printed *Question:* Hence my question is - can it be avoided? Can the source be set to act just as if the code were to run from the terminal? Thanks, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[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] R help on write.csv
You haven't followed the rules of the posting guide. No reproducible code. No OS or R version. I'm guessing you are a newer R user and didn't know this. So please read that guide. It'll help others to help you more quickly. If you're new you may not know about using ?object. So if you type ?write.csv into the r console it will take you to a help page. There you will see info about the object and in this case append is what you will most likely want to look at. Tyler From: ashish.ku...@esteeadvisors.com To: r-help@r-project.org Date: Wed, 21 Sep 2011 17:31:01 +0530 Subject: [R] R help on write.csv Hi, I wanted to write the data created using R on existing csv file. However everytime I use write.csv, it overwrites the values already there in the existing csv file. Any workaround on this. Thanks for your help Ashish Kumar Estee Advisors Pvt. Ltd. Email: ashish.ku...@esteeadvisors.com Cell: +91-9654072144 Direct: +91-124-4637-713 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Binary optimization problem in R
Michael Haenlein haenlein at escpeurope.eu writes: Dear all, I would like to solve a problem similar to a multiple knapsack problem and am looking for a function in R that can help me. Specifically, my situation is as follows: I have a list of n items which I would like to allocate to m groups with fixed size. Each item has a certain profit value and this profit depends on the type of group the item is in. My problem is to allocate the items into groups so the overall profit is maximized while respecting the fixed size of each group. Take the following example with 20 items (n=5) and 5 groups (m=5): set.seed(1) profits - matrix(runif(100), nrow=20) size-c(2,3,4,5,6) The matrix profits describes the profit of each item when it is allocated to a certain group. For example, when item 1 is allocated to group 1 it generates a profit of 0.26550866. However, when item 1 is allocated to group 2 it generates a profit of 0.93470523. The matrix size describes the size of each group. So group 1 can contain 2 items, group 2 3 items, group 4 4 items, etc. I think this is probably something that could be done with constrOptim() but I'm not exactly sure how. The task you describe is an integer optimization problem and can most likely not be solved with a numeric optimization routine like constrOptim(). In the example above, the solution I get is a maximal profit of 16.31194 with these allocations: group 1: 4, 18 2: 1, 9, 15 3: 3, 6, 11, 12 4: 8, 10, 16, 17, 20 5: 2, 5, 7, 13, 14, 19 (mis)using the mixed-integer package 'lpSolve' in the following way (with 100 binary variables): library(lpSolve) obj - -c(profits) # we will look for a minimum dir - rep(==, 25)# discrete equality constraints rhs - c(c(2,3,4,5,6), rep(1, 20)) # Assign 2, 3, 4, 5, 6 items to groups 1--5 resp. mat - matrix(0, 25, 100); mat[1, 1: 20] - 1; mat[2, 21: 40] - 1 mat[3, 41: 60] - 1; mat[4, 61: 80] - 1; mat[5, 81:100] - 1 # Assign each item to only one group for (i in 1:20) { mat[i+5, c(i, i+20, i+40, i+60, i+80)] - 1 } sol - lp(min, obj, mat, dir, rhs, all.bin=TRUE) # RESULT -sol$objval # 16.31194 # ALLOCATIONS which(sol$solution==1) - rep(seq(0, 80, 20), 2:6) # 4 18 1 9 15 3 6 11 12 8 10 16 17 20 2 5 7 13 14 19 In case you have thousands of items and many groups, packages like 'lpSolve', 'Rglpk', or 'Rsymphony' will not be able to handle the task and you might be forced to look for tools outside the R realm. Hans Werner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] heatmap.2 with colsep and sepwidth
I am using attributes colsep and sepwidth from heatmap.2 function, however when using larger values for sepwidth the following columns are not moved to the right but the seperator is covering the column(s) with a white bar and the column labels and ColSideColors remain at their positions, is this intended? I expected the following columns to be shifted to the right by sepwidth. Is there a way to achieve this? Here is a simple example library(gplots) col - c( rgb(0,100:0,0,maxColorValue=100), rgb(0:100,0,0,maxColorValue=100) ) heatmap.2(matrix(c(1,2,3,4,9,6,7,3), nrow=2), col=col, trace=none, density.info=density, key=FALSE, ColSideColors=rep(blue, 4), denscol=white, scale=row, dendrogram=none, colsep=c(2), sepwidth=1.8) Regards, Christian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] glmnet for Binary trait analysis
The man page tells you that y must be a factor. Is it? -- Bert On Tue, Sep 20, 2011 at 5:25 PM, Noah noah...@hotmail.com wrote: Hello, I got an error message saying Error in lognet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs, : NA/NaN/Inf in foreign function call (arg 5) when I try to analysis a binary trait using glmnet(R) by running the following code library(glmnet) Xori - read.table(c:\\SNP.txt, sep='\t'); Yori - read.table(c:\\Trait.txt, sep=','); Y=as.matrix(Yori); X=t(as.matrix(Xori)); fit1=glmnet(X, Y, family=binomial); in the above, X is a matrix with values 1, 0, and -1; Y is a one column matrix with values 1 and 0. I know how to analysis continuous traits using glmnet, but I have no idea about how to do it for binary dependent variables. I will appreciate it if you would give me any suggestion about this error or provide an example code for handling binary trait using glmnet. Looking forward for your kindly help. Thanks! Noah -- View this message in context: http://r.789695.n4.nabble.com/glmnet-for-Binary-trait-analysis-tp3828547p3828547.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. -- Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions. -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics [[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] R help on write.csv
Touche -- perhaps we could make one though? write.csv.append - function(..., append = TRUE) { Call - match.call(expand.dots = TRUE) for (argname in c(col.names, sep, dec, qmethod)) if (!is.null(Call[[argname]])) warning(gettextf(attempt to set '%s' ignored, argname), domain = NA) rn - eval.parent(Call$row.names) Call$col.names - if (is.logical(rn) !rn) TRUE else NA Call$sep - , Call$dec - . Call$qmethod - double Call[[1L]] - as.name(write.table) eval.parent(Call) } write.csv.append(1:5,test.csv, append = FALSE) write.csv.append(1:15, test.csv) Output seems a little sloppy, but might work for the OP. Michael Weylandt On Wed, Sep 21, 2011 at 9:03 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: I don't think there is an append argument to write.csv() (well, actually there is one, but set to FALSE). There is however one to write.table() Ivan Le 9/21/2011 14:54, R. Michael Weylandt michael.weyla...@gmail.com a écrit : The append argument of write.csv()? Michael On Sep 21, 2011, at 8:01 AM, Ashish Kumarashish.kumar@** esteeadvisors.com ashish.ku...@esteeadvisors.com wrote: Hi, I wanted to write the data created using R on existing csv file. However everytime I use write.csv, it overwrites the values already there in the existing csv file. Any workaround on this. Thanks for your help Ashish Kumar Estee Advisors Pvt. Ltd. Email: ashish.ku...@esteeadvisors.com Cell: +91-9654072144 Direct: +91-124-4637-713 [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-**hamburg.de/mammals/eng/1525_8_**1.phphttp://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Poisson-Gamma computation (parameters and likelihood)
Hi Sebatiano, Take a look at require(MCMCpack) ?MCpoissongamma HTH, Jorge On Wed, Sep 21, 2011 at 5:25 AM, Sebastiano Putoto wrote: Good afternoon/morning readers. This is the first time I am trying to run some Bayesian computation in R, and am experiencing a few problems. I am working on a Poisson model for cancer rates which has a conjugate Gamma prior. 1) The first question is precisely how I work out the parameters. #Suppose I assign values to theta with seq() theta-seq(0,1,len=500) #Then I try out the parameters that seem to fit with a certain prior idea on theta (see next) a=182 b=3530 gaprior-dgamma(theta,a,b) It should work by trial-and-error (according to Bayesian Computation with R) , but how can I check the parameters turned out well: should I just look at the plot, or evaluate it through the 1 - pgamma(x,a,b) function, having knowledge of the 5th percentile (data from US Cancer Statistics)? 2) Then, the next problem I have regards the likelihood distribution. #Having the react table, I name the columns (with y=deaths, and x=exposures) react x y 1 6 15 2 5 16 3 3 12 4 4 6 5 27 77 6 7 17 7 4 11 8 5 10 9 23 63 10 11 29 yr - react[,2] xr - react[,1] #I then compute the likelihood poislike=dpois(yr, theta*xr) #And this is what I come up with, which I really don't understand. poislike [1] 0 0 0 0 0 0 0 0 0 0 The values shouldn't be all null, otherwise my posterior cannot be computed properly. Does anyone have any idea on where I could possibly have messed it up? Thank you very much for your attention. Regards, Sebastiano Putoto (University of Pavia, Italy) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Row percentage labels within mosaic graph
Hi, I have the following sample data x - c(1,2,1,1,2,3,1,2,3,2,3,1,2,2,1,3,2,3,1,3) y - c(1,2,1,2,2,2,1,2,1,1,1,1,2,2,1,2,2,1,2,1) w - c(1, 1, 1.5, 1, 1.2, 0.8, 0.9, 1.7, 1, 1.3, 1, 1, 0.7, 0.8, 1.4, 1.3, 1, 1, 0.9, 0.7) d1 - data.frame(x,y,w) and I wish to build a x,y mosaic graphs that shows as labels both row percentages and number of cases. So far I have been using this script: require(gmodels) require(vcd) d2 - xtabs(~ x + y, data=d1) mosaic ( d2, gp = shading_max, labeling_args = list( gp_labels = gpar(fontsize = 10, fontface = 1), rot_labels = c(0,90,90,0), gp_varnames = gpar(fontsize = 0, fontface = 2) ), main= title, main_gp = gpar(fontsize = 16, fontface = 2), pop=FALSE ) d3 - CrossTable(d1$x,d1$y) etichette - ifelse(d2 5, 5, paste(round(d3$prop.row*100, digits=1),%\n(n=,d2,), sep=)) labeling_cells(text = etichette, clip = FALSE, gp_text=gpar(fontsize=10))(d2) This works just fine but now I have to apply the weight w to the computation. I have modified the first part of the above script to d2 -round(xtabs(w ~ x + y, data=d1), digits=0) mosaic ( d2, gp = shading_max, labeling_args = list( gp_labels = gpar(fontsize = 10, fontface = 1), rot_labels = c(0,90,90,0), gp_varnames = gpar(fontsize = 0, fontface = 2) ), main= title, main_gp = gpar(fontsize = 16, fontface = 2), pop=FALSE ) but I have some difficulty with the labeling part. I can show number of observation in the labels using: d3 - as.list(round(xtabs(w ~ x + y, data=d1)), digits=0) etichette - ifelse(d2 5, 5, paste((n=,d3,), sep=)) labeling_cells(text = etichette, clip = FALSE, gp_text=gpar(fontsize=10))(d2) but I would need to show row proportions, do you know how I can do that? Thanks, Luca Mr. Luca Meyer www.lucameyer.com R version 2.13.1 (2011-07-08) Mac OS X 10.6.8 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding labels to x,y points
A sample data would help. But you could modify as text(x,y, label = row.names(colon[1:20,])) HTH Weidong Gu On Tue, Sep 20, 2011 at 7:43 PM, baumeist mark.baumeist...@gmail.com wrote: Hi, I am new to R. I have a matrix that I have assigned to the object “colon”. colon-read.table(c:\\alon.txt,header=T,row.names=1) attach(colon) names(colon) The dimenstions are 2000 62. Each of the 62 columns (titled norm1, norm2, norm3, etc) has 2000 different numbers (‘continuous’ values) within it. I have also assigned a name for each of the 2000 rows of the dataframe with a prefix (i.e. g1 …. g2000) using the code (not sure if I did this right): colon-paste(g,c(1:nrow(colon)),sep=) I have plotted the first 20 values from two of the columns(samples). x-c(norm1[1:20]) y-c(norm2[1:20]) plot(x,y,type='n',xlab='x norm1 sample',ylab='y norm2 sample',main='Norm1 vs Norm2 - 20 genes') points(x,y,pch=15,col='blue') Now I wish to assign labels to each point (above each point (i.e. pos=3) in the plot with “g1 to g20 corresponding to each row but I am having trouble with this step. I have tried: text(x,y, label = row.names(colon[1:20])) but nothing happens. Any suggestions? Thanks in advance MAB -- View this message in context: http://r.789695.n4.nabble.com/adding-labels-to-x-y-points-tp3828461p3828461.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data in lisp format
Em 21/9/2011 07:39, ESTEBAN ALFARO CORTES escreveu: Hi, I am trying to read the credit.lisp file of the Japanese credit database in UCI repository, but it is in lisp format which I do not know how to read. I have not found how to do that in the foreign library http://archive.ics.uci.edu/ml/datasets/Japanese+Credit+Screeninghttp://archive.ics.uci.edu/ml/datasets/Japanese+Credit+Screening Could anyone help me? Esteban, Lisp files may mean a lot of different things, so it is not enough for an authoritative answer without further qualifications. They _may_ be files that can be read by XLisp-Stat or be a data format coming from another Lisp written program. For the former you could have XLisp-Stat read the file and export in a more manageable format (plain text, csv and for some add ons [like VisTa] to Excel]), for the latter the only option would be to ask the developer of the program or for the structure of the file or for an export to another format R can read. HTH -- Cesar Rabak __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] glmnet for Binary trait analysis
... another possibiity, probably more likely since you read your files in from disk, is that there is a stray character of some sort (e.g. extra comma, quotation mark, period) in your data that is causing what should be numeric data to be read in as character. Check your data after you've read them in. -- Bert On Wed, Sep 21, 2011 at 6:46 AM, Bert Gunter bgun...@gene.com wrote: The man page tells you that y must be a factor. Is it? -- Bert On Tue, Sep 20, 2011 at 5:25 PM, Noah noah...@hotmail.com wrote: Hello, I got an error message saying Error in lognet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs, : NA/NaN/Inf in foreign function call (arg 5) when I try to analysis a binary trait using glmnet(R) by running the following code library(glmnet) Xori - read.table(c:\\SNP.txt, sep='\t'); Yori - read.table(c:\\Trait.txt, sep=','); Y=as.matrix(Yori); X=t(as.matrix(Xori)); fit1=glmnet(X, Y, family=binomial); in the above, X is a matrix with values 1, 0, and -1; Y is a one column matrix with values 1 and 0. I know how to analysis continuous traits using glmnet, but I have no idea about how to do it for binary dependent variables. I will appreciate it if you would give me any suggestion about this error or provide an example code for handling binary trait using glmnet. Looking forward for your kindly help. Thanks! Noah -- View this message in context: http://r.789695.n4.nabble.com/glmnet-for-Binary-trait-analysis-tp3828547p3828547.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. -- Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions. -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics -- Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions. -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics [[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] Package dependency
On 21.09.2011 06:20, Tyler Rinker wrote: Greetings R community, I am making my first package and have run into the need to use other packages. I pass all the checks in the command prompt running Rcmd check package.name. In the Description file I have included: Depends: R (= 2.13), plotrix Repository: CRAN Now I create the zip file for windows 7. I delete my plotrix package from my library to create a setup where others might encounter when installing my package (perhaps they don't have the package dependency plotrix installed). I now install the zip file in my R library and try to load it in R generating the following error: if you have declared stuff as above and CRAN is among the current repositories, install.packages() will install the dependencies for you. Uwe Ligges library(genTools) Loading required package: plotrix Error: package ‘plotrix’ could not be loaded In addition: Warning message: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : there is no package called ‘plotrix’ Now the question: How do I get my package to automatically download dependencies from CRAN as other CRAN packages do when I install them to my library for the first time? Tyler Rinker R version 2.14 (beta) Windows 7 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with function Truncate in package distr
On 21.09.2011 11:53, Duarte Viana wrote: Hello all, Can someone tell me why the following mixture of two log-normal distributions does not get truncated? What puzzles me is that the function works almost always, but for certain combinations (like the one below), it does not. # R code example library(distr) mix-UnivarMixingDistribution(Lnorm(3.2,0.5),Lnorm(5.4,0.6),mixCoeff=c(0.3,0.7)) mix.trunc-Truncate(mix,lower=0.001,upper=3000) distr.sample-r(mix.trunc)(100) range(distr.sample) Why do I get values over 3000 (which was the defoned upper limit)? Some help would be greatly appreciated. Some question for the author of package distr, I believe. Uwe Ligges Duarte Viana __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] chippeakanno package: getAllPeakSequence problem
Hi all, I am using the package ChIPpeakAnno, and I have a problem with the function getAllPeakSequence. This is related to object oriented programming I think, I have the following message: peaksWithSequences - getAllPeakSequence(peakList, upstream = 100, downstream = 100, genome = Hsapiens) Error in validObject(.Object) : invalid class GRanges object: superclass Sequence not defined in the environment of the object's class Is the error coming from my configuration or from the code? I do not know many things about OOP in R. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/chippeakanno-package-getAllPeakSequence-problem-tp3830284p3830284.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] Reading data in lisp format
If you think that R is loosely typed, then examining LiSP code will change your mind, or at least give you a new data point further out on the Loose-Tight axis. I think you will need to do the processing by hand. The organization of the data is fairly clear. There are logical columns with values :neg and :pos, categorical columns with values in (id value) pairs, numeric ones and then a group of computed columns at the bottom. It also appears that after the first enumeration of ids with logical values that subsequent logical variables are defined possibly with pos: values only. So I guess the counter-question is: How important is this particular dataset to you?? And further question might be, are you sure that you don't want the dataset that is right next to it: ftp://ftp.ics.uci.edu/pub/machine-learning-databases/credit-screening/crx.data It is well-behaved comma-separated file. -- David. On Sep 21, 2011, at 6:39 AM, ESTEBAN ALFARO CORTES wrote: Hi, I am trying to read the credit.lisp file of the Japanese credit database in UCI repository, but it is in lisp format which I do not know how to read. I have not found how to do that in the foreign library http://archive.ics.uci.edu/ml/datasets/Japanese+Credit+Screening http://archive.ics.uci.edu/ml/datasets/Japanese+Credit+Screening Could anyone help me? Best regards, Esteban Alfaro PS: This is my first time in r-help so I apologize for possible inconveniences. [[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. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help on write.csv
Michael, You example doesn't seem to work. Append isn't passed on to the write.table call. You will need to add a Call$append- append to the function. And even then there will be a problem with the headers that are repeated when appending. An easier solution is to use write.table directly (I am using Dutch/European csv format): data - data.frame(a=1:10, b=1, c=letters[1:10]) write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE, col.names=TRUE) write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE, col.names=FALSE, append=TRUE) When first openening a file connection and passing that to write.csv or write.table data is also appended. The problem with write.csv is that writing the column names can not be suppressed which will result in repeated column names: con - file(d:\\test2.csv, wt) write.csv2(data, file=con, row.names=FALSE) write.csv2(data, file=con, row.names=FALSE) close(con) So one will still have to use write.table to avoid this: con - file(d:\\test2.csv, wt) write.table(data, file=con, sep=;, dec=,, row.names=FALSE, col.names=TRUE) write.table(data, file=con, sep=;, dec=,, row.names=FALSE, col.names=FALSE, append=TRUE) close(con) Using a file connection is probably also more efficient when doing a large number of appends. Jan Quoting R. Michael Weylandt michael.weyla...@gmail.com: Touche -- perhaps we could make one though? write.csv.append - function(..., append = TRUE) { Call - match.call(expand.dots = TRUE) for (argname in c(col.names, sep, dec, qmethod)) if (!is.null(Call[[argname]])) warning(gettextf(attempt to set '%s' ignored, argname), domain = NA) rn - eval.parent(Call$row.names) Call$col.names - if (is.logical(rn) !rn) TRUE else NA Call$sep - , Call$dec - . Call$qmethod - double Call[[1L]] - as.name(write.table) eval.parent(Call) } write.csv.append(1:5,test.csv, append = FALSE) write.csv.append(1:15, test.csv) Output seems a little sloppy, but might work for the OP. Michael Weylandt On Wed, Sep 21, 2011 at 9:03 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: I don't think there is an append argument to write.csv() (well, actually there is one, but set to FALSE). There is however one to write.table() Ivan Le 9/21/2011 14:54, R. Michael Weylandt michael.weyla...@gmail.com a écrit : The append argument of write.csv()? Michael On Sep 21, 2011, at 8:01 AM, Ashish Kumarashish.kumar@** esteeadvisors.com ashish.ku...@esteeadvisors.com wrote: Hi, I wanted to write the data created using R on existing csv file. However everytime I use write.csv, it overwrites the values already there in the existing csv file. Any workaround on this. Thanks for your help Ashish Kumar Estee Advisors Pvt. Ltd. Email: ashish.ku...@esteeadvisors.com Cell: +91-9654072144 Direct: +91-124-4637-713 [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-**hamburg.de/mammals/eng/1525_8_**1.phphttp://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] chippeakanno package: getAllPeakSequence problem
On 21.09.2011 17:08, Nico902 wrote: Hi all, I am using the package ChIPpeakAnno, and I have a problem with the function getAllPeakSequence. This is related to object oriented programming I think, I have the following message: peaksWithSequences- getAllPeakSequence(peakList, upstream = 100, downstream = 100, genome = Hsapiens) Error in validObject(.Object) : invalid class GRanges object: superclass Sequence not defined in the environment of the object's class We do not know, since we do not know what your objects peakList and Hsapiens are, hence we cannot reproduce anything here. The example works fine for me. Moreover, please ask question related to BioConductor packages on the BioC mailing list. Best, Uwe Ligges Is the error coming from my configuration or from the code? I do not know many things about OOP in R. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/chippeakanno-package-getAllPeakSequence-problem-tp3830284p3830284.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] adding labels to x,y points
#This should work (again, without your data ??) colon-read.table(c:\\alon.txt,header=T,row.names=1) row.names(colon) -paste(g,c(1:nrow(colon)),sep=) with(colon[1:20,], plot(norm1, norm2, type='n',xlab='x norm1 sample',ylab='y norm2 sample',main='Norm1 vs Norm2 - 20 genes')) with(colon, text(norm1, norm2, label = row.names(colon[1:20,])) baumeist wrote: Hi, I am new to R. I have a matrix that I have assigned to the object “colon”. colon-read.table(c:\\alon.txt,header=T,row.names=1) attach(colon) names(colon) The dimenstions are 2000 62. Each of the 62 columns (titled norm1, norm2, norm3, etc) has 2000 different numbers (‘continuous’ values) within it. I have also assigned a name for each of the 2000 rows of the dataframe with a prefix (i.e. g1 …. g2000) using the code (not sure if I did this right): colon-paste(g,c(1:nrow(colon)),sep=) I have plotted the first 20 values from two of the columns(samples). x-c(norm1[1:20]) y-c(norm2[1:20]) plot(x,y,type='n',xlab='x norm1 sample',ylab='y norm2 sample',main='Norm1 vs Norm2 - 20 genes') points(x,y,pch=15,col='blue') Now I wish to assign labels to each point (above each point (i.e. pos=3) in the plot with “g1 to g20 corresponding to each row but I am having trouble with this step. I have tried: text(x,y, label = row.names(colon[1:20])) but nothing happens. Any suggestions? Thanks in advance MAB -- View this message in context: http://r.789695.n4.nabble.com/adding-labels-to-x-y-points-tp3828461p3830363.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] chippeakanno package: getAllPeakSequence problem
On 09/21/2011 08:08 AM, Nico902 wrote: Hi all, I am using the package ChIPpeakAnno, and I have a problem with the function getAllPeakSequence. This is related to object oriented programming I think, I have the following message: peaksWithSequences- getAllPeakSequence(peakList, upstream = 100, downstream = 100, genome = Hsapiens) Error in validObject(.Object) : invalid class GRanges object: superclass Sequence not defined in the environment of the object's class Is the error coming from my configuration or from the code? I do not know many things about OOP in R. Hi Nico902 Please ask questions about this Bioconductor package on the Bioconductor mailing list. http://bioconductor.org/help/mailing-list/ Likely your packages are not at a consistent version. Follow these instructions http://bioconductor.org/install/#update-bioconductor-packages to update your packages. Martin Thanks. -- View this message in context: http://r.789695.n4.nabble.com/chippeakanno-package-getAllPeakSequence-problem-tp3830284p3830284.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. -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] chippeakanno package: getAllPeakSequence problem
On Sep 21, 2011, at 11:08 AM, Nico902 wrote: Hi all, I am using the package ChIPpeakAnno, and I have a problem with the function getAllPeakSequence. This is related to object oriented programming I think, I have the following message: peaksWithSequences - getAllPeakSequence(peakList, upstream = 100, downstream = 100, genome = Hsapiens) Error in validObject(.Object) : invalid class GRanges object: superclass Sequence not defined in the environment of the object's class Is the error coming from my configuration or from the code? I do not know many things about OOP in R. I haven't ever seen that package mentioned on r-help befor, so it is probably a BioC package. Bioconductor which has its own mailing list. There are a small number of persons who are bicultural with ordinary-R and BioC, but they generally suggest to posters to use the BioC list. (I don't know if it has a Nabble interface. I'm guessing it does not.) -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help on write.csv
Michael, You example doesn't seem to work. Append isn't passed on to the write.table call. You will need to add a Call$append- append to the function. And even then there will be a problem with the headers that are repeated when appending. An easier solution is to use write.table directly (I am using Dutch/European csv format): data - data.frame(a=1:10, b=1, c=letters[1:10]) write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE, col.names=TRUE) write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE, col.names=FALSE, append=TRUE) When first openening a file connection and passing that to write.csv or write.table data is also appended. The problem with write.csv is that writing the column names can not be suppressed which will result in repeated column names: con - file(d:test2.csv, wt) write.csv2(data, file=con, row.names=FALSE) write.csv2(data, file=con, row.names=FALSE) close(con) So one will still have to use write.table to avoid this: con - file(d:test2.csv, wt) write.table(data, file=con, sep=;, dec=,, row.names=FALSE, col.names=TRUE) write.table(data, file=con, sep=;, dec=,, row.names=FALSE, col.names=FALSE, append=TRUE) close(con) Using a file connection is probably also more efficient when doing a large number of appends. Jan Quoting R. Michael Weylandt michael.weyla...@gmail.com: Touche -- perhaps we could make one though? write.csv.append - function(..., append = TRUE) { Call - match.call(expand.dots = TRUE) for (argname in c(col.names, sep, dec, qmethod)) if (!is.null(Call[[argname]])) warning(gettextf(attempt to set '%s' ignored, argname), domain = NA) rn - eval.parent(Call$row.names) Call$col.names - if (is.logical(rn) !rn) TRUE else NA Call$sep - , Call$dec - . Call$qmethod - double Call[[1L]] - as.name(write.table) eval.parent(Call) } write.csv.append(1:5,test.csv, append = FALSE) write.csv.append(1:15, test.csv) Output seems a little sloppy, but might work for the OP. Michael Weylandt On Wed, Sep 21, 2011 at 9:03 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: I don't think there is an append argument to write.csv() (well, actually there is one, but set to FALSE). There is however one to write.table() Ivan Le 9/21/2011 14:54, R. Michael Weylandt michael.weyla...@gmail.com a écrit : The append argument of write.csv()? Michael On Sep 21, 2011, at 8:01 AM, Ashish Kumarashish.kumar@** esteeadvisors.com ashish.ku...@esteeadvisors.com wrote: Hi, I wanted to write the data created using R on existing csv file. However everytime I use write.csv, it overwrites the values already there in the existing csv file. Any workaround on this. Thanks for your help Ashish Kumar Estee Advisors Pvt. Ltd. Email: ashish.ku...@esteeadvisors.com Cell: +91-9654072144 Direct: +91-124-4637-713 [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-**hamburg.de/mammals/eng/1525_8_**1.phphttp://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help on write.csv
Michael, You example doesn't seem to work. Append isn't passed on to the write.table call. You will need to add a Call$append- append to the function. And even then there will be a problem with the headers that are repeated when appending. An easier solution is to use write.table directly (I am using Dutch/European csv format): data - data.frame(a=1:10, b=1, c=letters[1:10]) write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE, col.names=TRUE) write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE, col.names=FALSE, append=TRUE) When first openening a file connection and passing that to write.csv or write.table data is also appended. The problem with write.csv is that writing the column names can not be suppressed which will result in repeated column names: con - file(d:test2.csv, wt) write.csv2(data, file=con, row.names=FALSE) write.csv2(data, file=con, row.names=FALSE) close(con) So one will still have to use write.table to avoid this: con - file(d:test2.csv, wt) write.table(data, file=con, sep=;, dec=,, row.names=FALSE, col.names=TRUE) write.table(data, file=con, sep=;, dec=,, row.names=FALSE, col.names=FALSE, append=TRUE) close(con) Using a file connection is probably also more efficient when doing a large number of appends. Jan Quoting R. Michael Weylandt michael.weyla...@gmail.com: Touche -- perhaps we could make one though? write.csv.append - function(..., append = TRUE) { Call - match.call(expand.dots = TRUE) for (argname in c(col.names, sep, dec, qmethod)) if (!is.null(Call[[argname]])) warning(gettextf(attempt to set '%s' ignored, argname), domain = NA) rn - eval.parent(Call$row.names) Call$col.names - if (is.logical(rn) !rn) TRUE else NA Call$sep - , Call$dec - . Call$qmethod - double Call[[1L]] - as.name(write.table) eval.parent(Call) } write.csv.append(1:5,test.csv, append = FALSE) write.csv.append(1:15, test.csv) Output seems a little sloppy, but might work for the OP. Michael Weylandt On Wed, Sep 21, 2011 at 9:03 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: I don't think there is an append argument to write.csv() (well, actually there is one, but set to FALSE). There is however one to write.table() Ivan Le 9/21/2011 14:54, R. Michael Weylandt michael.weyla...@gmail.com a écrit : The append argument of write.csv()? Michael On Sep 21, 2011, at 8:01 AM, Ashish Kumarashish.kumar@** esteeadvisors.com ashish.ku...@esteeadvisors.com wrote: Hi, I wanted to write the data created using R on existing csv file. However everytime I use write.csv, it overwrites the values already there in the existing csv file. Any workaround on this. Thanks for your help Ashish Kumar Estee Advisors Pvt. Ltd. Email: ashish.ku...@esteeadvisors.com Cell: +91-9654072144 Direct: +91-124-4637-713 [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-**hamburg.de/mammals/eng/1525_8_**1.phphttp://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] Power calculation for survival analysis
useR's, I am trying to do a power calculation for a survival analysis using a logrank test and I need some help properly doing this in R. Here is the information that I know: - I have 2 groups, namely HG and LG - Retrospective analysis with subjects gathered from archival data over 20 years. No new recruitment of subjects and no estimated time to target accrual and accrual rate. - Survival measured in both groups at 1 year, 3 years, 5 years. - Assume 50% survival for LG and 30% survival for HG at 5 years. - Assume a 6 month difference in overall survival to be statistically significant. - Total sample size is ~ N=500 with 15% of subjects comprising the LG group; 85% make up the HG group. The main hypothesis is that HG group has shorter overall survival than LG group. Can someone please help me out with how to properly calculate the power for such a situation using R? This is new to me. Thanks, D -- View this message in context: http://r.789695.n4.nabble.com/Power-calculation-for-survival-analysis-tp3830031p3830031.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] logistic regression: default computed probability
Hello all, Suppose in a logistic regression model, the binary outcome is coded as 0 or 1. In SAS, the default probability computed is for Y = 0 (smaller of the two values) . However, in SPSS the probability computed is for Y = 1 (greater of the two values). Which one does R compute, the probability for the smaller or the greater value? I went through the documentation in a hurry but couldn't find a clue. Thanks Nikhil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] logistic regression: default computed probability
On Sep 21, 2011, at 10:25 AM, n wrote: Hello all, Suppose in a logistic regression model, the binary outcome is coded as 0 or 1. In SAS, the default probability computed is for Y = 0 (smaller of the two values) . However, in SPSS the probability computed is for Y = 1 (greater of the two values). Which one does R compute, the probability for the smaller or the greater value? I went through the documentation in a hurry but couldn't find a clue. Thanks Nikhil From ?glm in the Details section: For binomial and quasibinomial families the response can also be specified as a factor (when the first level denotes failure and all others success) or as a two-column matrix with the columns giving the numbers of successes and failures. So P(Y = 1) if using 0/1. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help in interpreting paired t-test
It looks like Bland-Altman procedures would be appropriate for this project (http://en.wikipedia.org/wiki/Bland-Altman_plot). -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Pedro Mardones Sent: Tuesday, September 20, 2011 11:47 AM To: R-help@r-project.org Subject: [R] help in interpreting paired t-test Dear all; A very basic question. I have the following data: A - 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163, 62,112,334,249,45,244,211,175,174,26,375,346,153,32, 89,32,358,202,123,131,88,36,30,67,96,135,219,122, 89,117,86,169,179,54,48,40,54,568,664,277,91,290, 116,80,107,401,225,517,90,133,36,50,174,103,192,150, 225,29,80,199,55,258,97,109,137,90,236,109,204,160, 95,54,50,78,98,141,508,144,434,100,37,22,304,175, 72,71,111,60,212,73,50,92,70,148,28,63,46,85, 111,67,234,65,92,59,118,202,21,17,95,86,296,45, 139,32,21,70,185,172,151,129,42,14,13,75,303,119, 128,106,224,241,112,395,78,89,247,122,212,61,165,30, 65,261,415,159,316,182,141,184,124,223,39,141,103,149, 104,71,259,86,85,214,96,246,306,11,129) B - 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162, 60,108,325,240,44,242,208,168,170,27,356,341,150,31, 85,29,363,185,124,131,85,35,27,63,92,147,217,117, 87,119,81,161,178,53,45,38,50,581,661,254,87,281, 110,76,100,401,220,507,94,123,36,47,154,99,184,146, 232,26,77,193,53,264,94,110,128,87,231,110,195,156, 95,51,50,75,93,134,519,139,435,96,37,21,293,169, 70,80,104,64,210,70,48,88,67,140,26,52,45,90, 106,63,219,62,91,56,113,187,18,14,95,86,284,39, 132,31,22,69,181,167,150,117,42,14,11,73,303,109, 129,106,227,249,111,409,71,88,256,120,200,60,159,27, 63,268,389,150,311,175,136,171,116,220,30,145,95,148, 102,70,251,88,83,199,94,245,305,9,129) plot(A,B) abline(0,1) At a glance, the data look very similar. Data A and B are two measurements of the same variable but using different devices (on a same set of subjects). Thus, I thought that a paired t-test could be appropriate to check if the diff between measurement devices = 0. t.test(A-B) One Sample t-test data: A - B t = 7.6276, df = 178, p-value = 1.387e-12 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.002451622 0.004162903 sample estimates: mean of x 0.003307263 The mean diff is 0.0033 but the p-value indicates a strong evidence to reject H0. I was expecting to find no differences so I'm wondering whether the t-test is the appropriate test to use. I'll appreciate any comments or suggestions. BR, PM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] help in interpreting paired t-test
cor(A, B) [1] 0.9986861 The data are very, very highly correlated. The higher the correlation, the greater the power of the t-test to detect the same difference between the means. Jeremy On 20 September 2011 10:46, Pedro Mardones mardone...@gmail.com wrote: Dear all; A very basic question. I have the following data: A - 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163, 62,112,334,249,45,244,211,175,174,26,375,346,153,32, 89,32,358,202,123,131,88,36,30,67,96,135,219,122, 89,117,86,169,179,54,48,40,54,568,664,277,91,290, 116,80,107,401,225,517,90,133,36,50,174,103,192,150, 225,29,80,199,55,258,97,109,137,90,236,109,204,160, 95,54,50,78,98,141,508,144,434,100,37,22,304,175, 72,71,111,60,212,73,50,92,70,148,28,63,46,85, 111,67,234,65,92,59,118,202,21,17,95,86,296,45, 139,32,21,70,185,172,151,129,42,14,13,75,303,119, 128,106,224,241,112,395,78,89,247,122,212,61,165,30, 65,261,415,159,316,182,141,184,124,223,39,141,103,149, 104,71,259,86,85,214,96,246,306,11,129) B - 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162, 60,108,325,240,44,242,208,168,170,27,356,341,150,31, 85,29,363,185,124,131,85,35,27,63,92,147,217,117, 87,119,81,161,178,53,45,38,50,581,661,254,87,281, 110,76,100,401,220,507,94,123,36,47,154,99,184,146, 232,26,77,193,53,264,94,110,128,87,231,110,195,156, 95,51,50,75,93,134,519,139,435,96,37,21,293,169, 70,80,104,64,210,70,48,88,67,140,26,52,45,90, 106,63,219,62,91,56,113,187,18,14,95,86,284,39, 132,31,22,69,181,167,150,117,42,14,11,73,303,109, 129,106,227,249,111,409,71,88,256,120,200,60,159,27, 63,268,389,150,311,175,136,171,116,220,30,145,95,148, 102,70,251,88,83,199,94,245,305,9,129) plot(A,B) abline(0,1) At a glance, the data look very similar. Data A and B are two measurements of the same variable but using different devices (on a same set of subjects). Thus, I thought that a paired t-test could be appropriate to check if the diff between measurement devices = 0. t.test(A-B) One Sample t-test data: A - B t = 7.6276, df = 178, p-value = 1.387e-12 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.002451622 0.004162903 sample estimates: mean of x 0.003307263 The mean diff is 0.0033 but the p-value indicates a strong evidence to reject H0. I was expecting to find no differences so I'm wondering whether the t-test is the appropriate test to use. I'll appreciate any comments or suggestions. BR, PM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Specifying Start/End Dates for X-axis Range in plot()/xyplot()
On Tue, 20 Sep 2011, David Winsemius wrote: It seems likely even if you got past that error, you would encounter problems from the hashed up syntax in this portion of that plot call: z[, $'Burns Mg'] David, Yes, that's not close to correct. If I specify plot(z[, Burns Mg]) # returned by names(z) I see the plot with the x-axis range from the earliest date for any data (1980-01-01) to the latest date for any data (2011-06-09). What I'm trying to learn is how to specify start and end dates for each of the z names. I have these dates as a list returned by: lapply(1:ncol(z), function(i) range(time(na.omit(z[, i] What I thought might wark was plot(z[, Burns Mg], start = as.Date(1994-01-20), end = as.Date(2009-11-11)) # wrapped in alpine; a single line in emacs but this generates warnings and no plots. In the zoo-quickref vignette are examples of querying dates (bottom of page 1) and selecting a range of dates of interest (page 5, using the window() function), but I cannot extrapolat from these examples to to plot a specified stream/param pair only within explicit start and end dates. Is there documentation I can read that will teach me the proper syntax? Or, can you show me how to specify those dates when plotting z elements? Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tcltk freezes R
was all prebuilt. -- View this message in context: http://r.789695.n4.nabble.com/tcltk-freezes-R-tp3828263p3830663.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] help in interpreting paired t-test
Jeremy, Correlation alone is irrelevant when comparing two separate sets of measurements on the same specimen. Correlation does not mean good agreement, but good agreement tends to infer high correlation. T1 - rnorm(50, mean = 100) mean(T1) [1] 99.80257 T2 - T1 * 1.5 mean(T2) [1] 149.7039 The two measures are off by a systematic 50%, but: cor(T1, T2) [1] 1 The key here, as I noted in my reply yesterday and as Greg noted in his this morning regarding Bland-Altman, is whether or not the two measures agree within an acceptable margin of error and whether or not there is systematic bias in the measures, either overall or perhaps one measure tends to be low at one end of the range, while high at the other. HTH, Marc Schwartz On Sep 21, 2011, at 11:20 AM, Jeremy Miles wrote: cor(A, B) [1] 0.9986861 The data are very, very highly correlated. The higher the correlation, the greater the power of the t-test to detect the same difference between the means. Jeremy On 20 September 2011 10:46, Pedro Mardones mardone...@gmail.com wrote: Dear all; A very basic question. I have the following data: A - 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163, 62,112,334,249,45,244,211,175,174,26,375,346,153,32, 89,32,358,202,123,131,88,36,30,67,96,135,219,122, 89,117,86,169,179,54,48,40,54,568,664,277,91,290, 116,80,107,401,225,517,90,133,36,50,174,103,192,150, 225,29,80,199,55,258,97,109,137,90,236,109,204,160, 95,54,50,78,98,141,508,144,434,100,37,22,304,175, 72,71,111,60,212,73,50,92,70,148,28,63,46,85, 111,67,234,65,92,59,118,202,21,17,95,86,296,45, 139,32,21,70,185,172,151,129,42,14,13,75,303,119, 128,106,224,241,112,395,78,89,247,122,212,61,165,30, 65,261,415,159,316,182,141,184,124,223,39,141,103,149, 104,71,259,86,85,214,96,246,306,11,129) B - 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162, 60,108,325,240,44,242,208,168,170,27,356,341,150,31, 85,29,363,185,124,131,85,35,27,63,92,147,217,117, 87,119,81,161,178,53,45,38,50,581,661,254,87,281, 110,76,100,401,220,507,94,123,36,47,154,99,184,146, 232,26,77,193,53,264,94,110,128,87,231,110,195,156, 95,51,50,75,93,134,519,139,435,96,37,21,293,169, 70,80,104,64,210,70,48,88,67,140,26,52,45,90, 106,63,219,62,91,56,113,187,18,14,95,86,284,39, 132,31,22,69,181,167,150,117,42,14,11,73,303,109, 129,106,227,249,111,409,71,88,256,120,200,60,159,27, 63,268,389,150,311,175,136,171,116,220,30,145,95,148, 102,70,251,88,83,199,94,245,305,9,129) plot(A,B) abline(0,1) At a glance, the data look very similar. Data A and B are two measurements of the same variable but using different devices (on a same set of subjects). Thus, I thought that a paired t-test could be appropriate to check if the diff between measurement devices = 0. t.test(A-B) One Sample t-test data: A - B t = 7.6276, df = 178, p-value = 1.387e-12 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.002451622 0.004162903 sample estimates: mean of x 0.003307263 The mean diff is 0.0033 but the p-value indicates a strong evidence to reject H0. I was expecting to find no differences so I'm wondering whether the t-test is the appropriate test to use. I'll appreciate any comments or suggestions. BR, PM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Power calculation for survival analysis
On Sep 21, 2011, at 8:54 AM, Duke wrote: useR's, I am trying to do a power calculation for a survival analysis using a logrank test and I need some help properly doing this in R. Here is the information that I know: - I have 2 groups, namely HG and LG - Retrospective analysis with subjects gathered from archival data over 20 years. No new recruitment of subjects and no estimated time to target accrual and accrual rate. - Survival measured in both groups at 1 year, 3 years, 5 years. - Assume 50% survival for LG and 30% survival for HG at 5 years. - Assume a 6 month difference in overall survival to be statistically significant. - Total sample size is ~ N=500 with 15% of subjects comprising the LG group; 85% make up the HG group. The main hypothesis is that HG group has shorter overall survival than LG group. Can someone please help me out with how to properly calculate the power for such a situation using R? This is new to me. Thanks, D Short answer, look at the cpower() function in Frank's Hmisc package on CRAN. Longer answer: Have you already performed the data collection and analysis? If so, then performing a post hoc power calculation is highly problematic. Do a Google search on post hoc power and you will find a myriad of resources/citations. Given the sizable differences in the two samples and that this is a retrospective analysis, you are almost certainly going to have selection bias issues to deal with in comparing the two groups, since presumably they were not prospectively randomized to group, even with the ratio indicated. Is the HG group High Grade Lymphoma and the LG group Low Grade Lymphoma? That would help to explain some of the issues here, since you have two groups with differing diagnoses, differing baseline characteristics and known material differences in prognosis. With a retrospective analysis over this time frame, loss to follow up (LTFU) is likely to be another issue, impacting your available data over time, especially if there is a bias in LTFU between the groups. LTFU is hard enough to manage in a prospective study. Using your numbers, you also have the potential for temporal issues impacting your comparison. If you are looking out to 5 years and the data was collected over a 20 year time frame, that suggests a possible 15 year difference between your first patient Time 0 and your last patient Time 0. What changes in patient and/or treatment profiles occurred over time that might impact your findings? Were the two groups treated concurrently or is there a stagger of some time window? Are the patients a consecutive series in each group or is there other selection bias involved as to why one patient is in the study and another is not. If you are not comfortable with these issues, you have a lot of resources at Duke (eg. DCRI) with some very experienced folks there. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Power calculation for survival analysis
Thanks for your response, Marc. HG and LG are high-grade/low-grade tumors. The data has not been collected yet, but will be soon. It's all archived data that will be pulled from computer records. The IRB wants some mention of power or sample size, but doing it for this scenario has been a bit of a head scratcher for me. If it's not really feasible to do a power analysis for this scenario, I can work to explain why to the IRB. D -- View this message in context: http://r.789695.n4.nabble.com/Power-calculation-for-survival-analysis-tp3830031p3830814.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] Making ?source act as if it is run through the terminal
Maybe some of the source() options will work. Suppose you have the following in an R file: junk.R 1:5 x = 1:10 library(ggplot2) data(VADeaths) pl - ggplot(melt(VADeaths),aes(value, X1))+ geom_point() + facet_wrap(~X2)+ylab() pl Then from the command line: source(junk.R) ## No output source(junk.R, print.eval = TRUE) [1] 1 2 3 4 5 and a window displays a graph. Not sure if this will work with the HTML stuff (don't know the first thing about the package), but it seems like a start. Hope this helps, Michael Weylandt On Wed, Sep 21, 2011 at 9:03 AM, Tal Galili tal.gal...@gmail.com wrote: Hello dear R help, The motivation for my question is wanting to run HTMLStart {R2HTML package} from source. *Background:* I was happy to discover the [ HTMLStart/HTMLStop, HTMLplot] functions in the R2HTML package. They allow my R code to run almost as is, but while writing most of the output (including the figures, when using HTMLplot) into an external HTML file. This method works rather well, but only when the script is running from the terminal. When I try using the code from ?source, the functions fails completely (with both output and especially with figures) I assume the reason is because of what is said in the help file: Note that running code via source differs in a few respects from entering it at the R command line. Since expressions are not executed at the top level, auto-printing is not done. So you will need to include explicit print calls for things you want to be printed *Question:* Hence my question is - can it be avoided? Can the source be set to act just as if the code were to run from the terminal? Thanks, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] glmnet for Binary trait analysis
Hi Bert, You are correct. I checked the data and did find some empty values in the X matrix. Thanks for your kindly help! Noah -- View this message in context: http://r.789695.n4.nabble.com/glmnet-for-Binary-trait-analysis-tp3828547p3830581.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] help in interpreting paired t-test
Thanks for all the replies and comments. I've followed Marc's suggestion of using the Bland-Altman's approach which I found pretty clarifying for comparing data collected on the same subjects. BR, PM On Wed, Sep 21, 2011 at 1:39 PM, Marc Schwartz marc_schwa...@me.com wrote: Jeremy, Correlation alone is irrelevant when comparing two separate sets of measurements on the same specimen. Correlation does not mean good agreement, but good agreement tends to infer high correlation. T1 - rnorm(50, mean = 100) mean(T1) [1] 99.80257 T2 - T1 * 1.5 mean(T2) [1] 149.7039 The two measures are off by a systematic 50%, but: cor(T1, T2) [1] 1 The key here, as I noted in my reply yesterday and as Greg noted in his this morning regarding Bland-Altman, is whether or not the two measures agree within an acceptable margin of error and whether or not there is systematic bias in the measures, either overall or perhaps one measure tends to be low at one end of the range, while high at the other. HTH, Marc Schwartz On Sep 21, 2011, at 11:20 AM, Jeremy Miles wrote: cor(A, B) [1] 0.9986861 The data are very, very highly correlated. The higher the correlation, the greater the power of the t-test to detect the same difference between the means. Jeremy On 20 September 2011 10:46, Pedro Mardones mardone...@gmail.com wrote: Dear all; A very basic question. I have the following data: A - 1/1000*c(347,328,129,122,18,57,105,188,57,257,53,108,336,163, 62,112,334,249,45,244,211,175,174,26,375,346,153,32, 89,32,358,202,123,131,88,36,30,67,96,135,219,122, 89,117,86,169,179,54,48,40,54,568,664,277,91,290, 116,80,107,401,225,517,90,133,36,50,174,103,192,150, 225,29,80,199,55,258,97,109,137,90,236,109,204,160, 95,54,50,78,98,141,508,144,434,100,37,22,304,175, 72,71,111,60,212,73,50,92,70,148,28,63,46,85, 111,67,234,65,92,59,118,202,21,17,95,86,296,45, 139,32,21,70,185,172,151,129,42,14,13,75,303,119, 128,106,224,241,112,395,78,89,247,122,212,61,165,30, 65,261,415,159,316,182,141,184,124,223,39,141,103,149, 104,71,259,86,85,214,96,246,306,11,129) B - 1/1000*c(351,313,130,119,17,50,105,181,58,255,51,98,335,162, 60,108,325,240,44,242,208,168,170,27,356,341,150,31, 85,29,363,185,124,131,85,35,27,63,92,147,217,117, 87,119,81,161,178,53,45,38,50,581,661,254,87,281, 110,76,100,401,220,507,94,123,36,47,154,99,184,146, 232,26,77,193,53,264,94,110,128,87,231,110,195,156, 95,51,50,75,93,134,519,139,435,96,37,21,293,169, 70,80,104,64,210,70,48,88,67,140,26,52,45,90, 106,63,219,62,91,56,113,187,18,14,95,86,284,39, 132,31,22,69,181,167,150,117,42,14,11,73,303,109, 129,106,227,249,111,409,71,88,256,120,200,60,159,27, 63,268,389,150,311,175,136,171,116,220,30,145,95,148, 102,70,251,88,83,199,94,245,305,9,129) plot(A,B) abline(0,1) At a glance, the data look very similar. Data A and B are two measurements of the same variable but using different devices (on a same set of subjects). Thus, I thought that a paired t-test could be appropriate to check if the diff between measurement devices = 0. t.test(A-B) One Sample t-test data: A - B t = 7.6276, df = 178, p-value = 1.387e-12 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.002451622 0.004162903 sample estimates: mean of x 0.003307263 The mean diff is 0.0033 but the p-value indicates a strong evidence to reject H0. I was expecting to find no differences so I'm wondering whether the t-test is the appropriate test to use. I'll appreciate any comments or suggestions. BR, PM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with installing tar.gz package
Yay! Thanks! I installed it too! Now the question would be how to use it -- View this message in context: http://r.789695.n4.nabble.com/help-with-installing-tar-gz-package-tp3791086p3830836.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Weighted Average on More than One Variable in Data Frame
Dear R Users, I have looked for a solution to the following problem and I have not been able to find it on the archive, through Google or in the R documentation. I have a data frame, say df, which has 4 variables, one of which I would like to use as a grouping variable (g), another one that I would like to use for my weights (w) The other two variables are variables (x1 and x2) for which I would like to compute the weighted average by group. df - data.frame(x1 = c(15, 12, 3, 10, 10, 14, 12), x2 = c(10, 11, 16, 9, 7, 17, 18), g = c( 1, 1, 1, 2, 2, 3, 3), w = c( 2, 3, 1, 5, 5, 2, 5)) wx1 - sapply(split(df, df$g), function(x){weighted.mean(x$x1, x$w)}) wx2 - sapply(split(df, df$g), function(x){weighted.mean(x$x2, x$w)}) The above code works, the result is: wx1 123 11.5 10.0 12.57143 wx2 123 11.5 8.0 17.71429 But is there not a more elegant way of acting on x1 and x2 simultaneously? Something along the lines of wdf - sapply(split(df, df$g), function(x){weighted.mean(df, x$w)}) which is wrong since df has two columns, while w only has one. I suppose, one could write a loop but that strikes me as being highly inefficient. Thank you very much for your help! Rita -- View this message in context: http://r.789695.n4.nabble.com/Weighted-Average-on-More-than-One-Variable-in-Data-Frame-tp3830922p3830922.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] package / function for monitoring processes?
Here is the function I use: my.stats - function (text = stats, reset = FALSE, oper = ) { procTime - proc.time()[1:3] if (reset) { Level - 1 Stack[Level, ] - c(procTime[3], procTime[1] + procTime[2]) } if (oper == push) { if (Level MaxLevel) Level - Level + 1 Stack[Level, ] - c(procTime[3], procTime[1] + procTime[2]) } .caller - sys.calls() if (length(.caller) == 1) .caller - Rgui else .caller - as.character(.caller[[length(.caller) - 1]])[1] cat(sprintf(%s (%d) - %s : %s %.1f %.1f %.1f : %.1fMB\n, text, Level, .caller, format(Sys.time(), format = %H:%M:%S), procTime[1] + procTime[2] - Stack[Level, 2], procTime[3] - Stack[Level, 1], procTime[3], memory.size())) if ((oper == pop) (Level 1)) Level - Level - 1 else if (oper == reset) Level - 1 invisible(flush.console()) } Here is an example of its use: inside the is the total CPU and elapsed time to that point. my.stats('start') start (1) - Rgui : 14:29:27 30.7 20136.7 20136.7 : 107.8MB for (i in 1:1e6) i+1 # consume some CPU for (i in 1:10e6) i+1 # consume some CPU my.stats('end') # used almost 8 secs of CPU time end (1) - Rgui : 14:30:24 38.4 20193.0 20193.0 : 139.4MB On Tue, Sep 20, 2011 at 9:16 PM, Benjamin Tyner bty...@gmail.com wrote: Hi I recall running across a function a while back which would return information about running processes (such as their cpu and memory usage), but I cannot seem to locate it. Wondering if someone would be kind enough to refresh my memory. I vaguely recall it was parsing the output of the 'ps' command. Thanks, Ben __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Data Munger Guru 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] R help on write.csv
Oh darn, I had that line and then when I copied it to gmail I thought I'd be all slick and clean up my code: oh well...just not my day/thread... It's possible to work around the repeated headers business (change to something like Call$col.names - !append) but yeah, at this point I'm thinking its perhaps better practice to direct the OP to the various connection methods: sink() is nice, but he'll probably have to do something to convert his object to a CSV like string before printing: apply(OBJ, 1, paste, sep=,) Michael Weylandt On Wed, Sep 21, 2011 at 11:20 AM, Jan van der Laan e...@dds.nl wrote: Michael, You example doesn't seem to work. Append isn't passed on to the write.table call. You will need to add a Call$append- append to the function. And even then there will be a problem with the headers that are repeated when appending. An easier solution is to use write.table directly (I am using Dutch/European csv format): data - data.frame(a=1:10, b=1, c=letters[1:10]) write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE, col.names=TRUE) write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE, col.names=FALSE, append=TRUE) When first openening a file connection and passing that to write.csv or write.table data is also appended. The problem with write.csv is that writing the column names can not be suppressed which will result in repeated column names: con - file(d:test2.csv, wt) write.csv2(data, file=con, row.names=FALSE) write.csv2(data, file=con, row.names=FALSE) close(con) So one will still have to use write.table to avoid this: con - file(d:test2.csv, wt) write.table(data, file=con, sep=;, dec=,, row.names=FALSE, col.names=TRUE) write.table(data, file=con, sep=;, dec=,, row.names=FALSE, col.names=FALSE, append=TRUE) close(con) Using a file connection is probably also more efficient when doing a large number of appends. Jan Quoting R. Michael Weylandt michael.weyla...@gmail.com: Touche -- perhaps we could make one though? write.csv.append - function(..., append = TRUE) { Call - match.call(expand.dots = TRUE) for (argname in c(col.names, sep, dec, qmethod)) if (!is.null(Call[[argname]])) warning(gettextf(attempt to set '%s' ignored, argname), domain = NA) rn - eval.parent(Call$row.names) Call$col.names - if (is.logical(rn) !rn) TRUE else NA Call$sep - , Call$dec - . Call$qmethod - double Call[[1L]] - as.name(write.table) eval.parent(Call) } write.csv.append(1:5,test.**csv, append = FALSE) write.csv.append(1:15, test.csv) Output seems a little sloppy, but might work for the OP. Michael Weylandt On Wed, Sep 21, 2011 at 9:03 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: I don't think there is an append argument to write.csv() (well, actually there is one, but set to FALSE). There is however one to write.table() Ivan Le 9/21/2011 14:54, R. Michael Weylandt michael.weyla...@gmail.com a écrit : The append argument of write.csv()? Michael On Sep 21, 2011, at 8:01 AM, Ashish Kumarashish.kumar@** esteeadvisors.com ashish.kumar@esteeadvisors.**comashish.ku...@esteeadvisors.com wrote: Hi, I wanted to write the data created using R on existing csv file. However everytime I use write.csv, it overwrites the values already there in the existing csv file. Any workaround on this. Thanks for your help Ashish Kumar Estee Advisors Pvt. Ltd. Email: ashish.ku...@esteeadvisors.com Cell: +91-9654072144 Direct: +91-124-4637-713 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/**posting-guide.htmlhttp://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-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/**posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de
[R] Quelplot
Hi all, Does anyone have an R implementation of the queplot (K. M. Goldberg and B. Iglewicz. Bivariate extensions of the boxplot. Technometrics, 34(3):pp. 307–320, 1992)? I'm struggling with the estimation of the asymmetry parameters. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University 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] Power calculation for survival analysis
On Sep 21, 2011, at 12:37 PM, Duke wrote: Thanks for your response, Marc. HG and LG are high-grade/low-grade tumors. The data has not been collected yet, but will be soon. It's all archived data that will be pulled from computer records. The IRB wants some mention of power or sample size, but doing it for this scenario has been a bit of a head scratcher for me. If it's not really feasible to do a power analysis for this scenario, I can work to explain why to the IRB. D Hi Derek, My guess is that the IRB wants to have some CYA in terms of the justification for the study. In a design such as this, safety is not the typical concern, since the patients have already been treated and nothing that you are going to do will affect that. More than likely, there may be privacy (e.g. HIPAA) and ethical issues, pertaining to your accessing the medical records of the patients and having a reasonable level of assurance that you will be able to offer some scientific value at the end of the day as a consequence of that access. I don't know the particulars of your IRB, so it may be of value to approach others at Duke who have experience in dealing with them in the setting of a retrospective chart review. You may be able to get a sense for what they are open to in terms of justification and where they may or may not be amenable to a discussion of the pros/cons of this particular approach. It is not uncommon, in my experience, to simply indicate that n = 500 is a convenience sample, based upon some assessment of time/budget limitations and some attempt to assess the number of patients with some common set of characteristics that are likely to be available within a reasonable time frame. In that setting, power as a discrete quantity is not quoted and you don't have an explicit hypothesis to be tested. You get what you get and within the limitations of the study design, can offer some insight into the differences in the two groups. I have seen the same approach even with prospective, non-randomized designs. All of that being said, you can use Frank's cpower() function in Hmisc, if they put a gun to your head. It would not be overly difficult to do that, you just need to be aware of your assumptions and how they can impact the resultant power calculation. Using the function itself is not overly complex. HTH, Marc __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Weighted Average on More than One Variable in Data Frame
Try this sapply(split(df, df$g), function(x) apply(x[, 1:2], 2, weighted.mean, x$w)) Jean StellathePug wrote on 09/21/2011 01:15:33 PM: Dear R Users, I have looked for a solution to the following problem and I have not been able to find it on the archive, through Google or in the R documentation. I have a data frame, say df, which has 4 variables, one of which I would like to use as a grouping variable (g), another one that I would like to use for my weights (w) The other two variables are variables (x1 and x2) for which I would like to compute the weighted average by group. df - data.frame(x1 = c(15, 12, 3, 10, 10, 14, 12), x2 = c(10, 11, 16, 9, 7, 17, 18), g = c( 1, 1, 1, 2, 2, 3, 3), w = c( 2, 3, 1, 5, 5, 2, 5)) wx1 - sapply(split(df, df$g), function(x){weighted.mean(x$x1, x$w)}) wx2 - sapply(split(df, df$g), function(x){weighted.mean(x$x2, x$w)}) The above code works, the result is: wx1 123 11.5 10.0 12.57143 wx2 123 11.5 8.0 17.71429 But is there not a more elegant way of acting on x1 and x2 simultaneously? Something along the lines of wdf - sapply(split(df, df$g), function(x){weighted.mean(df, x$w)}) which is wrong since df has two columns, while w only has one. I suppose, one could write a loop but that strikes me as being highly inefficient. Thank you very much for your help! Rita [[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] Limitations of audio processing in R
Hello everybody I am trying to process audio files in R and had some problems with files size. I´m using R packages 'audio' and 'sound'. I´m trying a really simple thing and it is working well with small sized .wav files. When I try to open huge audio files I received this error message: cannot allocate vector of size 2.7 Gb. My job is open in R a 3-hour .wav file, make six 5-minute random audio subsamples, and than save these new files. I have to do the same process +1500 times. My problems is not in build the function to do the job, but in oppening the 3-hour files. Does anybody knows how to handle big audio files in R? Another package that allows me to do this work? I believe this is a really simple thing, but I really don´t know what to do to solve that memory problem. Thank you very much for your answers, all the best! Ulisses -- View this message in context: http://r.789695.n4.nabble.com/Limitations-of-audio-processing-in-R-tp3831192p3831192.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] Limitations of audio processing in R
If you are running Windows it may be as simple as using memory.limit() to allow R more memory -- if you are on another OS, it may be possible to get the needed memory by deleting various things in your workspace and running gc() Of course, if your computer's memory is 3GB, you are probably going to have trouble with R's keeping all objects in memory and will have to get more creative. Michael On Wed, Sep 21, 2011 at 3:43 PM, Ulisses.Camargo moliterno.cama...@gmail.com wrote: Hello everybody I am trying to process audio files in R and had some problems with files size. I´m using R packages 'audio' and 'sound'. I´m trying a really simple thing and it is working well with small sized .wav files. When I try to open huge audio files I received this error message: cannot allocate vector of size 2.7 Gb. My job is open in R a 3-hour .wav file, make six 5-minute random audio subsamples, and than save these new files. I have to do the same process +1500 times. My problems is not in build the function to do the job, but in oppening the 3-hour files. Does anybody knows how to handle big audio files in R? Another package that allows me to do this work? I believe this is a really simple thing, but I really don´t know what to do to solve that memory problem. Thank you very much for your answers, all the best! Ulisses -- View this message in context: http://r.789695.n4.nabble.com/Limitations-of-audio-processing-in-R-tp3831192p3831192.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. [[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] Problem indexing a factor variable
Hi, I have a dataframe gexp_1 with 115 rows of samples and 27000 columns of gene expression measurements with each column corresponding to one gene. I now have a smaller vector of genes tp for which I need to pull out the data form the data frame. # first gene from the list with 16 genes x - tp[1,] x [1] geneA 16 Levels: geneA, geneB... #unsuccessful gexp_1$x NULL #or gexp_1$x[1] NULL #but this works gexp_1$geneA I am sure that this is a fundamental error on my part since I am new to R, I would appreciate any advice. I am trying to construct a for loop to analyze data for sets of genes at a time but stuck at this step. Regards Rizwan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem indexing a factor variable
Your problem is a fairly common one and it has to do with how factors are stored internally in R. They look like geneA,geneB, etc to you, but to R (for many things) they are kept as integers 1,2,3. It should suffice to set x - as.character(tp[1,]) which forces x to be the string geneA and you can then put that into gexp_1[,x] More generally, you can probably do something like gexp_1[,as.character(tp)] to just get the columns of interest directly. Hope this helps, Michael Weylandt On Wed, Sep 21, 2011 at 4:00 PM, Ahmed, Rizwan rizwan.ah...@csc.mrc.ac.ukwrote: Hi, I have a dataframe gexp_1 with 115 rows of samples and 27000 columns of gene expression measurements with each column corresponding to one gene. I now have a smaller vector of genes tp for which I need to pull out the data form the data frame. # first gene from the list with 16 genes x - tp[1,] x [1] geneA 16 Levels: geneA, geneB... #unsuccessful gexp_1$x NULL #or gexp_1$x[1] NULL #but this works gexp_1$geneA I am sure that this is a fundamental error on my part since I am new to R, I would appreciate any advice. I am trying to construct a for loop to analyze data for sets of genes at a time but stuck at this step. Regards Rizwan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Specifying Start/End Dates for X-axis Range in plot()/xyplot() [RESOLVED]
On Wed, 21 Sep 2011, Rich Shepard wrote: Is there documentation I can read that will teach me the proper syntax? Or, can you show me how to specify those dates when plotting z elements? Got it: extract the window for the times of interest, then plot that window. Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Limitations of audio processing in R
Hi Ulisses! Yes, get more creative -- or get more memory! On the creative side, it may be worth thinking about using an independent (non-R) audio file editor. I'm writing from the standpoint of a Linux/Unixoid user here -- I wouldn;t know how to set ebout this in WIndows. You could use R to create a shell script which would run the editor in such a way as to extract your 6 random samples, and save them, where the script would be fed with the randomly-chosen 5-minute intervals decided by R. This could be done under the control of R, so you could set it up for your 1500 or so sets of samples, which (with the right editing program) could be done quite quickly. On Linux (also available for Windows) a flexible audio editor is 'sox' -- see: http://en.wikipedia.org/wiki/SoX To take, say, a 5-minute sample starting at 1 hour, 10 min and 35sec into the audio file infile.wav, and save this as outfile.wav, you can execute sox infile.wav outfile.wav trim 01:10:35 00:05:00 and such a command could easily be generated by R and fed to a shell script (or simply executed from R by using the system() command). My test just now with a 5-minute long sample from a .wav file was completed in about 5 seconds, so it is quite efficient. There is a huge number of options for 'sox', allowing you to manipulate almost any aspect of the editing. Hoping this helps, Ted. On 21-Sep-11 19:55:22, R. Michael Weylandt wrote: If you are running Windows it may be as simple as using memory.limit() to allow R more memory -- if you are on another OS, it may be possible to get the needed memory by deleting various things in your workspace and running gc() Of course, if your computer's memory is 3GB, you are probably going to have trouble with R's keeping all objects in memory and will have to get more creative. Michael On Wed, Sep 21, 2011 at 3:43 PM, Ulisses.Camargo moliterno.cama...@gmail.com wrote: Hello everybody I am trying to process audio files in R and had some problems with files size. I´m using R packages 'audio' and 'sound'. I´m trying a really simple thing and it is working well with small sized .wav files. When I try to open huge audio files I received this error message: cannot allocate vector of size 2.7 Gb. My job is open in R a 3-hour .wav file, make six 5-minute random audio subsamples, and than save these new files. I have to do the same process +1500 times. My problems is not in build the function to do the job, but in oppening the 3-hour files. Does anybody knows how to handle big audio files in R? Another package that allows me to do this work? I believe this is a really simple thing, but I really don´t know what to do to solve that memory problem. Thank you very much for your answers, all the best! Ulisses E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 21-Sep-11 Time: 22:05:55 -- 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] Limitations of audio processing in R
Also with Linux you can add more swap memory(which I'm pretty sure R spills into if it hasn't reached it's internal limits on 32 bit installations). Windows pagefile is kind of obnoxious. Ken Hutchison On Sep 21, 2554 BE, at 5:05 PM, (Ted Harding) ted.hard...@wlandres.net wrote: Hi Ulisses! Yes, get more creative -- or get more memory! On the creative side, it may be worth thinking about using an independent (non-R) audio file editor. I'm writing from the standpoint of a Linux/Unixoid user here -- I wouldn;t know how to set ebout this in WIndows. You could use R to create a shell script which would run the editor in such a way as to extract your 6 random samples, and save them, where the script would be fed with the randomly-chosen 5-minute intervals decided by R. This could be done under the control of R, so you could set it up for your 1500 or so sets of samples, which (with the right editing program) could be done quite quickly. On Linux (also available for Windows) a flexible audio editor is 'sox' -- see: http://en.wikipedia.org/wiki/SoX To take, say, a 5-minute sample starting at 1 hour, 10 min and 35sec into the audio file infile.wav, and save this as outfile.wav, you can execute sox infile.wav outfile.wav trim 01:10:35 00:05:00 and such a command could easily be generated by R and fed to a shell script (or simply executed from R by using the system() command). My test just now with a 5-minute long sample from a .wav file was completed in about 5 seconds, so it is quite efficient. There is a huge number of options for 'sox', allowing you to manipulate almost any aspect of the editing. Hoping this helps, Ted. On 21-Sep-11 19:55:22, R. Michael Weylandt wrote: If you are running Windows it may be as simple as using memory.limit() to allow R more memory -- if you are on another OS, it may be possible to get the needed memory by deleting various things in your workspace and running gc() Of course, if your computer's memory is 3GB, you are probably going to have trouble with R's keeping all objects in memory and will have to get more creative. Michael On Wed, Sep 21, 2011 at 3:43 PM, Ulisses.Camargo moliterno.cama...@gmail.com wrote: Hello everybody I am trying to process audio files in R and had some problems with files size. I´m using R packages 'audio' and 'sound'. I´m trying a really simple thing and it is working well with small sized .wav files. When I try to open huge audio files I received this error message: cannot allocate vector of size 2.7 Gb. My job is open in R a 3-hour .wav file, make six 5-minute random audio subsamples, and than save these new files. I have to do the same process +1500 times. My problems is not in build the function to do the job, but in oppening the 3-hour files. Does anybody knows how to handle big audio files in R? Another package that allows me to do this work? I believe this is a really simple thing, but I really don´t know what to do to solve that memory problem. Thank you very much for your answers, all the best! Ulisses E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 21-Sep-11 Time: 22:05:55 -- 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] raster plot is empty
Dear R-help, I have a problem plotting maps using the raster package when I use R on my workplace server, but not when I use my own desktop. I suspect the server version must be missing something and was wondering if anyone would have any ideas. The problem occurs after library(raster) f - system.file(external/test.grd, package=raster) r - raster(f) plot(f) On my desktop computer this works perfectly. If I run this on my workplace server then the axes labels are identical, the legend numbers are identical, but the plot is empty and the legend has no colors in it. This persists even if I specify a color explicitly plot(f, col=red) for example. Any help would be appreciated. Kind regards, Alex __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] raster plot is empty
Alex, We definitely need the output of sessionInfo(), the version of raster, and a reproducible example. Without knowing the versions OS, it's impossible to say. But my first guess (and it IS a guess) is that the server needs to be updated. Sarah On Wed, Sep 21, 2011 at 5:45 PM, Alex Olssen alex.ols...@gmail.com wrote: Dear R-help, I have a problem plotting maps using the raster package when I use R on my workplace server, but not when I use my own desktop. I suspect the server version must be missing something and was wondering if anyone would have any ideas. The problem occurs after library(raster) f - system.file(external/test.grd, package=raster) r - raster(f) plot(f) On my desktop computer this works perfectly. If I run this on my workplace server then the axes labels are identical, the legend numbers are identical, but the plot is empty and the legend has no colors in it. This persists even if I specify a color explicitly plot(f, col=red) for example. Any help would be appreciated. Kind regards, Alex -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Limitations of audio processing in R
A more general question: What tools are available in R for reading parts of binary files? 'scan' allows you to 'skip' a certain number of records and read the next 'nlines'. Unfortunately, scan only seems to work for text files not binary, and I cannot find a comparable function that would work for binary files. I tried library(sos); (rb - findFn('read binary')). This produced 299 matches. Something there might solve the problem, but I haven't taken the time to study it carefully. I hope someone else will know. Spencer On 9/21/2011 2:15 PM, Ken wrote: Also with Linux you can add more swap memory(which I'm pretty sure R spills into if it hasn't reached it's internal limits on 32 bit installations). Windows pagefile is kind of obnoxious. Ken Hutchison On Sep 21, 2554 BE, at 5:05 PM, (Ted Harding)ted.hard...@wlandres.net wrote: Hi Ulisses! Yes, get more creative -- or get more memory! On the creative side, it may be worth thinking about using an independent (non-R) audio file editor. I'm writing from the standpoint of a Linux/Unixoid user here -- I wouldn;t know how to set ebout this in WIndows. You could use R to create a shell script which would run the editor in such a way as to extract your 6 random samples, and save them, where the script would be fed with the randomly-chosen 5-minute intervals decided by R. This could be done under the control of R, so you could set it up for your 1500 or so sets of samples, which (with the right editing program) could be done quite quickly. On Linux (also available for Windows) a flexible audio editor is 'sox' -- see: http://en.wikipedia.org/wiki/SoX To take, say, a 5-minute sample starting at 1 hour, 10 min and 35sec into the audio file infile.wav, and save this as outfile.wav, you can execute sox infile.wav outfile.wav trim 01:10:35 00:05:00 and such a command could easily be generated by R and fed to a shell script (or simply executed from R by using the system() command). My test just now with a 5-minute long sample from a .wav file was completed in about 5 seconds, so it is quite efficient. There is a huge number of options for 'sox', allowing you to manipulate almost any aspect of the editing. Hoping this helps, Ted. On 21-Sep-11 19:55:22, R. Michael Weylandt wrote: If you are running Windows it may be as simple as using memory.limit() to allow R more memory -- if you are on another OS, it may be possible to get the needed memory by deleting various things in your workspace and running gc() Of course, if your computer's memory is3GB, you are probably going to have trouble with R's keeping all objects in memory and will have to get more creative. Michael On Wed, Sep 21, 2011 at 3:43 PM, Ulisses.Camargo moliterno.cama...@gmail.com wrote: Hello everybody I am trying to process audio files in R and had some problems with files size. I´m using R packages 'audio' and 'sound'. I´m trying a really simple thing and it is working well with small sized .wav files. When I try to open huge audio files I received this error message: cannot allocate vector of size 2.7 Gb. My job is open in R a 3-hour .wav file, make six 5-minute random audio subsamples, and than save these new files. I have to do the same process +1500 times. My problems is not in build the function to do the job, but in oppening the 3-hour files. Does anybody knows how to handle big audio files in R? Another package that allows me to do this work? I believe this is a really simple thing, but I really don´t know what to do to solve that memory problem. Thank you very much for your answers, all the best! Ulisses E-Mail: (Ted Harding)ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 21-Sep-11 Time: 22:05:55 -- 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.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] Limitations of audio processing in R
Once again, I would myself be inclined to farm this out (in Linux) to the tools which come with the system. In this case the command dd is useful (though one may need to be careful about setting the options. For instance, dd -bs=1 skip=54321 count=31415 if=infile of=outfile would (having set block-size to bs=1 byte) copy count=31415 bytes (blocks) from the input file infile (if=infile), starting at but position 54322 (skip=54321), and write the result to outfile (of=outfile). Ted. On 21-Sep-11 22:08:02, Spencer Graves wrote: A more general question: What tools are available in R for reading parts of binary files? 'scan' allows you to 'skip' a certain number of records and read the next 'nlines'. Unfortunately, scan only seems to work for text files not binary, and I cannot find a comparable function that would work for binary files. I tried library(sos); (rb - findFn('read binary')). This produced 299 matches. Something there might solve the problem, but I haven't taken the time to study it carefully. I hope someone else will know. Spencer On 9/21/2011 2:15 PM, Ken wrote: Also with Linux you can add more swap memory(which I'm pretty sure R spills into if it hasn't reached it's internal limits on 32 bit installations). Windows pagefile is kind of obnoxious. Ken Hutchison On Sep 21, 2554 BE, at 5:05 PM, (Ted Harding)ted.hard...@wlandres.net wrote: Hi Ulisses! Yes, get more creative -- or get more memory! On the creative side, it may be worth thinking about using an independent (non-R) audio file editor. I'm writing from the standpoint of a Linux/Unixoid user here -- I wouldn;t know how to set ebout this in WIndows. You could use R to create a shell script which would run the editor in such a way as to extract your 6 random samples, and save them, where the script would be fed with the randomly-chosen 5-minute intervals decided by R. This could be done under the control of R, so you could set it up for your 1500 or so sets of samples, which (with the right editing program) could be done quite quickly. On Linux (also available for Windows) a flexible audio editor is 'sox' -- see: http://en.wikipedia.org/wiki/SoX To take, say, a 5-minute sample starting at 1 hour, 10 min and 35sec into the audio file infile.wav, and save this as outfile.wav, you can execute sox infile.wav outfile.wav trim 01:10:35 00:05:00 and such a command could easily be generated by R and fed to a shell script (or simply executed from R by using the system() command). My test just now with a 5-minute long sample from a .wav file was completed in about 5 seconds, so it is quite efficient. There is a huge number of options for 'sox', allowing you to manipulate almost any aspect of the editing. Hoping this helps, Ted. On 21-Sep-11 19:55:22, R. Michael Weylandt wrote: If you are running Windows it may be as simple as using memory.limit() to allow R more memory -- if you are on another OS, it may be possible to get the needed memory by deleting various things in your workspace and running gc() Of course, if your computer's memory is3GB, you are probably going to have trouble with R's keeping all objects in memory and will have to get more creative. Michael On Wed, Sep 21, 2011 at 3:43 PM, Ulisses.Camargo moliterno.cama...@gmail.com wrote: Hello everybody I am trying to process audio files in R and had some problems with files size. I´m using R packages 'audio' and 'sound'. I´m trying a really simple thing and it is working well with small sized .wav files. When I try to open huge audio files I received this error message: cannot allocate vector of size 2.7 Gb. My job is open in R a 3-hour .wav file, make six 5-minute random audio subsamples, and than save these new files. I have to do the same process +1500 times. My problems is not in build the function to do the job, but in oppening the 3-hour files. Does anybody knows how to handle big audio files in R? Another package that allows me to do this work? I believe this is a really simple thing, but I really don´t know what to do to solve that memory problem. Thank you very much for your answers, all the best! Ulisses E-Mail: (Ted Harding)ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 21-Sep-11 Time: 22:05:55 -- 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
Re: [R] raster plot is empty
Dear Sarah, I am not sure how to make a reproducible example. The 3 lines of code are exactly what I type in either system. The code can be reproduced, but the result is unlikely to be reproduced - for example on my desktop this all works fine. Is there something more I can do to make this reproducible? Is it helpful if I post the results of sessionInfo() ? Kind regards, Alex On 22 September 2011 09:55, Sarah Goslee sarah.gos...@gmail.com wrote: Alex, We definitely need the output of sessionInfo(), the version of raster, and a reproducible example. Without knowing the versions OS, it's impossible to say. But my first guess (and it IS a guess) is that the server needs to be updated. Sarah On Wed, Sep 21, 2011 at 5:45 PM, Alex Olssen alex.ols...@gmail.com wrote: Dear R-help, I have a problem plotting maps using the raster package when I use R on my workplace server, but not when I use my own desktop. I suspect the server version must be missing something and was wondering if anyone would have any ideas. The problem occurs after library(raster) f - system.file(external/test.grd, package=raster) r - raster(f) plot(f) On my desktop computer this works perfectly. If I run this on my workplace server then the axes labels are identical, the legend numbers are identical, but the plot is empty and the legend has no colors in it. This persists even if I specify a color explicitly plot(f, col=red) for example. Any help would be appreciated. Kind regards, Alex -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Limitations of audio processing in R
Dear Ted, Thank you very much about your answer, it really helped. Now I am working on the function that will do all the job with sox help. All the best, Ulisses 2011/9/21 Ted Harding ted.hard...@wlandres.net Hi Ulisses! Yes, get more creative -- or get more memory! On the creative side, it may be worth thinking about using an independent (non-R) audio file editor. I'm writing from the standpoint of a Linux/Unixoid user here -- I wouldn;t know how to set ebout this in WIndows. You could use R to create a shell script which would run the editor in such a way as to extract your 6 random samples, and save them, where the script would be fed with the randomly-chosen 5-minute intervals decided by R. This could be done under the control of R, so you could set it up for your 1500 or so sets of samples, which (with the right editing program) could be done quite quickly. On Linux (also available for Windows) a flexible audio editor is 'sox' -- see: http://en.wikipedia.org/wiki/SoX To take, say, a 5-minute sample starting at 1 hour, 10 min and 35sec into the audio file infile.wav, and save this as outfile.wav, you can execute sox infile.wav outfile.wav trim 01:10:35 00:05:00 and such a command could easily be generated by R and fed to a shell script (or simply executed from R by using the system() command). My test just now with a 5-minute long sample from a .wav file was completed in about 5 seconds, so it is quite efficient. There is a huge number of options for 'sox', allowing you to manipulate almost any aspect of the editing. Hoping this helps, Ted. On 21-Sep-11 19:55:22, R. Michael Weylandt wrote: If you are running Windows it may be as simple as using memory.limit() to allow R more memory -- if you are on another OS, it may be possible to get the needed memory by deleting various things in your workspace and running gc() Of course, if your computer's memory is 3GB, you are probably going to have trouble with R's keeping all objects in memory and will have to get more creative. Michael On Wed, Sep 21, 2011 at 3:43 PM, Ulisses.Camargo moliterno.cama...@gmail.com wrote: Hello everybody I am trying to process audio files in R and had some problems with files size. Iæ´ using R packages 'audio' and 'sound'. Iæ´ trying a really simple thing and it is working well with small sized .wav files. When I try to open huge audio files I received this error message: cannot allocate vector of size 2.7 Gb. My job is open in R a 3-hour .wav file, make six 5-minute random audio subsamples, and than save these new files. I have to do the same process +1500 times. My problems is not in build the function to do the job, but in oppening the 3-hour files. Does anybody knows how to handle big audio files in R? Another package that allows me to do this work? I believe this is a really simple thing, but I really donæ know what to do to solve that memory problem. Thank you very much for your answers, all the best! Ulisses E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 21-Sep-11 Time: 22:05:55 -- XFMail -- -- Ulisses Moliterno de Camargo Instituto Nacional de Pesquisas da Amazônia [[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] Weighted Average on More than One Variable in Data Frame
Thanks Jean, that worked perfectly! Try this sapply(split(df, df$g), function(x) apply(x[, 1:2], 2, weighted.mean, x$w)) Jean StellathePug wrote on 09/21/2011 01:15:33 PM: I have a data frame, say df, which has 4 variables, one of which I would like to use as a grouping variable (g), another one that I would like to use for my weights (w) The other two variables are variables (x1 and x2) for which I would like to compute the weighted average by group. df - data.frame(x1 = c(15, 12, 3, 10, 10, 14, 12), x2 = c(10, 11, 16, 9, 7, 17, 18), g = c( 1, 1, 1, 2, 2, 3, 3), w = c( 2, 3, 1, 5, 5, 2, 5)) wx1 - sapply(split(df, df$g), function(x){weighted.mean(x$x1, x$w)}) wx2 - sapply(split(df, df$g), function(x){weighted.mean(x$x2, x$w)}) The above code works, the result is: wx1 123 11.5 10.0 12.57143 wx2 123 11.5 8.0 17.71429 But is there not a more elegant way of acting on x1 and x2 simultaneously? Something along the lines of wdf - sapply(split(df, df$g), function(x){weighted.mean(df, x$w)}) which is wrong since df has two columns, while w only has one. I suppose, one could write a loop but that strikes me as being highly inefficient. -- View this message in context: http://r.789695.n4.nabble.com/Weighted-Average-on-More-than-One-Variable-in-Data-Frame-tp3830922p3831611.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] raster plot is empty
Hi, On Wed, Sep 21, 2011 at 6:31 PM, Alex Olssen alex.ols...@gmail.com wrote: Dear Sarah, I am not sure how to make a reproducible example. The 3 lines of code are exactly what I type in either system. The code can be reproduced, but the result is unlikely to be reproduced - for example on my desktop this all works fine. Is there something more I can do to make this reproducible? Ah, I see. You were using data from the raster package, not a local file as it seemed on first glance. Is it helpful if I post the results of sessionInfo() ? Yes, that would be just what I'd asked for. Don't forget the version of raster. Sarah Kind regards, Alex On 22 September 2011 09:55, Sarah Goslee sarah.gos...@gmail.com wrote: Alex, We definitely need the output of sessionInfo(), the version of raster, and a reproducible example. Without knowing the versions OS, it's impossible to say. But my first guess (and it IS a guess) is that the server needs to be updated. Sarah On Wed, Sep 21, 2011 at 5:45 PM, Alex Olssen alex.ols...@gmail.com wrote: Dear R-help, I have a problem plotting maps using the raster package when I use R on my workplace server, but not when I use my own desktop. I suspect the server version must be missing something and was wondering if anyone would have any ideas. The problem occurs after library(raster) f - system.file(external/test.grd, package=raster) r - raster(f) plot(f) On my desktop computer this works perfectly. If I run this on my workplace server then the axes labels are identical, the legend numbers are identical, but the plot is empty and the legend has no colors in it. This persists even if I specify a color explicitly plot(f, col=red) for example. Any help would be appreciated. Kind regards, Alex -- Sarah Goslee http://www.functionaldiversity.org -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] raster plot is empty
Please ensure that it is really the exact same code, I'm sure you did not mean to plot f, but r (for example). Also, sessionInfo results are helpful always - see the posting guide for ways to post better questions. library(raster) Loading required package: sp raster version 1.9-5 (28-July-2011) f - system.file(external/test.grd, package=raster) r - raster(f) Here is f - not r! And the error here is to be expected since f is just a character string. plot(f) Error in plot.window(...) : need finite 'ylim' values In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf Cheers, Mike. On Thu, Sep 22, 2011 at 8:31 AM, Alex Olssen alex.ols...@gmail.com wrote: Dear Sarah, I am not sure how to make a reproducible example. The 3 lines of code are exactly what I type in either system. The code can be reproduced, but the result is unlikely to be reproduced - for example on my desktop this all works fine. Is there something more I can do to make this reproducible? Is it helpful if I post the results of sessionInfo() ? Kind regards, Alex On 22 September 2011 09:55, Sarah Goslee sarah.gos...@gmail.com wrote: Alex, We definitely need the output of sessionInfo(), the version of raster, and a reproducible example. Without knowing the versions OS, it's impossible to say. But my first guess (and it IS a guess) is that the server needs to be updated. Sarah On Wed, Sep 21, 2011 at 5:45 PM, Alex Olssen alex.ols...@gmail.com wrote: Dear R-help, I have a problem plotting maps using the raster package when I use R on my workplace server, but not when I use my own desktop. I suspect the server version must be missing something and was wondering if anyone would have any ideas. The problem occurs after library(raster) f - system.file(external/test.grd, package=raster) r - raster(f) plot(f) On my desktop computer this works perfectly. If I run this on my workplace server then the axes labels are identical, the legend numbers are identical, but the plot is empty and the legend has no colors in it. This persists even if I specify a color explicitly plot(f, col=red) for example. Any help would be appreciated. Kind regards, Alex -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Sumner Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia e-mail: mdsum...@gmail.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] Limitations of audio processing in R
On Thu, Sep 22, 2011 at 8:08 AM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: A more general question: What tools are available in R for reading parts of binary files? 'scan' allows you to 'skip' a certain number of records and read the next 'nlines'. Unfortunately, scan only seems to work for text files not binary, and I cannot find a comparable function that would work for binary files. I tried library(sos); (rb - findFn('read binary')). This produced 299 matches. Something there might solve the problem, but I haven't taken the time to study it carefully. I hope someone else will know. Spencer ?readBin and ?seek Also see Viewing Binary Files with the hexView Package in RNews Volume 7/1, April 2007. http://www.r-project.org/doc/Rnews/Rnews_2007-1.pdf Cheers, Mike. On 9/21/2011 2:15 PM, Ken wrote: Also with Linux you can add more swap memory(which I'm pretty sure R spills into if it hasn't reached it's internal limits on 32 bit installations). Windows pagefile is kind of obnoxious. Ken Hutchison On Sep 21, 2554 BE, at 5:05 PM, (Ted Harding)ted.hard...@wlandres.net wrote: Hi Ulisses! Yes, get more creative -- or get more memory! On the creative side, it may be worth thinking about using an independent (non-R) audio file editor. I'm writing from the standpoint of a Linux/Unixoid user here -- I wouldn;t know how to set ebout this in WIndows. You could use R to create a shell script which would run the editor in such a way as to extract your 6 random samples, and save them, where the script would be fed with the randomly-chosen 5-minute intervals decided by R. This could be done under the control of R, so you could set it up for your 1500 or so sets of samples, which (with the right editing program) could be done quite quickly. On Linux (also available for Windows) a flexible audio editor is 'sox' -- see: http://en.wikipedia.org/wiki/SoX To take, say, a 5-minute sample starting at 1 hour, 10 min and 35sec into the audio file infile.wav, and save this as outfile.wav, you can execute sox infile.wav outfile.wav trim 01:10:35 00:05:00 and such a command could easily be generated by R and fed to a shell script (or simply executed from R by using the system() command). My test just now with a 5-minute long sample from a .wav file was completed in about 5 seconds, so it is quite efficient. There is a huge number of options for 'sox', allowing you to manipulate almost any aspect of the editing. Hoping this helps, Ted. On 21-Sep-11 19:55:22, R. Michael Weylandt wrote: If you are running Windows it may be as simple as using memory.limit() to allow R more memory -- if you are on another OS, it may be possible to get the needed memory by deleting various things in your workspace and running gc() Of course, if your computer's memory is3GB, you are probably going to have trouble with R's keeping all objects in memory and will have to get more creative. Michael On Wed, Sep 21, 2011 at 3:43 PM, Ulisses.Camargo moliterno.cama...@gmail.com wrote: Hello everybody I am trying to process audio files in R and had some problems with files size. I´m using R packages 'audio' and 'sound'. I´m trying a really simple thing and it is working well with small sized .wav files. When I try to open huge audio files I received this error message: cannot allocate vector of size 2.7 Gb. My job is open in R a 3-hour .wav file, make six 5-minute random audio subsamples, and than save these new files. I have to do the same process +1500 times. My problems is not in build the function to do the job, but in oppening the 3-hour files. Does anybody knows how to handle big audio files in R? Another package that allows me to do this work? I believe this is a really simple thing, but I really don´t know what to do to solve that memory problem. Thank you very much for your answers, all the best! Ulisses E-Mail: (Ted Harding)ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 21-Sep-11 Time: 22:05:55 -- 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web:
Re: [R] raster plot is empty
Yes, Mike you are correct. In fact I did use plot(r) The code is exactly the same in both cases - the axis labels have the same numbers, same with the legend - there is just no picture. sessionInfo() for my desktop - where the code works R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 [3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C [5] LC_TIME=English_New Zealand.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] raster_1.9-13 sp_0.9-88 loaded via a namespace (and not attached): [1] grid_2.13.1 lattice_0.19-30 sessionInfo() from the server R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 [3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C [5] LC_TIME=English_New Zealand.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] raster_1.9-13 sp_0.9-88 loaded via a namespace (and not attached): [1] grid_2.13.1 lattice_0.19-30 And I can't see any difference! Kind regards, Alex On 22 September 2011 11:17, Michael Sumner mdsum...@gmail.com wrote: Please ensure that it is really the exact same code, I'm sure you did not mean to plot f, but r (for example). Also, sessionInfo results are helpful always - see the posting guide for ways to post better questions. library(raster) Loading required package: sp raster version 1.9-5 (28-July-2011) f - system.file(external/test.grd, package=raster) r - raster(f) Here is f - not r! And the error here is to be expected since f is just a character string. plot(f) Error in plot.window(...) : need finite 'ylim' values In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf Cheers, Mike. On Thu, Sep 22, 2011 at 8:31 AM, Alex Olssen alex.ols...@gmail.com wrote: Dear Sarah, I am not sure how to make a reproducible example. The 3 lines of code are exactly what I type in either system. The code can be reproduced, but the result is unlikely to be reproduced - for example on my desktop this all works fine. Is there something more I can do to make this reproducible? Is it helpful if I post the results of sessionInfo() ? Kind regards, Alex On 22 September 2011 09:55, Sarah Goslee sarah.gos...@gmail.com wrote: Alex, We definitely need the output of sessionInfo(), the version of raster, and a reproducible example. Without knowing the versions OS, it's impossible to say. But my first guess (and it IS a guess) is that the server needs to be updated. Sarah On Wed, Sep 21, 2011 at 5:45 PM, Alex Olssen alex.ols...@gmail.com wrote: Dear R-help, I have a problem plotting maps using the raster package when I use R on my workplace server, but not when I use my own desktop. I suspect the server version must be missing something and was wondering if anyone would have any ideas. The problem occurs after library(raster) f - system.file(external/test.grd, package=raster) r - raster(f) plot(f) On my desktop computer this works perfectly. If I run this on my workplace server then the axes labels are identical, the legend numbers are identical, but the plot is empty and the legend has no colors in it. This persists even if I specify a color explicitly plot(f, col=red) for example. Any help would be appreciated. Kind regards, Alex -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Sumner Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia e-mail: mdsum...@gmail.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] raster plot is empty
Adding $0.01 to this: Maybe comparing outputs of capabilities() gives some clues. /Henrik On Wed, Sep 21, 2011 at 6:00 PM, Alex Olssen alex.ols...@gmail.com wrote: Yes, Mike you are correct. In fact I did use plot(r) The code is exactly the same in both cases - the axis labels have the same numbers, same with the legend - there is just no picture. sessionInfo() for my desktop - where the code works R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 [3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C [5] LC_TIME=English_New Zealand.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] raster_1.9-13 sp_0.9-88 loaded via a namespace (and not attached): [1] grid_2.13.1 lattice_0.19-30 sessionInfo() from the server R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 [3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C [5] LC_TIME=English_New Zealand.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] raster_1.9-13 sp_0.9-88 loaded via a namespace (and not attached): [1] grid_2.13.1 lattice_0.19-30 And I can't see any difference! Kind regards, Alex On 22 September 2011 11:17, Michael Sumner mdsum...@gmail.com wrote: Please ensure that it is really the exact same code, I'm sure you did not mean to plot f, but r (for example). Also, sessionInfo results are helpful always - see the posting guide for ways to post better questions. library(raster) Loading required package: sp raster version 1.9-5 (28-July-2011) f - system.file(external/test.grd, package=raster) r - raster(f) Here is f - not r! And the error here is to be expected since f is just a character string. plot(f) Error in plot.window(...) : need finite 'ylim' values In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf Cheers, Mike. On Thu, Sep 22, 2011 at 8:31 AM, Alex Olssen alex.ols...@gmail.com wrote: Dear Sarah, I am not sure how to make a reproducible example. The 3 lines of code are exactly what I type in either system. The code can be reproduced, but the result is unlikely to be reproduced - for example on my desktop this all works fine. Is there something more I can do to make this reproducible? Is it helpful if I post the results of sessionInfo() ? Kind regards, Alex On 22 September 2011 09:55, Sarah Goslee sarah.gos...@gmail.com wrote: Alex, We definitely need the output of sessionInfo(), the version of raster, and a reproducible example. Without knowing the versions OS, it's impossible to say. But my first guess (and it IS a guess) is that the server needs to be updated. Sarah On Wed, Sep 21, 2011 at 5:45 PM, Alex Olssen alex.ols...@gmail.com wrote: Dear R-help, I have a problem plotting maps using the raster package when I use R on my workplace server, but not when I use my own desktop. I suspect the server version must be missing something and was wondering if anyone would have any ideas. The problem occurs after library(raster) f - system.file(external/test.grd, package=raster) r - raster(f) plot(f) On my desktop computer this works perfectly. If I run this on my workplace server then the axes labels are identical, the legend numbers are identical, but the plot is empty and the legend has no colors in it. This persists even if I specify a color explicitly plot(f, col=red) for example. Any help would be appreciated. Kind regards, Alex -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Sumner Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia e-mail: mdsum...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] raster plot is empty
Unfortunately the capabilities are identical too. For both systems I get jpeg png tifftcltk X11 aqua http/ftp sockets TRUE TRUE TRUE TRUEFALSEFALSE TRUE TRUE libxml fifo clediticonv NLS profmemcairo TRUEFALSE TRUE TRUE TRUE TRUEFALSE On 22 September 2011 13:09, Henrik Bengtsson h...@biostat.ucsf.edu wrote: Adding $0.01 to this: Maybe comparing outputs of capabilities() gives some clues. /Henrik On Wed, Sep 21, 2011 at 6:00 PM, Alex Olssen alex.ols...@gmail.com wrote: Yes, Mike you are correct. In fact I did use plot(r) The code is exactly the same in both cases - the axis labels have the same numbers, same with the legend - there is just no picture. sessionInfo() for my desktop - where the code works R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 [3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C [5] LC_TIME=English_New Zealand.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] raster_1.9-13 sp_0.9-88 loaded via a namespace (and not attached): [1] grid_2.13.1 lattice_0.19-30 sessionInfo() from the server R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 [3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C [5] LC_TIME=English_New Zealand.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] raster_1.9-13 sp_0.9-88 loaded via a namespace (and not attached): [1] grid_2.13.1 lattice_0.19-30 And I can't see any difference! Kind regards, Alex On 22 September 2011 11:17, Michael Sumner mdsum...@gmail.com wrote: Please ensure that it is really the exact same code, I'm sure you did not mean to plot f, but r (for example). Also, sessionInfo results are helpful always - see the posting guide for ways to post better questions. library(raster) Loading required package: sp raster version 1.9-5 (28-July-2011) f - system.file(external/test.grd, package=raster) r - raster(f) Here is f - not r! And the error here is to be expected since f is just a character string. plot(f) Error in plot.window(...) : need finite 'ylim' values In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf Cheers, Mike. On Thu, Sep 22, 2011 at 8:31 AM, Alex Olssen alex.ols...@gmail.com wrote: Dear Sarah, I am not sure how to make a reproducible example. The 3 lines of code are exactly what I type in either system. The code can be reproduced, but the result is unlikely to be reproduced - for example on my desktop this all works fine. Is there something more I can do to make this reproducible? Is it helpful if I post the results of sessionInfo() ? Kind regards, Alex On 22 September 2011 09:55, Sarah Goslee sarah.gos...@gmail.com wrote: Alex, We definitely need the output of sessionInfo(), the version of raster, and a reproducible example. Without knowing the versions OS, it's impossible to say. But my first guess (and it IS a guess) is that the server needs to be updated. Sarah On Wed, Sep 21, 2011 at 5:45 PM, Alex Olssen alex.ols...@gmail.com wrote: Dear R-help, I have a problem plotting maps using the raster package when I use R on my workplace server, but not when I use my own desktop. I suspect the server version must be missing something and was wondering if anyone would have any ideas. The problem occurs after library(raster) f - system.file(external/test.grd, package=raster) r - raster(f) plot(f) On my desktop computer this works perfectly. If I run this on my workplace server then the axes labels are identical, the legend numbers are identical, but the plot is empty and the legend has no colors in it. This persists even if I specify a color explicitly plot(f, col=red) for example. Any help would be appreciated. Kind regards, Alex -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Sumner Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia e-mail: mdsum...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the
[R] Numbering entries for each subject
Hi R Users I am hoping someone might be able to give some pointers on alternative code to the for loop described below. I have a dataset which is ordered by subject ID and date, what I would like to do is create a new variable that numbers the entries for each person (e.g. 1,2,3,) As an example if we have subjects A, B and C all with multiple entries (have excluded date variable for simplicity), the for loop below achieves the desired result, however my dataset is big (1 million + observations) and the for loop is slow. Is there a more efficient way of getting to the desired result? Many thanks in advance Toni A - data.frame(ID=c('A','A','A','A','B','B','B', 'C','C','C','C','C')) ID 1 A 2 A 3 A 4 A 5 B 6 B 7 B 8 C 9 C 10 C 11 C 12 C A$Session_ID - 0 previous_ID - '' current_index - 1 for ( i in seq(1,nrow(A)) ) { if (A$ID[i] != previous_ID) {current_index - 1} A$Session_ID[i] - current_index previous_ID - A$ID[i] current_index - current_index + 1 } ID Session_ID 1 A 1 2 A 2 3 A 3 4 A 4 5 B 1 6 B 2 7 B 3 8 C 1 9 C 2 10 C 3 11 C 4 12 C 5 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.