Re: [R] Getting the last day of the month.
For 2007: seq(as.Date('2007-02-01'), length = 12, by = "mon") - 1 Current month: seq( as.Date( format( Sys.Date(), "%Y-%m-01")), length = 2, by = "mon")[2] - 1 Eric Patnaik, Tirthankar wrote: > Hi, > Given a date, how do I get the last date of that month? I have > data in the form MM, that I've read as a date using > > >> x$Date <- >> > as.Date(ISOdate(substr(x$YearEnd,1,4),substr(x$YearEnd,5,6),1)) > > But this gives the first day of the month. To get the last day of the > month, I tried > > >> as.Date(as.yearmon(x$Date,frac=0)) >> > > But I don't get the last day of the month here. (Tried frac=1 too.) > > I then add a month to the date, substract one day from the resultant > date. But this wouldn't work for December. > > >> x$YearEnd >> > [1] 200203 200303 200403 200503 200603 200603 200312 200503 200603 > 200203 200303 > [12] 200403 200503 200512 200612 200203 200303 200403 200503 200603 > >> x$Date <- as.Date(ISOdate(substr(x$YearEnd,1,4), >> > + as.integer(substr(x$YearEnd,5,6))+1, > + 1))-1 > >> x$Date >> > [1] "2002-03-31" "2003-03-31" "2004-03-31" "2005-03-31" "2006-03-31" > "2006-03-31" > [7] NA "2005-03-31" "2006-03-31" "2002-03-31" "2003-03-31" > "2004-03-31" > [13] "2005-03-31" NA NA "2002-03-31" "2003-03-31" > "2004-03-31" > [19] "2005-03-31" "2006-03-31" > > So I add a year, and set the month to 1 in a quick function. > > >> GetEOM <- function(mm=200406){ >> > year <- as.integer(substr(mm,1,4)) > month <- as.integer(substr(mm,5,6)) > if (month==12){ > date <- as.Date(ISOdate(year+1,1,1))-1 > }else{ > date <- as.Date(ISOdate(year,month+1,1))-1 > } > print(date) > } > > x$Date <- as.vector(sapply(x$YearEnd,GetEOM)) > > str(x$Date) > > > Is there a simpler way to do this please? > > > TIA and best, > -Tir > > Tirthankar Patnaik > India Strategy > Citigroup Investment Research > +91-22-6631 9887 > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] CGIwithR and visible output of 'invisible(capture.output(library(...)))'
library(R2HTML, verbose = FALSE) Leo Gürtler wrote: > Dear alltogether, > > I want to use CGIwithR in conjunction with R2HTML. > > A small example called 'test.R': > > # > > #! /usr/bin/R > invisible(capture.output(library(R2HTML))) > HTML(summary(as.numeric(scanText(formData$numbers))), file=stdout()) > > # > > The script gets its input via 'CGIwithR.cgi' and contains the variable > "numbers." > > The 'HTML' output (-> summary() in this example) goes well, but the > loading of the R2HTML library is also printed (!) in the resulting html > page. > > As I took the example from the original CGIwithR examples and I also > read the manpages of invisible() and capture.output(), I do not find a > logical reason why this still happens. > > Deleting the line with "invisible ... library().." and adding > 'library(R2HTML)' to .Rprofile does not solve the problem. > > I use ubuntu edgy, R Version 2.3.1 (2006-06-01) > > THANKS! > > best wishes, > > leo > > > PS: the output is (uncut) > > <> > MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant more > info at http://www.winimage.com/zLibDll/unzip.html > /usr/local/lib/R/site-library/R2HTML/output/R2HTMLstuff.zip opened > extracting: ASCIIMathML.js extracting: factor.gif extracting: > gridR2HTML.css extracting: gridR2HTML.js extracting: numeric.gif > extracting: Pastel.css extracting: R2HTML.css extracting: R2HTMLlogo.gif > creating directory: runtime/ creating directory: runtime/lib/ > extracting: runtime/lib/grid.js extracting: runtime/readme.txt creating > directory: runtime/styles/ creating directory: runtime/styles/classic/ > extracting: runtime/styles/classic/gecko.xml extracting: > runtime/styles/classic/grid.css extracting: > runtime/styles/classic/grid.png extracting: > runtime/styles/classic/icons.png extracting: > runtime/styles/classic/loading.gif creating directory: > runtime/styles/flat/ extracting: runtime/styles/flat/gecko.xml > extracting: runtime/styles/flat/grid.css extracting: > runtime/styles/flat/grid.png extracting: runtime/styles/flat/icons.png > extracting: runtime/styles/flat/loading.gif creating directory: > runtime/styles/xp/ extracting: runtime/styles/xp/gecko.xml extracting: > runtime/styles/xp/grid.css extracting: runtime/styles/xp/grid.png > extracting: runtime/styles/xp/icons.png extracting: > runtime/styles/xp/loading.gif extracting: SciViews.css extracting: > tablesort.htc > > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R in Industry
Conversely, unqualified(*) candidates are nearly guaranteed to find support scarce here. More seriously, free job boards, highly targeted like the one proposed do seem to get enough traffic to make it worth the effort to post there. One example serving the US market for market research is here: http://quirks.com/jobmart/search.asp Heck, it could even become a revenue resource for the R Project foundation if members and supporting institutions got little gold stars with their postings or some such. Eric * Defined as "Unable to follow posting guidelines." Bert Gunter wrote: > "... two main drawbacks of R at our firm (as viewed by our IT dept) are lack > of > guaranteed support as well as the difficulty in finding candidates. > > > -- Just an aside: "lack of guaranteed support" -- absolutely true in theory, > absolutely false in practice. I doubt that the voluntary support found on > r-help and other R lists can be matched by the "guaranteed" support of any > commercial software product. Not that this makes a difference to the IT > group's requirements, of course... > > Cheers, > Bert > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RSPerl Causes Segfaults with Perl 5.8.0 and R 1.9.1 on Redhat9
RSPerl causes random segfaults (it occassionally works) in Rf_isValidName () from /usr/lib/R/bin/libR.so when I call wilcox.test on some perl array references. This is with R built from the r-project source RPM modified to have the --enable-shared-R option and RSPerl built with the default options, except for having to set PERL_MODULES to not include modperl or Apache. any ideas? eric. -- http://ir.iit.edu/~ej __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] randomForest partialPlot x.var through function
All, I'm trying to set up a function which calls the partialPlot function but am getting an error that I can't seem to solve. Here's a simplified version of the function and error... > pplot <- function(rf,pred.var){partialPlot(x=rf,pred.data=acoust,x.var=pred.var)} > > attach(acoust) > acoust.rf <- randomForest(VocalTF~Cruise+Spot+Spin+Delph+Stripe+Steno+Turs+Gramp+Lags+ + Lisso+FerPsu+Glob+mixspotspin+mixother+mixed+Size, + data=acoust,importance=TRUE,keep.forest=TRUE) > cruise.pp <- pplot(acoust.rf,Cruise) Error in "[.data.frame"(pred.data, , xname) : undefined columns selected Here's the traceback call... > traceback() 6: stop("undefined columns selected") 5: "[.data.frame"(pred.data, , xname) 4: pred.data[, xname] 3: partialPlot.randomForest(x = rf, pred.data = acoust, x.var = pred.var) 2: partialPlot(x = rf, pred.data = acoust, x.var = pred.var) 1: pplot(acoust.rf, Cruise) From the partialPlot help file, the "pred.data[, xname]" seems to apply to the "n.pt" argument which reads, "if 'x.var' is continuous, the number of points on the grid for evaluating partial dependence." It is not clear to me what "xname" is or where it is defined. If it is supposed to be "x.var" where does it get assigned? I've tried help.search("xname") to no useful avail that I could tell. Second, in my case, "acoust$Cruise" is a factor and the line > cruise.pp <- partialPlot(acoust.rf,acoust,Cruise) produces the proper plot. Which leads me to belive that I'm doing something wrong in how I'm passing "Cruise" through "pred.var" in the function call to "x.var", but I can't figure out how to properly correct it. Thanks in advance for any pointers. e. -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] attached file with syntax error
Well... You just can't end vector declaration with a comma... > x <- c(0,1,) Error: syntax error > x <- c(0,1) Eric Eric Lecoutre UCL / Institut de Statistique Voie du Roman Pays, 20 1348 Louvain-la-Neuve Belgium tel: (+32)(0)10473050 [EMAIL PROTECTED] http://www.stat.ucl.ac.be/ISpersonnel/lecoutre If the statistics are boring, then you've got the wrong numbers. -Edward Tufte > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] > Sent: vendredi 20 mai 2005 11:39 > To: r-help@stat.math.ethz.ch > Subject: [R] attached file with syntax error > > > > > oops, I forgot to attach the example txt file with the syntax > error, so I will do it here, can anyone see what the error is > with bryansAtLineLevel? > > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Question on read.table
Hi This is possbible to read AREMOS file with read.table function. The AREMOS format come from DRI-WEFA and is uses with Eviews Thanks *** AVIS DE NON-RESPONSABILITE:\ Ce document transmis par courri...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] a more elegant approach to getting the majority level
You could also use: > names(rev(sort(table(x[1] There is nonetheless a difference if there are several levels which provides this maximum. This method will only return one, yours would return all those levels (which may not be desirable for some others processing). HTH, Eric Eric Lecoutre UCL / Institut de Statistique Voie du Roman Pays, 20 1348 Louvain-la-Neuve Belgium tel: (+32)(0)10473050 [EMAIL PROTECTED] http://www.stat.ucl.ac.be/ISpersonnel/lecoutre If the statistics are boring, then you've got the wrong numbers. -Edward Tufte > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Rajarshi Guha > Sent: jeudi 26 mai 2005 16:37 > To: R > Subject: [R] a more elegant approach to getting the majority level > > > Hi, I have a factor and I would like to find the most frequent level. > > I think my current approach is a bit long winded and I was > wondering if there was a more elegant way to do it: > > x <- factor(sample(1:0, 5,replace=TRUE)) > > levels(x)[ which( as.logical((table(x) == max(table(x == TRUE ) ] > > (The length of x will always be an odd number, so I wont get a tie in > max()) > > Thanks, > > --- > Rajarshi Guha <[EMAIL PROTECTED]> <http://jijo.cjb.net> > GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE > --- > Alcohol, an alternative to your self > - 'Alcohol' by the Bare Naked Ladies > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] DEM calculation
You can use ´expand.grid' » expand.grid(x=seq(42.2,45.2,by=1),y=seq(50.5,51.5,by=1)) xy 1 42.2 50.5 2 43.2 50.5 3 44.2 50.5 4 45.2 50.5 5 42.2 51.5 6 43.2 51.5 7 44.2 51.5 8 45.2 51.5 Eric Eric Lecoutre UCL / Institut de Statistique Voie du Roman Pays, 20 1348 Louvain-la-Neuve Belgium tel: (+32)(0)10473050 [EMAIL PROTECTED] http://www.stat.ucl.ac.be/ISpersonnel/lecoutre If the statistics are boring, then you've got the wrong numbers. -Edward Tufte > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Lars Claussen > Sent: jeudi 2 juin 2005 10:56 > To: R-help@stat.math.ethz.ch > Subject: [R] DEM calculation > > > Hello R-World, > > i am trying to calculate data for a DEM (Digital Elavation > Model) which i also want to plot in R. i have the coordinates > for the lower left corner which look something like this: > > x<-42,2 > y<-50,5 > > besides i have the cellsize of the grid, which is: > > z<-1,1 > > what i do is to calculate the corrdinates of the cells to the > right and top, what i can do by specifying the number of rows > and columns. these are j<-1:805 (columns) i<-1:616 (rows) > > well, to calculate them seperatly is easy: > > r<-x+(i-1)*z > h<-y+(j-1)*z > > but i can't get it straight how to create a data frame with > two rows, one for the x- the other for the y-coordinate. The > problem is, that lots of values have to be repeated as every > first row x-coordinate has the same y-coordinate and so on. > > finally it should look like this: > > xy > 42,2 50,5 > 43,3 50,5 > 44,4 50,5 > 45,5 50,5 > . . > . . > 42,2 51,5 > 43,3 51,5 > 44,3 51,5 > > any suggestion? thanks in advance, Lars Claussen > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] R code for performance
You could use the benchmark created by Philippe Grosjean to compare various statistical packages. You will find it at: http://www.sciviews.org/benchmark/ Note that you have to ensure to have installed packages: Matrix and SuppDist HTH, Eric Eric Lecoutre UCL / Institut de Statistique Voie du Roman Pays, 20 1348 Louvain-la-Neuve Belgium tel: (+32)(0)10473050 [EMAIL PROTECTED] http://www.stat.ucl.ac.be/ISpersonnel/lecoutre If the statistics are boring, then you've got the wrong numbers. -Edward Tufte > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: lundi 6 juin 2005 10:10 > To: r-help > Subject: [R] R code for performance > > > At office I'm cautiously introducing R to be used as the > basic statistical program, getting rid of licensed stuff or > reducing the amount of it. The aim of R would be to run > generic statistical programs built & "consumed" when needed > and some static procedure dealing with time-series. Now, we > have substantially 3 OS platforms, win xp, linux and freebsd > 5.4, on similar PCs (pentium 4, 2-2.5 GHz). I have been asked > by the boss to test the "average" performance (in term of > speed and memory use) of R on each of this platform to stick > with one of them on a couple of PCs. > > Could you please suggest an R source code (apart from the > "static procedure" I will obviously test) to be run on the > three platforms to test performance? > > If there is nothing of the kind, any suggestion? > > Ciao > Vittorio > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] ROMA project (R Output MAnager) / Progress report / Call for contributors
Hello useRs, This email is about the ROMA project, the implementation in pure S of a reporting system for R. Several month ago, I did then send on R-help a survey on that (mainly: what features did you expect for a reporting system). During the following months, I did try different approaches for the core functionalities, ending now with a set of generic functions of which I am satisfied. More details about the coding later for those who are interested. Basically, my purpose is to provide to R a mechanism to describe outputs, in term of structure/content. Then, some driver functions would handle output object to export them in HTML, LaTeX, RTF, raw text, and so on. While progressing in that project, I also did realize that it could even be an intersting alternative to "print." method: each package creator who write a "print.myclass" function only needs to describe output. If he could do that once and benefit from HTML, TeX,... this would be of great advantage. I am currently seeking for a new job and I dont know if I will have time later to go on with that project, which appears to be rather big. That's why I am searching for collaborators. Anyone interested in reporting may help. See below for a (non exhaustive) list of tasks / competences. I have to say that in any cases I am interested in keeping involved in that problematic. My latest implementation consists in 2 x 1000 lines of highly commented code. Mainly 1000 lines for the core functions and 1000 lines for the beginning of the HTML export driver. Each output object consist of a XML internal representation (using Duncan Temple Lang XML package), which gives folowing advantages: - any output structure could be described (even "non-linear") - any output "brick" could contain things and have properties (that's XML node / properties) - we do have a DOM directly - XML exportation driver is already functional Some goals which are already achieved: - describing complex tables (with merged cells, containing footnotes etc) - representing output as internal objects (for storing/further manipulating purposes) - manipulating those output objects ("+" operator, changing properties) There is some work for volonteers in numerous areas: - reading my actual code and helping to improve it - thinking about required fundamentals "bricks" to describe outputs (footnote, p-value, comment, are some sample such "bricks") - implementing functions that describes some standards outputs - implementing exporting drivers: LaTeX, native PDF, RTF, raw tex - ... Please let me know if you are interested in particpating to this project. If there are enough participants, I will consider using a shared platform such as freshmeat or other. Eric Eric Lecoutre UCL / Institut de Statistique Voie du Roman Pays, 20 1348 Louvain-la-Neuve Belgium tel: (+32)(0)10473050 [EMAIL PROTECTED] http://www.stat.ucl.ac.be/ISpersonnel/lecoutre If the statistics are boring, then you've got the wrong numbers. -Edward Tufte __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] htlm3D made4
have you tried using Google using keyword "made4" ??? The second item gives: made4 Package: made4. Description: Multivariate data analysis and graphical display of microarray data. Functions include between group analysis and coinertia ... www.bioconductor.org/repository/devel/package/html/made4.html - 2k - 6 Jun 2005 - Cached - Similar pages And then later: http://bioinf.ucd.ie/people/aedin/R/ HTH, Eric ps: google is your best friend Eric Lecoutre UCL / Institut de Statistique Voie du Roman Pays, 20 1348 Louvain-la-Neuve Belgium tel: (+32)(0)10473050 [EMAIL PROTECTED] http://www.stat.ucl.ac.be/ISpersonnel/lecoutre If the statistics are boring, then you've got the wrong numbers. -Edward Tufte > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Navarre Sabine > Sent: mardi 7 juin 2005 15:15 > To: r-help@stat.math.ethz.ch > Subject: [R] htlm3D made4 > > > Hi, > > I would like to know if people have found the package made4 > to load! I would like the .zip > > If you have the @ on internet to load it please give me it! > > Thanks a lot, > > Sabine > > > - > > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] lme model specification
Dear All, I am trying to specify the following fixed effects model for lme: y ~ constant1 - beta1*(x - beta2) where y is the response, x is the independent variable, and the operators above are real arithmetic operations of addition, subtraction, and multiplication. I realize that this model is just a reparameterization of y=beta0+beta1*x, but I am using this parameterization because I am specifically interested in confidence bounds for beta2. I have looked at the help, but the closest hint I find is the I() function, and that does not seem to work this way. I confess that I am actually using S-plus, but there does not seem to be a resource like this list for S-plus. Any help would be greatly appreciated. Kind regards, Eric [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] lme model specification
Thanks for the response. It is actually a repeated measures study, I just mention the fixed effects specification because I think I know the random effect specification, i.e.: Random = ~ 1|subject And thanks for the tip about the nonlinear model and the S-plus list. I will check out nlme and the other list. Eric On 6/9/05, Eric Hack <[EMAIL PROTECTED]> wrote: > Dear All, > > > > I am trying to specify the following fixed effects model for lme: If you have a linear fixed-effects model you should use lm, not lme. > > y ~ constant1 - beta1*(x - beta2) > > where y is the response, x is the independent variable, and the > operators above are real arithmetic operations of addition, subtraction, > and multiplication. I realize that this model is just a > reparameterization of y=beta0+beta1*x, but I am using this > parameterization because I am specifically interested in confidence > bounds for beta2. You would need to fit that as a nonlinear model. In reference to such models "linear" means "linear in the parameters" and that model isn't. > I have looked at the help, but the closest hint I find is the I() > function, and that does not seem to work this way. > > > > I confess that I am actually using S-plus, but there does not seem to be > a resource like this list for S-plus. Look for the S-news email list (http://www.biostat.wustl.edu/s-news/) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] c(recursive=TRUE)
Hi R users, I am currently using c(...,recursive=TRUE) to handle list-structured objects. This allows to represent something like: > l1 = list(level1=1,level2=list(sub1=1,sub2=2)) as: > (l1names = names(c(l1,recursive=TRUE))) [1] "level1" "level2.sub1" "level2.sub2" Then, one can use: > (l1names = sapply(l1names,FUN=function(element) strsplit(element,"\\."))) $level1 [1] "level1" $level2.sub1 [1] "level2" "sub1" $level2.sub2 [1] "level2" "sub2" Which allows to access to individuals terminal nodes of list using indexing, as l1[[c("level2","sub2")]] nicely works in R. For my very specific uses, it unfortunatelt happens that some elements of my list do have names that contains a dot (for example: decimal.mark). This is very frustating as a consequence is that my function does not work in that case... One workaround would be to add an argument to c(), as delimitor='.' by default, allowing to put a less usual delimitor (say "§"). But this would mean changing in C (feature request?). Same for "unlist". Is there any other easy way to get the structure of a list? Eric Eric Lecoutre UCL / Institut de Statistique Voie du Roman Pays, 20 1348 Louvain-la-Neuve Belgium tel: (+32)(0)10473050 [EMAIL PROTECTED] http://www.stat.ucl.ac.be/ISpersonnel/lecoutre If the statistics are boring, then you've got the wrong numbers. -Edward Tufte __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] quick way to construct formula
Here is a way: it uses 'paste' but I dont think it is a problem anyway to use it. Nevertheless, it is surely a bad idea to fit any model with more than 25 terms... > main_effects = paste(nam,collapse="+") > inter <- outer(nam,nam,paste,sep=":") > inter <- paste(inter[upper.tri(inter)],collapse="+") > log_effects <- paste("log(",nam,")",sep="",collapse="+") > as.formula(paste("~",main_effects,"+",inter,"+",log_effects,sep="")) ~x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x1:x2 + x1:x3 + x2:x3 + x1:x4 + x2:x4 + x3:x4 + x1:x5 + x2:x5 + x3:x5 + x4:x5 + x1:x6 + x2:x6 + x3:x6 + x4:x6 + x5:x6 + x1:x7 + x2:x7 + x3:x7 + x4:x7 + x5:x7 + x6:x7 + x1:x8 + x2:x8 + x3:x8 + x4:x8 + x5:x8 + x6:x8 + x7:x8 + x1:x9 + x2:x9 + x3:x9 + x4:x9 + x5:x9 + x6:x9 + x7:x9 + x8:x9 + x1:x10 + x2:x10 + x3:x10 + x4:x10 + x5:x10 + x6:x10 + x7:x10 + x8:x10 + x9:x10 + log(x1) + log(x2) + log(x3) + log(x4) + log(x5) + log(x6) + log(x7) + log(x8) + log(x9) + log(x10) HTH, Eric Eric Lecoutre UCL / Institut de Statistique Voie du Roman Pays, 20 1348 Louvain-la-Neuve Belgium tel: (+32)(0)10473050 [EMAIL PROTECTED] http://www.stat.ucl.ac.be/ISpersonnel/lecoutre If the statistics are boring, then you've got the wrong numbers. -Edward Tufte > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Luke > Sent: mercredi 29 juin 2005 4:49 > To: R-help@stat.math.ethz.ch > Subject: [R] quick way to construct formula > > > Dear R users, > > I have a data with 1000 variables named "x1", "x2", ..., > "x1000", and I want to construct a formula like this format: > > ~x1+x2+...+x1000+x1:x2+x1:x3+x999:x1000+log(x1)+...+log(x1000) > > That is: the base variables followed by all interaction terms > and all base feature log-transformations. I know I can use > several paste functions to construct it. But is there any > other handy way to do it? > > -Luke > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Sample Datasets for binary classifiers
Hi, I hope I'm not totally Off Topic, but I'm actually working on binary classifier with probabilistic output [0 -> 1]. I tested my methods with some sample datasets from UCI Database but I'm still in need of some samples. Especially, I'm looking for binary datasets with a probabilistic information of belonging to one of the two classes. for example, not only values X_1..X_n associated with a class Y = (C1 or C2) but rather the probability of belonging to class C2 (or equivalently C1). Maybe I could generate this probabilistic Y with some bayesian network but I was wondering if there are other datasets or ideas that could help me. Thanks and don't hesitate to ask extra information if my request is not understandable. Eric __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] 3d scatter plot
Hi, I ran into a dilemma trying to plot the following data in a 3d scatter fashion. My data are not always increasing as persp() expects. For now I use scatterplot3d to get points in a 3d scatter plot. I wonder if I have any way to plot the surfaces. Thanks! Eric sample data -0.50 0.40 1.281 -0.50 0.45 1.795 -0.50 0.50 1.766 -0.40 0.35 1.595 -0.40 0.40 1.388 -0.40 0.45 2.344 -0.40 0.50 2.179 -0.30 0.35 1.792 -0.30 0.40 2.349 -0.30 0.45 1.682 -0.30 0.50 1.493 -0.20 0.35 1.836 -0.20 0.40 2.186 -0.20 0.45 1.863 -0.20 0.50 1.775 -0.10 0.25 2.991 -0.10 0.30 2.426 -0.10 0.35 1.954 -0.10 0.40 1.136 -0.10 0.45 1.438 -0.10 0.50 1.429 -0.05 0.30 2.163 -0.05 0.35 1.953 -0.05 0.40 1.672 -0.05 0.45 1.688 -0.05 0.50 1.963 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] 3d scatter plot
Hey Sundar I guess it works indeed. I had made a stupid mistake. Thanks. Eric On Jul 15, 2005, at 11:24 AM, Sundar Dorai-Raj wrote: > Hi, Eric, > > I plotted a surface using the first two columns as x and y and the > third column for z: > > library(lattice) > v <- read.table("clipboard") > names(v) <- c("x", "y", "z") > wireframe(z ~ x * y, data = v) > > The result is attached. Am I missing something? > > Thanks, > > --sundar > > Eric Hu wrote: >> Ok, I don't think x and y lay on a rectangle which explains why >> wireframe does not work. BTW, I am really new to R and maybe you can >> plot those data to prove that I am wrong. Thanks. >> Eric >> On Jul 15, 2005, at 10:56 AM, Sundar Dorai-Raj wrote: >>> >>> >>> Eric Hu wrote: >>> >>>> Hi, I ran into a dilemma trying to plot the following data in a 3d >>>> scatter fashion. My data are not always increasing as persp() >>>> expects. For now I use scatterplot3d to get points in a 3d scatter >>>> plot. I wonder if I have any way to plot the surfaces. Thanks! >>>> Eric >>>> sample data >>>> -0.50 0.40 1.281 >>>> -0.50 0.45 1.795 >>>> -0.50 0.50 1.766 >>>> -0.40 0.35 1.595 >>>> -0.40 0.40 1.388 >>>> -0.40 0.45 2.344 >>>> -0.40 0.50 2.179 >>>> -0.30 0.35 1.792 >>>> -0.30 0.40 2.349 >>>> -0.30 0.45 1.682 >>>> -0.30 0.50 1.493 >>>> -0.20 0.35 1.836 >>>> -0.20 0.40 2.186 >>>> -0.20 0.45 1.863 >>>> -0.20 0.50 1.775 >>>> -0.10 0.25 2.991 >>>> -0.10 0.30 2.426 >>>> -0.10 0.35 1.954 >>>> -0.10 0.40 1.136 >>>> -0.10 0.45 1.438 >>>> -0.10 0.50 1.429 >>>> -0.05 0.30 2.163 >>>> -0.05 0.35 1.953 >>>> -0.05 0.40 1.672 >>>> -0.05 0.45 1.688 >>>> -0.05 0.50 1.963 >>> >>> >>> >>> ?wireframe in the lattice package may help. >>> >>> --sundar >>> >>> >>> > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Cochran-Armitage-trend-test
Hi there, I often do receive some mails about this piece of code regarding Cochran-Armitage or Mantel Chi square. The archived mail does unfortunately lack some pieces of code (function "scores"). I copy there all my raw code that I did implement to mimic SAS PROC FREQ statistics regarding the analysis of contingency tables. Whoever is interested to take it and rework it a little bit (for example redefining outputs so that they suits a htest object) is welcome. Best wishes, Eric - # R functions to provides statistics on contingency tables # Mimics SAS PROC FREQ outputs # Implementation is the one described in SAS PROC FREQ manual # Eric Lecoutre <[EMAIL PROTECTED] # Feel free to use / modify / document / add to a package # UTILITARY FUNCTIONS # print.ordtest=function(l,...) { tmp=matrix(c(l$estimate,l$ASE),nrow=1) dimnames(tmp)=list(l$name,c("Estimate","ASE")) print(round(tmp,4),...) } compADPQ=function(x) { nr=nrow(x) nc=ncol(x) Aij=matrix(0,nrow=nr,ncol=nc) Dij=matrix(0,nrow=nr,ncol=nc) for (i in 1:nr) { for (j in 1:nc) { Aij[i,j]=sum(x[1:i,1:j])+sum(x[i:nr,j:nc])-sum(x[i,])-sum(x[,j]) Dij[i,j]=sum(x[i:nr,1:j])+sum(x[1:i,j:nc])-sum(x[i,])-sum(x[,j]) }} P=sum(x*Aij) Q=sum(x*Dij) return(list(Aij=Aij,Dij=Dij,P=P,Q=Q)) } scores=function(x,MARGIN=1,method="table",...) { # MARGIN # 1 - row # 2 - columns # Methods for ranks are # # x - default # rank # ridit # modridit if (method=="table") { if (is.null(dimnames(x))) return(1:(dim(x)[MARGIN])) else { options(warn=-1) if (sum(is.na(as.numeric(dimnames(x)[[MARGIN]])))>0) { out=(1:(dim(x)[MARGIN])) } else { out=(as.numeric(dimnames(x)[[MARGIN]])) } options(warn=0) } } else{ ### method is a rank one Ndim=dim(x)[MARGIN] OTHERMARGIN=3-MARGIN ranks=c(0,(cumsum(apply(x,MARGIN,sum[1:Ndim]+(apply(x,MARGIN,sum)+1) /2 if (method=="ranks") out=ranks if (method=="ridit") out=ranks/(sum(x)) if (method=="modridit") out=ranks/(sum(x)+1) } return(out) } # FUNCTIONS # tablegamma=function(x) { # Statistic tmp=compADPQ(x) P=tmp$P Q=tmp$Q gamma=(P-Q)/(P+Q) # ASE Aij=tmp$Aij Dij=tmp$Dij tmp1=4/(P+Q)^2 tmp2=sqrt(sum((Q*Aij - P*Dij)^2 * x)) gamma.ASE=tmp1*tmp2 # Test var0=(4/(P+Q)^2) * (sum(x*(Aij-Dij)^2) - ((P-Q)^2)/sum(x)) tb=gamma/sqrt(var0) p.value=2*(1-pnorm(tb)) # Output out=list(estimate=gamma,ASE=gamma.ASE,statistic=tb,p.value=p.value,name= "Gamma",bornes=c(-1,1)) class(out)="ordtest" return(out) } tabletauc=function(x) { tmp=compADPQ(x) P=tmp$P Q=tmp$Q m=min(dim(x)) n=sum(x) # statistic tauc=(m*(P-Q))/(n^2*(m-1)) # ASE Aij=tmp$Aij Dij=tmp$Dij dij=Aij-Dij tmp1=2*m/((m-1)*n^2) tmp2= sum(x * dij^2) - (P-Q)^2/n ASE=tmp1*sqrt(tmp2) # Test tb=tauc/ASE p.value=2*(1-pnorm(tb)) # Output out=list(estimate=tauc,ASE=ASE,statistic=tb,p.value=p.value,name="Kendal l's tau-c",bornes=c(-1,1)) class(out)="ordtest" return(out) } tabletaub=function(x) { # Statistic tmp=compADPQ(x) P=tmp$P Q=tmp$Q n=sum(x) wr=n^2 - sum(apply(x,1,sum)^2) wc=n^2 - sum(apply(x,2,sum)^2) taub=(P-Q)/sqrt(wr*wc) # ASE Aij=tmp$Aij Dij=tmp$Dij w=sqrt(wr*wc) dij=Aij-Dij nidot=apply(x,1,sum) ndotj=apply(x,2,sum) n=sum(x) vij=outer(nidot,ndotj, FUN=function(a,b) return(a*wc+b*wr)) tmp1=1/(w^2) tmp2= sum(x*(2*w*dij + taub*vij)^2) tmp3=n^3*taub^2*(wr+wc)^2 tmp4=sqrt(tmp2-tmp3) taub.ASE=tmp1*tmp4 # Test var0=4/(wr*wc) * (sum(x*(Aij-Dij)^2) - (P-Q)^2/n) tb=taub/sqrt(var0) p.value=2*(1-pnorm(tb)) # Output out=list(estimate=taub,ASE=taub.ASE,statistic=tb,p.value=p.value,name="K endall's tau-b",bornes=c(-1,1)) class(out="ordtest") return(out) } tablesomersD=function(x,dep=2) { # dep: which dime
[R] passing variable to formula environment
List gurus, I'm trying to code a Gompertz growth curve function as part of a larger project and have run across a problem due to my ignorance of environments. Some sample data and the function are as follows: growth <- data.frame(age = c(1.92, 3, 5.83, 3.17, 15.5, 1.17, 5.58, 13.33, 14.29, 5.83, 13.79, 6.33, 13.75, 16.83, 13, 11.67, 0.25, 1.73, 9.46, 5.67), length = c(157, 165, 179, 171, 195, 135, 179, 193, 194, 186, 196, 186, 210, 200, 189, 194, 106, 161, 188, 159)) # return gompertz fit Gompertz <- function(data,Xintercept,Lzero,start) { gomp <- formula(length ~ Lzero * exp(k * (1 - exp(-g * (age - Xintercept) nls(formula=gomp,data=data,start=start) } When I run the function, I get the following error: > Gompertz(growth,0,87,list(k=0.5,g=0.5)) Error in eval(expr, envir, enclos) : Object "Lzero" not found After reading through the help files on 'nls', 'formula', 'model.frame', and 'environment', I understand that the formula gets evaluated in the environment in which it is created, and in my case, "Lzero" is not defined in that environment, but I'm still shaky on the environment concept and can't figure out how to pass or include "Lzero" in the environment that nls is evaluating gomp and data in. I have tried redefining "gomp" in the function as: gomp <- as.formula("length ~ Lzero * exp(k * (1 - exp(-g * (age - Xintercept",environment()) # thinking that 'environment()' refers to environment of Gompertz function where Lzero exists gomp <- as.formula("length ~ Lzero * exp(k * (1 - exp(-g * (age - Xintercept",environment(Gompertz)) # trying to explicitly force it gomp <- as.formula("length ~ Lzero * exp(k * (1 - exp(-g * (age - Xintercept",new.env()) # my guess at what formula(x,...) does ...but I get the same error. Since I'm still trying to wrap my head around environments and evaluation in R, the solution to this will be very educational. Thanks in advance. Cheers, e. -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] passing variable to formula environment
Most excellent Sundar! Thanks so much! Cheers, e. Sundar Dorai-Raj wrote: > > > Eric Archer wrote: > >> List gurus, >> >> I'm trying to code a Gompertz growth curve function as part of a >> larger project and have run across a problem due to my ignorance of >> environments. Some sample data and the function are as follows: >> >> growth <- data.frame(age = c(1.92, 3, 5.83, 3.17, 15.5, 1.17, 5.58, >> 13.33, 14.29, 5.83, 13.79, 6.33, 13.75, 16.83, 13, 11.67, 0.25, 1.73, >> 9.46, 5.67), length = c(157, 165, 179, 171, 195, 135, 179, 193, 194, >> 186, 196, 186, 210, 200, 189, 194, 106, 161, 188, 159)) >> >> # return gompertz fit >> Gompertz <- function(data,Xintercept,Lzero,start) { >> gomp <- formula(length ~ Lzero * exp(k * (1 - exp(-g * (age - >> Xintercept) >> nls(formula=gomp,data=data,start=start) >> } >> >> When I run the function, I get the following error: >> >> > Gompertz(growth,0,87,list(k=0.5,g=0.5)) >> Error in eval(expr, envir, enclos) : Object "Lzero" not found >> >> After reading through the help files on 'nls', 'formula', >> 'model.frame', and 'environment', I understand that the formula gets >> evaluated in the environment in which it is created, and in my case, >> "Lzero" is not defined in that environment, but I'm still shaky on >> the environment concept and can't figure out how to pass or include >> "Lzero" in the environment that nls is evaluating gomp and data in. >> >> I have tried redefining "gomp" in the function as: >> >> gomp <- as.formula("length ~ Lzero * exp(k * (1 - exp(-g * (age - >> Xintercept",environment()) # thinking that 'environment()' refers >> to environment of Gompertz function where Lzero exists >> >> gomp <- as.formula("length ~ Lzero * exp(k * (1 - exp(-g * (age - >> Xintercept",environment(Gompertz)) >> # trying to explicitly force it >> >> gomp <- as.formula("length ~ Lzero * exp(k * (1 - exp(-g * (age - >> Xintercept",new.env()) >> # my guess at what formula(x,...) does >> >> ...but I get the same error. Since I'm still trying to wrap my head >> around environments and evaluation in R, the solution to this will be >> very educational. Thanks in advance. >> >> Cheers, >> e. >> > > Hi, Eric, > > I think the easiest way to do this is to use substitute: > > # return gompertz fit > Gompertz <- function(data, Xintercept, Lzero, start) { > gomp <- substitute(length ~ Lzero * exp(k * (1 - exp(-g * (age - > Xintercept, > list(Xintercept = Xintercept, Lzero = Lzero)) > nls(gomp, data, start) > } > > Gompertz(growth, 0, 87, list(k = 0.5, g = 0.5)) > > HTH, > > --sundar -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] spline curves in R
Dear all, Is it possible to calculate the first and second derivatives of a cubic spline curve (interpolating through the points) as opposed to a smoothing spline? If so, how is this done? Is it also possible to find the equation of the spline curve that is fitted? Any help is much appreciated. TIA Eric - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] nested mixed-effect model: variance components
Dear listers, I am trying to assess variance components for a nested, mixed-effects model. I think I got an answer that make sense from R, but I have a warning message and I wanted to check that what I am looking at is actually what I need: my data are organized as transects within stations, stations within habitats, habitats within lagoons. lagoons: random, habitats: fixed the question is: how much variation is due to lagoons? habitats? lagoons*habitat? transects? Here is my code: res <- aov(COVER ~ HABITAT + Error(HABITAT+LAGOON+LAGOON/HABITAT), data=cov) summary(res) and I get Sum Sq for each to calculate variance components: Error: STRATE Df Sum Sq Mean Sq STRATE 5 4493.1 898.6 Error: ATOLL Df Sum Sq Mean Sq F value Pr(>F) Residuals 5 3340.5 668.1 Error: STRATE:ATOLL Df Sum Sq Mean Sq F value Pr(>F) Residuals 18 2442.71 135.71 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Residuals 145 6422.044.3 My error message seems to come from the LAGOON/HABITAT, the Error is computed. Warning message: Error() model is singular in: aov(COVER ~ HABITAT + Error(HABITAT+LAGOON+LAGOON/HABITAT), data=cov), THANKS !!! eric Eric Pante College of Charleston, Grice Marine Laboratory 205 Fort Johnson Road, Charleston SC 29412 Phone: 843-953-9190 (lab) -9200 (main office) "On ne force pas la curiosite, on l'eveille ..." Daniel Pennac __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] plot two graphs with different length of data
Hi I am trying to plot two data set in the same picture window without overlapping with each other. I am using the format plot(x1,y1,x2,y2) but get the following error message: >plot(as.numeric(r0[,4]),as.numeric(r0[,7]),as.numeric(r0[,4]),as.numeric(r0[,7][ind[,1]])) Error in plot.window(xlim, ylim, log, asp, ...) : invalid 'ylim' value Can anyone tell me what went wrong? Thanks. Eric __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plot two graphs with different length of data
Thanks Jim. This seems to work for my case already. Eric On 6/13/06, Jim Lemon <[EMAIL PROTECTED]> wrote: > Eric Hu wrote: > > Hi I am trying to plot two data set in the same picture window without > > overlapping with each other. I am using the format plot(x1,y1,x2,y2) > > but get the following error message: > > > > > >>plot(as.numeric(r0[,4]),as.numeric(r0[,7]),as.numeric(r0[,4]),as.numeric(r0[,7][ind[,1]])) > > > > Error in plot.window(xlim, ylim, log, asp, ...) : > > invalid 'ylim' value > > > > Can anyone tell me what went wrong? Thanks. > > plot is probably interpreting one of your data vectors as the ylim > argument. If you want to plot multiple data series of different lengths, > it is probably simplest to use points() (or lines()) after plotting the > first one. For an example of this, see: > > http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_addat.html > > Jim > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plot two graphs with different length of data
thank you, Joerg. I am able to use points() to add the new data in the current plot. Eric On 6/13/06, Joerg van den Hoff <[EMAIL PROTECTED]> wrote: > Eric Hu wrote: > > Hi I am trying to plot two data set in the same picture window without > > overlapping with each other. I am using the format plot(x1,y1,x2,y2) > > but get the following error message: > > > >> plot(as.numeric(r0[,4]),as.numeric(r0[,7]),as.numeric(r0[,4]),as.numeric(r0[,7][ind[,1]])) > > Error in plot.window(xlim, ylim, log, asp, ...) : > > invalid 'ylim' value > > > > Can anyone tell me what went wrong? Thanks. > > > > Eric > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > matplot(cbind(x1,x2), cbind(y1,y2)) might be what you want. > > (if x1, x2 and y1,y2 are of equal length. otherwise pad the short ones > with NAs or use `matplot' with type =n (to get the scaling of the plot > right), followed by `plot(x1,y1), lines(x2,y2)') > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] running R in batch with stdin input
Hi I have a R script that needs to run a few times for different systems. I use R --no-save < r.script for one system. I am trying with no luck to use R CMD BATCH to introduce an stdin input variable for the script. I wonder if anyone can provide the correct usage to put the variable in the command like R CMD BATCH r.script name_variable. Thanks. -Eric In the r.script I have name <- readline("/dev/stdin") r0 <- read.table("/usr/local/surface/$name/$name_c_r") ... I want to get at the end: name <- "1BRS" r0 <- read.table("/usr/local/surface/1BRS/1BRS_c_r") ... __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Maximum length of R GUI input line?
Hello, I'm using R 2.3.1 on Windows. I'm generating some very long SQL statements. I do this by using paste() which will contain many strings and variables. I'm getting an error when the the total line length is longer than about 1013 characters. For example, it works with the line containing 1013 characters and not when it is 1059. I've looked into adjusting the options(width) and a handful of other settings. I have a feeling there is some other setting i'm missing that i can adjust. Any ideas? Thanks! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] "unvector" ?
Hi ev'rybody, is there a way to pass a vector to a function expecting separate arguments? more specifically, I have a character vector, say u and I want a single string, but >paste(u) doesn't work, so I would like something like >paste(unvector(u)). I am interested in a solution to the general problem too, as the only one I found is maintaining two versions of the functions I write. Eric Elguero GEMI-UMR 2724 IRD-CNRS, Equipe "Evolution des Systemes Symbiotiques" 911 avenue Agropolis, BP 64501, 34394 Montpellier cedex 5 FRANCE __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] bootstrapping for clustering
Dear R-listers, Is anyone familiar with a package that would perform bootstrapping on species/site matrices for clustering ? So far I have been using the vegan package to generate trees (Bray-Curtis index), but I would like to associate a certainty to each node (similarly to a phylogenetic tree). If no package exist, I would know how to generate bootstrapped matrices of distance, but how could I plot the results ? Graphically, I am looking for something similar to what is available from the pvclust package (my understanding is that pvclust makes covariance clustering from dataframes, and it cannot be used with matrices to generate Bray-Curtis similarity dendrograms?) Please forgive my ignorance! Thank you in advance, eric pante __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Clustering and bootstrap
Dear Listers, I emailed the list a few days ago about how to bootstrap a community matrix (species by sites) and get a consensus tree with node support. A friend pointed out that a similar question remained unanswered in 2004. I wish to re-word my question: is anyone aware of a package / method to obtain a majority-rule consensus tree from x distance matrices ? Is anyone using R to generate phylogenetic trees with node support ? thanks for your time and consideration, Eric P. Eric Pante --- Graduate Student in Marine Biology Grice Marine Laboratory 205 Fort Johnson Road, Charleston SC 29412 --- "On ne force pas la curiosite, on l'eveille ..." Daniel Pennac __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] sampling vectors
Hello Listers, I am trying to sample a vector to create a new one of sample length, witha sum equal to the sum of the initial vector: initial = 10, 30, 10 (sum=50) sample example = 5, 35, 10 (sum=50) or 25, 15, 10 (sum=50), etc ... My problem is to control the sum, so it stays constant. Any suggestions would be very helpful ! Thank you in advance, Eric __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] sampling vectors
Hi Dan, I just tried your code with long vectors, and the sampling stops to be random. Do you see any reason why this is ? examples: ex = c(30,13,9,8,7,7,7,6,6,5,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1) > vectorSample(ex) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 7 6 [24] 4 2 75 > vectorSample(ex) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 11 [24] 7 8 67 > > vectorSample(ex) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [24] 1 6 87 > vectorSample(ex) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 3 [24] 1 4 85 > vectorSample(ex) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 19 [24] 16 42 18 > vectorSample(ex) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 3 5 4 4 17 [24] 2 53 10 > vectorSample(ex) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 5 [24] 3 11 74 > vectorSample(ex) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 1 2 3 [24] 21 23 43 > vectorSample(ex) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 9 [24] 18 20 44 > vectorSample(ex) [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 3 6 14 [24] 8 6 59 On Oct 4, 2005, at 12:02 PM, Daniel Nordlund wrote: >> -Original Message- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] >> On Behalf Of ecatchpole >> Sent: Monday, October 03, 2005 11:57 PM >> To: Eric Pante >> Cc: r-help@stat.math.ethz.ch >> Subject: Re: [R] sampling vectors >> >> Eric, >> >> If you want samples of size 3 from 0:50, with sum==50, this seems to >> do >> the job (with apologies to those who really know how to program in R): >> >> tot <- 50 >> ii <- 0 >> aa <- list() >> for(i in 0:tot){ >> for(j in 0:(tot-i)){ >>k <- tot-i-j >>ii <- ii+1 >>aa[[ii]] <- list(i=i,j=j,k=k) >> } >> } >> >> aa[sample(ii, 4)] # for a sample of 4. >> >> If you want a sample of size n from x[1],...x[N], such that the sample >> sum is T, then that is much trickier! >> >> Ted. >> >> On 04/10/05 07:31, Eric Pante wrote,: >>> Hello Listers, >>> >>> I am trying to sample a vector to create a new one of sample length, >>> witha sum equal to the sum of the initial vector: >>> >>> initial = 10, 30, 10 (sum=50) >>> sample example = 5, 35, 10 (sum=50) or 25, 15, 10 (sum=50), etc ... >>> >>> My problem is to control the sum, so it stays constant. >>> Any suggestions would be very helpful ! >>> >>> Thank you in advance, >>> Eric >>> > > Eric, > > Here is another solution, which allows vectors of different lengths > and sums. > > vectorSample <- function(vec) { > tot<-sum(vec) > Len<-length(vec) > v < -rep(0,Len) > for(i in Len:2) { > UL <- tot - sum(v) - i + 1 > v[i]<-sample(1:UL,1) > } > v[1] <- tot - sum(v) > v > } > > vectorSample( c(10,30,10) ) > > Hope this helps, > > Dan Nordlund > Bothell, WA > > > > Eric Pante --- Graduate Student in Marine Biology Grice Marine Laboratory 205 Fort Johnson Road, Charleston SC 29412 --- "On ne force pas la curiosite, on l'eveille ..." Daniel Pennac [[alternative text/enriched version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to plot matrix in graphs
halo, how to plot a matrix (i have a multiple matrix ) in graphs in terms of colored boxes or circles. my matrix looks like A B C 6 2 3 4 3 2 2 1 7 A4 3 1 4 6 8 2 1 6 2 7 8 7 8 0 2 3 5 5 2 3 4 7 2 2 1 7 B4 3 1 4 8 8 3 1 6 9 7 8 7 8 0 6 3 5 1 2 3 4 3 2 2 1 7 C 4 3 1 4 6 8 2 1 6 2 7 8 7 8 0 2 3 5 And my graph should looks like(in terms of colored boxes or circles according to the magnitude of the nos) A B C O O OO O O O O O A O O OO O O O O O O O OO O O O O O O O OO O O O O O B O O OO O O O O O O O OO O O O O O O O OO O O O O O C O O OO O O O O O O O OO O O O O O Can you suggest me some ways of doing this.. thank you best regards, peter. Research student, Fraunhofer IPT, Germany. - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Histogram over a Large Data Set (DB): How?
Hi! I'm new to R, and I have a question about how R works with large data sets --- in particular, data sets that come from databases. I'm using R 2.2.0 with the DBI package (0.1-9) and the RMySQL package (0.5-5). My get-my-feet-wet-with-R project is to make a histogram from a data set stored in a MySQL database. In particular, I have a table that describes some observed spam emails. The 'unixtime' column of the table contains the timestamps of the messages. My current goal is to plot the number of spams per day during the recording period. So far, this is my script (edited for brevity), and it works well: - library(RMySQL) drv <- dbDriver("MySQL") con <- dbConnect(drv, group="spam") # "where" clause to limit data set size, as described below. spams <- dbGetQuery(con, "select unixtime from email where LENGTH(email_to)=4") firstspam <- min(spams$unixtime) lastspam <- max(spams$unixtime) # spansize == one day spansize <- 60 * 60 * 24 firstbreak = floor(firstspam / spansize) lastbreak = celing(lastspam / spansize) spambreaks = (firstbreak:lastbreak) * spansize hist(spams$unixtime, br=spambreaks, plot=TRUE, col="red") - The "where" clause serves to limit the number of records, while I figure out the surrounding parts. And now I'd like to do that... but I'm not sure how! The actual "email" table has 2.9 million rows (a lot of spam!), so I presume that I cannot (or at least, shouldn't) read it all at once. Reading the documentation of the RMySQL package, I understand that the syntax I want is something like this: - rs <- dbSendQuery(con, "select unixtime from email order by unixtime") out <- dbApply(rs, INDEX = "unixtime", FUN = function(x, grp) hist(x$unixtime, ...)) - But I can't quite seem to make this work. When I try the above directly, I get errors like this: Error in mysqlDBApply(res, ...) : unimplemented type 'NULL' in 'length<-' More generally, I'm pretty sure that I'm misusing `hist' in the code above. I don't want a series of histograms; I want just one histogram, made from the concatenation of all the records fetched from the table. I didn't find a recipe for doing this sort of thing in the R FAQ or in the archives for this mailing list, so I'm hoping that someone can set me on the right track. How does one code in R with functions that expect "whole" vectors, and somehow provide those vectors in a "piecemeal" fashion? Is there a general recipe for this situation in R (aren't large data sets common?), or do I need to code the histogram generator myself? Thanks for any help! --- Eric. -- --- Eric Eide <[EMAIL PROTECTED]> . University of Utah School of Computing http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Histogram over a Large Data Set (DB): How?
"Sean" == Sean Davis <[EMAIL PROTECTED]> writes: Sean> Have you tried just grabbing the whole column using dbGetQuery? Sean> Try doing this: Sean> Sean> spams <- dbGetQuery(con,"select unixtime from email limit Sean> 100") Sean> Sean> Then increase from 1,000,000 to 1.5 million, to 2 million, etc. Sean> until you break something (run out of memory), if you do at all. Yes, you are right. For the example problem that I posed, R can indeed process the entire query result in memory. (The R process grows to 240MB, though!) Sean> However, the BETTER way to do this, if you already have the data Sean> in the database is to allow the database to do the histogram for Sean> you. For example, to get a count of spams by day, in MySQL do Sean> something like: [...] Yes, again you are right --- the particular problem that I posed is probably better handled by formulating a more sophisticated SQL query. But really, my goal isn't to solve the the example problem that I posed --- rather, it is to understand how people use R to process very large data sets. The research project that I'm working on will eventually need to deal with query results that cannot fit in main memory, and for which the built-in statistical facilities of most DBMSs will be insufficient. Some of my colleagues have previously written their analyses "by hand," using various scripting languages to read and process records from a DB in chunks. Writing things in this way, however, can be tedious and error-prone. Instead of taking this approach, I would like to be able to use existing statistics packages that have the ability to deal with large datasets in good ways. So, I seek to understand the ways that people deal with these sorts of situations in R. Your advice is very helpful --- one should solve problems in the simplest ways available! --- but I would still like to understand the harder cases, and how one can use "general" R functions in combination with DBI's `dbApply' and `fetch' interfaces, which divide results into chunks. Thanks! Eric. -- --- Eric Eide <[EMAIL PROTECTED]> . University of Utah School of Computing http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to plot a list in graphs
hi all, I have a matrix and named each row and column as like below... a<-matrix(c(seq(3,45,3),seq(10,6,-1)),4,5,byrow=F) > col<-c("peter","david","richrd","vincent","selva") > rows<-c("julius","caeser","anja","maya") > dimnames(a)<-list(rows,col) > a peter david richrd vincent selva julius 315 27 39 9 caeser 618 30 42 8 anja 921 33 45 7 maya 1224 36 10 6 How I can plot this in graphs like julius Vs peter and so on.. whether it could ne done with image function?.. please give me some suggestions... best regards, eric. Research student, Fraunhofer IPT, Germany. - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to plot a list in graphs
Really your (Mr.deepayan´s)answer is what I expected..thanks a lot...and I like to ask you one more thing.. Is it possible to do boolean operations in this matrix and plot that also in graphs? for example 1. a[anja,maya] Vs a[vincent,selva] means things common between the rows anja&maya and columns vincent & selva 2.a[anja,maya] Vs a[peter,david] and so on... So in that case whether it is possible to plot in the same graph(since I´m doing different...more than one.. comparisions) or I´ve to plot in a multiple graph.. kindly help me... thanks a lot with regards, eric Deepayan Sarkar <[EMAIL PROTECTED]> wrote: On 11/21/05, peter eric wrote: > hi all, > I have a matrix and named each row and column as like below... > > a<-matrix(c(seq(3,45,3),seq(10,6,-1)),4,5,byrow=F) > > col<-c("peter","david","richrd","vincent","selva") > > rows<-c("julius","caeser","anja","maya") > > dimnames(a)<-list(rows,col) > > a > peter david richrd vincent selva > julius 3 15 27 39 9 > caeser 6 18 30 42 8 > anja 9 21 33 45 7 > maya 12 24 36 10 6 > > How I can plot this in graphs like julius Vs peter and so on.. > > whether it could ne done with image function?.. Sure, how about image(a) If you want the axes to be labelled appropriately, it might be easier with library(lattice) levelplot(a) or perhaps levelplot(a, scales = list(x = list(rot = 90))) -Deepayan __ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Any volonteer to maintain package R2HTML ?
Hi useRs! I am in search of any R programer / user to go on with the package R2HTML. I did change of job 3 months ago and I could only realize I have absolutely no time anymore for that (even so little) task. R2HTML package consists in a set of HTML.* functions that could be used to export R objects to raw HTML. It could also be used in a litterate programing way thanks to Sweave tool. Basically, the task should not be too hard, as the whole stuff works as it ; it consists mainly in adapting little parts as R new versions do require such or such additional quality check. Currently, .Rd help files require some minors modifs to pass checks (break returns). I was intending to do that this week end but did fail installing all necessary stuff to compile R packages (I do not have all admin rights on my new computer). If anyone is interested, please contact me directly at: [EMAIL PROTECTED] Best wishes, and all go happyR and happyR! Eric __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to plot a clustered matrix in graphs
dear deepayan & all... let me explain you my full problem clearly..so that you could clearly suggest me in right direction my matrix (a) looks like as below...I´ve done clusutering in this matrix a<-matrix(c(seq(3,45,3),seq(10,6,-1)),4,5,byrow=F) col<-c("ra","rb","rc","rd","re") rows<-c("ca","cb","cc","cd") dimnames(a)<-list(rows,col) a ra rb rc rd re ca 3 15 27 39 9 cb 6 18 30 42 8 cc 9 21 33 45 7 cd 12 24 36 10 6 --- clustering based on row and columns..suppose after clustering my row & col clustes looks like this.. row cluster 1: ra,rb 2: rc,rd 3:re column cluster 1: ca,cb 2: cc,cd So my clustered matrix (should) looks like ROWS 1 2 3 I rarb I rc rd I re I--I--I-- ca I 315 I 27 39 I 9 1 I I I cb I 618 I 30 42 I 8 I I I COLUMNS---I-I- cc I 9 21 I 33 45 I 7 2 I I I cd I 1224 I 36 10 I 6 I-I---I The above is the output matrix..It has to be plotted in graphs showing the partitions clearly as it is shown in the above matrix... . what kind of approach will be useful in gettign this..?particularly in colored graphs... thanks a lot... yours sincerely, eric. Deepayan Sarkar <[EMAIL PROTECTED]> wrote: On 11/21/05, peter eric wrote: > > Really your (Mr.deepayan´s)answer is what I expected..thanks a lot...and I > like to ask you one more thing.. > Is it possible to do boolean operations in this matrix and plot that also > in graphs? > > for example > 1. a[anja,maya] Vs a[vincent,selva] > means things common between the rows anja&maya and columns vincent & > selva You mean levelplot(a[c("anja", "maya"), c("vincent", "selva")]) ? This is standard matrix indexing in R. > 2.a[anja,maya] Vs a[peter,david] > and so on... > > So in that case whether it is possible to plot in the same graph(since I´m > doing different...more than one.. comparisions) or I´ve to plot in a > multiple graph.. It depends on what you want to do. If the different comparisons are based on some systematic rule then levelplot may take you further. [Note that for this you may need to work with a data.frame instead of a matrix. E.g., mat2df <- function(x) { rx <- row(x) cx <- col(x) data.frame(row = rownames(x)[rx], column = colnames(x)[cx], z = as.vector(x)) } b <- mat2df(a) b is now a data frame: > b row column z 1 julius peter 3 2 caeser peter 6 3 anja peter 9 ... ] - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] plotting filled.contour without color key
List, I'd like to plot a filled.contour() plot, but exclude the color key that is printed on the left side. I understand that the key.axis argument allows for control of the axes around the key, but there doesn't seem to be an argument that eliminates it all together. I have looked in the help files for the function and the archives, but have not come across an answer or clue to the answer. Is this possible? Thanks in advance. -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] what is the difference between survival analysis and (...)
Hi everybody, recently I had to teach a course on Cox model, of which I am not a specialist, to an audience of medical epidemiologists. Not a good idea you might say.. anyway, someone in the audience was very hostile. At some point, he sayed that Cox model was useless, since all you have to do is count who dies and who survives, divide by the sample sizes and compute a relative risk, and if there was significant censoring, use cumulated follow-up instead of sample sizes and that's it! I began arguing that in Cox model you could introduce several variables, interactions, etc, then I remembered of logistic models ;-) The only (and poor) argument I could think of was that if mr Cox took pains to devise his model, there should be some reason... but the story doesn't end here. When I came back to my office, I tried these two methods on a couple of data sets, and true, crude RRs are very close to those coming from Cox model. hence this question: could someone provide me with a dataset (preferably real) where there is a striking difference between estimated RRs and/or between P-values? and of course I am interested in theoretical arguments and references. sorry that this question has nothing to do with R and thank you in advance for your leniency. Eric Elguero GEMI-UMR 2724 IRD-CNRS, Équipe "Évolution des Systèmes Symbiotiques" 911 avenue Agropolis, BP 64501, 34394 Montpellier cedex 5 FRANCE __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] bivariate interpolation
Hi. I'm trying to take a data set with two independent and one dependent variable and enter a x,y value to predict the dependent with a nonparametric technique. I've been using interpp in the akima package, (windows xp, R 2.4.1), but get values that are orders of magnitude off when the predictors are slightly out of the range of the data set. Can you recommend a function for me? I've read that predict.loess has the same problem or just lists NA. Smooth.spline looks good, but can only do one predictor instead of bivariate. I've tried help.search("predict"), but couldn't find what I needed. Thanks. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Assignment from list
I have a list of groups of xy positions I want to set to 0 in an array full of 1s. When the assignments are done directly from the list, they are incorrect, while if I use a temporary array derived from the list the assignments are correct. The following example will hopefully make my problem clearer. The matrices z and zz are initialised with 1. The z and zz values at coordinates in list x are then set to 0 using two different methods. Although either method should lead to the same results, z and zz are different. z is incorrect, because some values in its first row have been incorrectly set to 0. x <- list( matrix( c( 9, 9, 74, 75 ), nrow=2 ), matrix( c( 11, 11, 34, 35 ), nrow=2 ), matrix( c( 14, 15, 58, 58 ), nrow=2 ), c( 16, 142 ), matrix( c( 19, 19, 94, 95 ), nrow=2 ), matrix( c( 19, 20, 127, 127 ), nrow=2 ), matrix( c( 22, 22, 112, 113 ), nrow=2 ), c( 23, 13 ), matrix( c( 26, 27, 81, 81 ), nrow=2 ), matrix( c( 31, 32, 153, 153 ), nrow=2 ) ) xx <- do.call( "rbind", x ) z <- matrix( 1, ncol=249, nrow=240 ) zz <- matrix( 1, ncol=249, nrow=240 ) for( k in x ) z[k] <- 0 zz[xx] <- 0 sum( z != zz ) c( sum( z[,1] != 1 ), sum( zz[,1] != 1 ) ) Somewhere, I must be doing something wrong, or assuming something incorrect. I would be very grateful if anybody could point me in the right direction. platform i386-apple-darwin8.8.1 arch i386 os darwin8.8.1 system i386, darwin8.8.1 status major 2 minor 4.1 year 2006 month 12 day18 svn rev40228 language R version.string R version 2.4.1 (2006-12-18) (same results with platform i386-pc-mingw32, R version 2.4.1 and platform x86_64-unknown-linux-gnu, R version 2.3.1) -- Dr Eric Blanc Lecturer in Bioinformatics MRC Centre for Developmental Neurobiology King's College London New Hunt's House Room 4.10B Guy's Hospital Campus London SE1 1UL E-mail: [EMAIL PROTECTED] Tel: +44 (0)20 7848 6532 Fax: +44 (0)20 7848 6550 [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error returned by "make check" in R-2.5.0
Today I tried to install the R-2.5.0 (currently running R-2.4.1) on Mandriva Linux. The ./configure and make commands seem to run fine, but "make check" gives the following messages: running regression tests make[3]: Entering directory `/home/ethomp04/R-2.5.0/tests' running code in 'reg-tests-1.R' ...make[3]: *** [reg-tests-1.Rout] Error 1 make[3]: Leaving directory `/home/ethomp04/R-2.5.0/tests' make[2]: *** [test-Reg] Error 2 make[2]: Leaving directory `/home/ethomp04/R-2.5.0/tests' make[1]: *** [test-all-basics] Error 1 make[1]: Leaving directory `/home/ethomp04/R-2.5.0/tests' make: *** [check] Error 2 Regarding "make check", the R-admin.html page says "Failures are not necessarily problems as they might be caused by missing functionality..." So, looking at the "reg-tests-1.Rout.fail" file, I see that the error occurs here: > ## eigen > Meps <- .Machine$double.eps > set.seed(321, kind = "default")# force a particular seed > m <- matrix(round(rnorm(25),3), 5,5) > sm <- m + t(m) #- symmetric matrix > em <- eigen(sm); V <- em$vect > print(lam <- em$values) # ordered DEcreasingly [1] 5.1738946 3.1585064 0.6849974 -1.6299494 -2.5074489 > > stopifnot( + abs(sm %*% V - V %*% diag(lam))< 60*Meps, + abs(sm - V %*% diag(lam) %*% t(V)) < 60*Meps) > > ##--- Symmetric = FALSE: -- different to above : --- > > em <- eigen(sm, symmetric = FALSE); V2 <- em$vect > print(lam2 <- em$values) # ordered decreasingly in ABSolute value ! [1] 5.1738946 3.1585064 -2.5074489 -1.6299494 0.6849974 > print(i <- rev(order(lam2))) [1] 1 2 5 4 3 > stopifnot(abs(lam - lam2[i]) < 60 * Meps) Error: abs(lam - lam2[i]) < 60 * Meps is not all TRUE Execution halted Interestingly, running these same tests on R-2.4.1 on the same system does not give an error: > Meps <- .Machine$double.eps > set.seed(321, kind = "default") # force a particular seed > m <- matrix(round(rnorm(25),3), 5,5) > sm <- m + t(m) #- symmetric matrix > em <- eigen(sm); V <- em$vect > print(lam <- em$values) # ordered DEcreasingly [1] 5.17389456321 3.15850637323 0.68499738238 -1.62994940108 -2.50744891774 > stopifnot( + abs(sm %*% V - V %*% diag(lam)) < 60*Meps, + abs(sm - V %*% diag(lam) %*% t(V)) < 60*Meps) > > ##--- Symmetric = FALSE: -- different to above : --- > > em <- eigen(sm, symmetric = FALSE); V2 <- em$vect > print(lam2 <- em$values) # ordered decreasingly in ABSolute value ! [1] 5.17389456321 3.15850637323 -2.50744891774 -1.62994940108 0.68499738238 > print(i <- rev(order(lam2))) [1] 1 2 5 4 3 > stopifnot(abs(lam - lam2[i]) < 60 * Meps) > abs(lam - lam2[i]) < 60 * Meps [1] TRUE TRUE TRUE TRUE TRUE I'm not sure what to do next, or how serious of a problem this might be. I would appreciate any suggestions or advice. I thought maybe this was due to something about how my system is setup, but since I don't get the error in R-2.4.1, that seems to imply to me that there is something different in R-2.5.0 that is causing it. Thanks. Eric Thompson Tufts University Civil & Environmental Engineering > sessionInfo() R version 2.4.1 (2006-12-18) i686-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] "datasets" "utils" "stats" "graphics" "grDevices" "methods" [7] "base" other attached packages: MASS "7.2-31" __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] acf and pacf plot
The lines indicate the confidence interval (95% by default). I think you mean that it is not documented in help(acf), but it directs you to plot.acf in the "See Also" secion. >From ?plot.acf: Note: The confidence interval plotted in 'plot.acf' is based on an _uncorrelated_ series and should be treated with appropriate caution. Using 'ci.type = "ma"' may be less potentially misleading. also see the description of the ci and ci.type arguments. As far as HOW they are calculated, I believe that the default is qnorm(c(0.025, 0.975))/sqrt(n) And yes, I think that they are very important. Hope that helps. Eric On 4/27/07, tom soyer <[EMAIL PROTECTED]> wrote: > Hi, > > I noticed that whenever I ran acf or pacf, the plot generated by R always > includes two horizontal blue doted lines. Furthermore, these two lines are > not documented in the acf documentation. I don't know what they are for, but > it seems that they are important. Could someone tell me what they are and > how are they calculated? > > Thanks, > > -- > Tom > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error returned by "make check" in R-2.5.0
Professor Ripley, Thank you for your comments. On 4/28/07, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > How big is abs(lam - lam2[i])/Meps ? Here is the result on my system: > abs(lam - lam2[i])/Meps [1] 60 18 17 0 12 which is quite surprising to me that the maximum value exactly equals the cutoff, so perhaps this is not such a big problem. I changed the value to 61 in the reg-tests-1.R file, and then make check runs with no errors. > This could be one of those cases where your system (which CPU, what > compilers?) is unusually inaccurate, but Linux systems do not usually > differ much in their accuracies on the same CPU. It is somewhat disconcerting that my system is unusually inaccurate. I'm running Intel Xeon 3.20GHz CPUs and I've been using gcc 4.1.1 and ifort to compile R (these are what the compile script choose by default on my system). Perhaps it is a bad idea to mix the GNU and Intel compilers? > I've checked several systems, as see maximum values of around 40. > > R 2.5.0 has an updated LAPACK so it will be different from 2.4.1. My > hunch is that this is a compiler optimization bug, so you could see what > happens at lower optimization levels. I'm not sure how to do this, but from reading R-admin.html, my guess is that setting the CFLAGS for ./configure will change the optimization level for LAPACK compilation, so I used ./configure CFLAGS="-g -O" And after make, I find the exact same values as before. So I thought I'd try to set the Fortran compiler to a GNU compiler, to be consistent with gcc. When I set F77=g77, make check finishes fine, and running the same test > abs(lam - lam2[i])/Meps [1] 32 8 17 1 2 which makes me more comfortable. Also, if I use the g95 compiler (./configure F77=g95), the eigen test gives > abs(lam - lam2[i])/Meps [1] 48.0 10.0 10.5 9.0 6.0 So, I suppose I will use the g77 compiler. Eric Thompson Tufts University Civil & Environmental Engineering Graduate Student > On Fri, 27 Apr 2007, Eric Thompson wrote: > > > Today I tried to install the R-2.5.0 (currently running R-2.4.1) on > > Mandriva Linux. The ./configure and make commands seem to run fine, > > but "make check" gives the following messages: > > > > running regression tests > > make[3]: Entering directory `/home/ethomp04/R-2.5.0/tests' > > running code in 'reg-tests-1.R' ...make[3]: *** [reg-tests-1.Rout] Error 1 > > make[3]: Leaving directory `/home/ethomp04/R-2.5.0/tests' > > make[2]: *** [test-Reg] Error 2 > > make[2]: Leaving directory `/home/ethomp04/R-2.5.0/tests' > > make[1]: *** [test-all-basics] Error 1 > > make[1]: Leaving directory `/home/ethomp04/R-2.5.0/tests' > > make: *** [check] Error 2 > > > > Regarding "make check", the R-admin.html page says "Failures are not > > necessarily problems as they might be caused by missing > > functionality..." > > > > So, looking at the "reg-tests-1.Rout.fail" file, I see that the error > > occurs here: > > > >> ## eigen > >> Meps <- .Machine$double.eps > >> set.seed(321, kind = "default") # force a particular seed > >> m <- matrix(round(rnorm(25),3), 5,5) > >> sm <- m + t(m) #- symmetric matrix > >> em <- eigen(sm); V <- em$vect > >> print(lam <- em$values) # ordered DEcreasingly > > [1] 5.1738946 3.1585064 0.6849974 -1.6299494 -2.5074489 > >> > >> stopifnot( > > + abs(sm %*% V - V %*% diag(lam)) < 60*Meps, > > + abs(sm - V %*% diag(lam) %*% t(V)) < 60*Meps) > >> > >> ##--- Symmetric = FALSE: -- different to above : --- > >> > >> em <- eigen(sm, symmetric = FALSE); V2 <- em$vect > >> print(lam2 <- em$values) # ordered decreasingly in ABSolute value ! > > [1] 5.1738946 3.1585064 -2.5074489 -1.6299494 0.6849974 > >> print(i <- rev(order(lam2))) > > [1] 1 2 5 4 3 > >> stopifnot(abs(lam - lam2[i]) < 60 * Meps) > > Error: abs(lam - lam2[i]) < 60 * Meps is not all TRUE > > Execution halted > > > > > > Interestingly, running these same tests on R-2.4.1 on the same system > > does not give an error: > > > >> Meps <- .Machine$double.eps > >> set.seed(321, kind = "default") # force a particular seed > >> m <- matrix(round(rnorm(25),3), 5,5) > >> sm <- m + t(m) #- symmetric matrix > >> em <- eigen(sm); V <- em$vect > >> print(lam <- em$values) # ordered DEcreasingly > > [1] 5.17389456321 3.15850637323 0.68499738238 -1.62994940108 > > -2.50744891774 > >> stopifnot
[R] is it possible to fill with a color or transparency gradient?
Hi all, Is there a way to fill a rectangle or polygon with a color and/or transparency gradient? This would be extremely useful for me in terms of adding some additional information to some plots I'm making, especially if I could define the gradient on my own by putting functions into rgb something like rgb( r=f(x,y), g=f(x,y), b=f(x,y), alpha=f(x,y) ). Not so important whether the coordinates are in terms of the plot axes or normalized to the polygon itself somehow. Ideally it would work not only for a fill color but also for shading lines. I haven't been using R very long, so it's possible that I'm just missing something, but I haven't found anything like this in the help files. I've tried to poke around in graphics, grid, and ggplot, without any luck so far. I really like some of the functionality in ggplot, and it does some nice things with continuous gradients for the color of scatter plot points, for example, but it each individual point (or grob) is always one solid color as far as I can tell. Thanks, Eric __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Likelihood of multiple random processes
this way the problem is not well posed. You need to place an upper bound on the number of distributions in the mixture you want to estimate, for otherwise the likelihood is unbounded (take one normal distribution for each value in your data). - Original Message - > Do you know which observations came from which process (you do in your > example, but it whatever it is supposed to emulate)? No- I need to determine whether more than one process could have been involved. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Single precision data behaviour with readBin()
Hi all, I am running R version 2.4.0 (2006-10-03) on an i686 pc with Mandrake 10.2 Linux. I was given a binary data file containing single precision numbers that I would like to read into R. In a previous posting, someone suggested reading in such data as double(), which is what I've tried: > zz <- file(file, "rb") > h1 <- readBin(con = zz, what = double(), n = 1, size = 4) > h1 [1] 0.050007451 Except that I know that the first value should be exactly 0.05. To get rid of the unwanted (or really unknown) values, I try using signif(), which gives me: > h1 <- signif(h1, digits = 8) > h1 [1] 0.05001 I suppose I could use: > h1 <- signif(h1, digits = 7) > h1 [1] 0.05 But this does not seem ideal to me. Apparently I don't understand machine precision very well, because I don't understand where the extra values are coming from. So I also don't know if this use of signif() will be reliable for all possible values. What about a value of 1.2e-8? Will this be read in as: > signif(1.2034e-8, digits = 7) [1] 1.2e-08 or could this occur?: > signif(1.234e-8, digits = 7) [1] 1.23e-08 Thanks for any advice. Eric Thompson Graduate Student Tufts University Civil & Environmental Engineering Medford, MA 02144 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] delete content of directory - unlink doesn't work as expected
This has worked for me: system("rm path/*") On 11/28/06, Hans-Peter <[EMAIL PROTECTED]> wrote: > Hi, > > I try to delete the files in a directory. While the command > > invisible(lapply( list.files( "DeleteThis" ), function(x) > file.remove(paste("DeleteThis", x, sep="/" )) )) > > works, I keep thinking that there should be a more direct command. > > "unlink" looks like a good candidate but whith this I only arrive to > either delete the whole directory or nothing happens at all. Code: > > file.exists( "DeleteThis" )# TRUE: folder is here > > (unlink( "DeleteThis/*.*" )) # 0, content doesn't get deleted > (unlink( "DeleteThis/*" )) # do. > (unlink( "DeleteThis/*.*", TRUE )) # do. > (unlink( "DeleteThis/*", TRUE ))# do. > > unlink( "DeleteThis", TRUE ) # whole folder will be deleted > > According to the help placeholders are allowed so I don't see where is an > error. > > Thanks for your help! > > -- > Regards, > Hans-Peter > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] building R 2.4.0 on aix
Roy and others, I'm also trying to build R 2.4.0 on aix 5 (5.3 in my case, on an Intellistation Power 285) and I have not had luck yet. I notice that the only mentions of AIX on this list in the past two months are people not having luck building it. So far there don't seem to be any responses, and I don't know if it's from lack of information in the questions, or because this isn't the right place to ask the questions. Does anyone know a good place to ask such questions? If this is the right place, please let me know what information you need. I am unfortunately very new to this business of compiling and linking on Unix, so I have trouble knowing what information to provide. Here's my stab at troubleshooting, which is basically trial-and-error: === tried just to type ./configure (I can always dream, right? :-) ) Failed with the following problem in config.log configure:26491: checking how to get verbose linking output from f95 configure:26502: f95 -c conftest.f >&5 f95: 1501-218 file conftest.f contains an incorrect file suffix configure:26508: $? = 1 configure: failed program was: | program main | | end configure:26587: WARNING: compilation failed configure:26593: result: config.log (93%) === A little playing around shows me that f95 doesn't like to compile files ending in .f, so I try doing ./configure F77=f77 In this case, the configure script completes successfully. Now I try make but make exits early with errors. make check gives make: 1254-002 Cannot find a rule to create target ../../src/library/base/all.R from dependencies. Stop. and a few other 1254-004 errors. === There are some examples in http://cran.r-project.org/doc/manuals/R-admin.html , particularly in the AIX platform notes (C.9 AIX). However, the second paragraph says "The rest of this section is historical, as the default *_LDFLAGS were changed in R 2.4.0." so evidently the examples don't apply to the current version of R. I tried some frankenstein combinations of the options given in the examples, using the xl*_* compilers since I don't have gfortran on my system, but this kind of thing is time-consuming when I'm essentially making random changes. I'm hoping that someone with more experience than I can at least help me sort through the "Cannot find a rule to create target" error, and that maybe I can proceed somehow one error at a time and finally end up with something that works. BTW, I did try to google the "Cannot find a rule to create target" "from dependencies", but I don't get much that I can understand. One message said something about this means make can't find the source code. If this is the problem, how can I figure out what source code make is looking for, where it's looking for it, and how to tell it the right place to look? Or perhaps there's something else I'm missing? Thanks, Eric Harley On 11/20/06, Roy Heimbach <[EMAIL PROTECTED]> wrote: > I'm trying to build R 2.4.0 on aix 5 and not having much luck. If > anyone on the list has built 2.3 or 2.4 on AIX and would be willing > pass along some hints, I would be grateful. So would the research > group that's waiting to use R. > > Thanks, > Roy Heimbach > -- > Roy Heimbach <[EMAIL PROTECTED]> / 505-277-8348 > User Services / Center for High Performance Computing > University of New Mexico > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] control for frame color in cloud()
I am trying to construct a cloud plot viewable in 3D with the classic 3D glasses (one red lens, one bluish lens). I've figured out how to overlay two printings of cloud() (from the lattice package) with appropriate colors, however the box frame seems to only print in black. Is there any way to control the color for the frame? How about the background color (gray)? See http://www.crustose.net/~nnhp/3Dview.pdf for a sample of what I'm doing. Thanks, -Eric --- Eric B. Peterson Vegetation Ecologist Nevada Natural Heritage Program [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help for L-moment Ratio Diagram
I think there are a few packages for doing this. I have used "lmomco": the function lmom.ub() will calculate the sample lmoments, and lmrdia() gives theoretical lmoments for different distributions. Hope this is helpful. Eric On 12/4/06, amna khan <[EMAIL PROTECTED]> wrote: > Respected Sir > > I have to select a probability distribution using L-moment Ratio Diagram. I > am not understanding how to plot sample TAU3 and TUA4 on L-moment Ratio > Diagram. > Please Guide me > Best Regards > > -- > AMINA SHAHZADI > Department of Statistics > GC University Lahore, Pakistan. > Email: > [EMAIL PROTECTED] > [EMAIL PROTECTED] > [EMAIL PROTECTED] > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to extract the row names of a matrix using for loop or other looping
Hi all, I have a matrix and its cluster...and i like to extract the row names of each clusterbut using the for loop or some other looping a<-matrix(c(seq(3,45,3),seq(10,6,-1)),4,5,byrow=F) col<-c("ra","rb","rc","rd","re") rows<-c("ca","cb","cc","cd") dimnames(a)<-list(rows,col) a##matrix #--- # ra rb rc rd re # ca 3 15 27 39 9 # cb 6 18 30 42 8 # cc 9 21 33 45 7 # cd 12 24 36 10 6 t<-list()## clusters of the matrix s<-list() r<-c(1:3) for(i in 1:3) { p<-seq(r[i],4,3) s[[i]]<-print(p) t[[i]]<-a[s[[i]],,drop=FALSE] } print(t) -- ##[[1]] ra rb rc rd re ca 3 15 27 39 9 cd 12 24 36 10 6 [[2]] ra rb rc rd re cb 6 18 30 42 8 [[3]] ra rb rc rd re cc 9 21 33 45 7 ##now if i want to extract the row names i can do it manually giving the values like rowc <- list(c(rownames(t[[1]])), c(rownames(t[[2]])), rownames(t[[3]])) but i like to do using for loop or other loops...could you give me some suggestion..i´ve tried like this..but it is not working rowc<-list(for(i in 1:3){p<-c();k<-rownames(t[[i]]);p[[i]]<-print(k)}) ## here I´m getting only the final rowname t[[3]]..other two values are missing..how could i do this to store all the values... thank you... with regards, eric. - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] problem with R on mac os x
Hello all, R just ''stopped working'' on my machine (ibook g4, os 10.3.9). between last time I used it and now, I did not do anything but check emails and browse the internet. when I try to start the GUI, it appears and disappears as rapidly. when I tried to run a session from the terminal, I got the following: mkdir: /tmp/Rtmp590-29493: Permission denied mkdir: /tmp/Rtmp590: Permission denied ERROR: cannot create temporary R session directory If I log as root, I can start a session from the terminal, so I figured that somewhere file permissions got corrupted. therefore, I re-installed R (I tried 2.1.1 and 2.2.0), but same result: I can't start a session. The install itself runs fine, though. Does anyone know what is going on? Where can I re-establish my ''rights'' to use R ??? My R.app file is defined as drwxrwxr-x. I did not see any mention of a similar problem in the archives. Thank you in advance for your insights! eric Eric Pante --- Graduate Student in Marine Biology Grice Marine Laboratory 205 Fort Johnson Road, Charleston SC 29412 --- "On ne force pas la curiosite, on l'eveille ..." Daniel Pennac __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] problem with R on mac os x
Thanks Doug and Peter, I changed the permissions of the tmp dir as root, and it made the trick! I still don't know how the permissions got changed ... best, eric On Dec 12, 2005, at 3:37 PM, Douglas Grove wrote: > The error are telling you that you don't have permission to > create a directory in /tmp. So the problem is with your permissions > to the directory /tmp, not with R. That's why reinstalling didn't > help. > > Doug > > > On Mon, 12 Dec 2005, Eric Pante wrote: > >> Hello all, >> >> R just ''stopped working'' on my machine (ibook g4, os 10.3.9). >> between >> last time I used it and now, I did not do anything but check emails >> and >> browse the internet. when I try to start the GUI, it appears and >> disappears as rapidly. when I tried to run a session from the >> terminal, >> I got the following: >> mkdir: /tmp/Rtmp590-29493: Permission denied >> mkdir: /tmp/Rtmp590: Permission denied >> ERROR: cannot create temporary R session directory >> If I log as root, I can start a session from the terminal, so I >> figured >> that somewhere file permissions got corrupted. therefore, I >> re-installed R (I tried 2.1.1 and 2.2.0), but same result: I can't >> start a session. The install itself runs fine, though. >> >> Does anyone know what is going on? Where can I re-establish my >> ''rights'' to use R ??? My R.app file is defined as drwxrwxr-x. I did >> not see any mention of a similar problem in the archives. >> >> Thank you in advance for your insights! >> eric >> >> Eric Pante >> --- >> Graduate Student in Marine Biology >> Grice Marine Laboratory >> 205 Fort Johnson Road, Charleston SC 29412 >> --- >> >> "On ne force pas la curiosite, on l'eveille ..." >> Daniel Pennac >> >> __ >> R-help@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide! >> http://www.R-project.org/posting-guide.html >> > > Eric Pante --- Graduate Student in Marine Biology Grice Marine Laboratory 205 Fort Johnson Road, Charleston SC 29412 --- "On ne force pas la curiosite, on l'eveille ..." Daniel Pennac __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Two problems compiling my shared library...
Since requests keep trickling in, I have finally gotten around to polishing my rtiff package for R. This package will read TIFF images into a pixmap for subsequent processing. However, I am encountering a couple problems with compiling the shared library. 1. On windows (R 2.2.0): R CMD INSTALL successfully compiles a dll, but the dll has no entry points (as revealed by nm rtiff.dll), leading to "C entry point ... not in load table" errors when I try to use the library. Here is how R CMD INSTALL built the dll: ---8<-- MkRules:143: warning: ignoring old commands for target `.c.o' making rtiff.d from rtiff.c g++ -Ic:/usr/include -Wall -O2 -c rtiff.c -o rtiff.o rtiff.c: In function `void reduce(int*, int*, int*, int*, double*)': rtiff.c:138: warning: converting to `int' from `double' rtiff.c:139: warning: converting to `int' from `double' ar cr rtiff.a rtiff.o ranlib rtiff.a windres --include-dir c:/usr/include -i rtiff_res.rc -o rtiff_res.o gcc --shared -s -o rtiff.dll rtiff.def rtiff.a rtiff_res.o -Lc:/usr/src/gnuwin32 -ltiff -lg2c -lR ... DLL made ---8<-- However, if I simply do the following: gcc -shared -o rtiff.dll rtiff.c -ltiff I get a functional shared library. Any clues as to why R CMD INSTALL is resulting in an entry-pointless dll? (And couldn't the shared library compilation be greatly simplified as I have demonstrated above?) 2. On (ubuntu) Linux (R 2.1.0): R CMD INSTALL results in an rtiff.so that crashes with a segmentation fault. Again, gcc -shared -o rtiff.so rtiff.c -ltiff results in a function shared library. Here, I have traced the problem to the -O2 flag with which R was compiled. If I "hand compile" with the -O2 flag, I get the segmentation fault back. A search of the internet suggests this is likely a GCC bug, which perhaps I could patch, but I don't want to expect potential users of my library to have to patch their GCC. So...can I eliminate the -O2 option via Makevars somehow, or do I need my own custom Makefile to get around this? Thank you, Eric This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] segmetation fault
Elizabeth Lawson Wrote: > > Hey, > > I don;t know if anyone has come across this error before... More times than I care to remember. > > I am running R on the terminal of my MAC OS X 10.3.4 and I have written > C code and compiled it using > R CMD SHLIB mycode.c > There were no problems in compiling so I now have mycode.o and mycode.so. A segmentation fault occurs when you try to access memory you didn't allocate for your use (see below). In other words, you are trying to use memory outside the segment allocated to your program (which, if allowed, could result in corrupting memory being used by other programs--which brings back unhappy memories of days gone by when an error in one program could crash the whole system). So these kinds of problems will not show up at compile time...only when you actually run the program. > I used dyn.load("mycode.so") and again, no problems. But when I try to > use the code .C("mycode",x) I get the error Segmentation fault and R shuts > down. Any ideas as to where my problem could be? When I run into a segmentation fault, it is usually because I am trying to access an element of an array that is beyond what I have allocated, as in... int main() { int *a; a = (int*) malloc(3*sizeof(int)); printf("Fasten your seatbelts...\n"); a[4000] = 12; return(0); } One less obvious way this can happen is forgetting to initialize your arrays to the proper length before passing a reference to them to your C function. If you still are having trouble, you could post a small snippet of code that recreates the error for us to examine. HTH, Eric This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Repeating functions
Ronnie Babigumira said... > >Hi, I have a number of spatial weight files and using Roger Bivand's spdep, I >would like to > >1. Convert them into neighbor lists using >2. Convert the neighbor lists into spatial weights > >For a given file, the syntax would be > >mygal_nb1 <- read.gal("mygalfile1", override.id = TRUE) >myweight1 <- nb2listw(mygal_nb1) > >I have mygalfile[i] with i from 1 through to 6 and would like to repeat the >above two lines through 1 to 6. >something like (the syntax below is not correct...just an illustration) > >for (i in 1:6) { >mygal_nb[i] <- read.gal("mygalfile[i]", override.id = TRUE) >myweight[i] <- nb2listw(mygal_nb[i] >} > > >Kindly point me in the right direction (whilst read through the material I >have) Looks like you want to create lists of objects. Likely the best place to start is looking at the section on lists in An Introduction to R (which came with your R distribution and can be accessed via help.start(), or you can download it here: http://cran.r-project.org/doc/manuals/R-intro.pdf). -Eric >Ronnie This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Segmetation Fault in R
Marcelo Damasceno wrote... >Hi all, > >I has a C code in Linux, it has 7 pointers and compile e run OK, but when I >run in R happens Segmetation Fault. >When I use calloc function, it returns NULL. >What's wrong? >I would like more information about R-alloc function? >Thanks! What is wrong is that there is a bug in your C code related. A search of the R-help mailing list archives seems to indicate that there have been about 10,800 prior posts about segmentation faults, the last of which was a few days ago--in which I and then Dr. Ripley described in some detail what causes segmentation faults. I would review these, and if you are still having this problem, post a snippet of code that recreates the problem to the appropriate C development list serve. HTH, Eric This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] A comment about R:
>Kjetil Halvorsen wrote... > >Readers of this list might be interested in the following commenta about R. > > >In a recent report, by Michael N. Mitchell >http://www.ats.ucla.edu/stat/technicalreports/ >says about R: >"Perhaps the most notable exception to this discussion is R, a language for >statistical computing and graphics. > ---8<- After reading this commentary a couple of times, I can't quite figure out if he is damning with faint praise, or praising with faint damnation. (For example, after observing how many researchers around me approach statistical analysis, I'd say discouraging "casual" use is a _feature_.) -Eric This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] A comment about R:
Berton Gunter writes > U > > I cannot say how easy or hard R is to learn, but in response to the UCLA > commentary: > > > However, I > > feel like R > > is not so much of a statistical package as much as it is a statistical > > programming environment that has many new and cutting edge > > features. > > Please note: the first sentence of the Preface of THE Green Book > (PROGRAMMING WITH DATA: A GUIDE TO THE S LANGUAGE) by John Chambers, the > inventor of the S Language, explicitly states: > > "S is a programming language and environment for all kinds of computing > involving data." > > I think this says that R is **not** meant to be a statistical package in > the > conventional sense and should not be considered one. As computing > involving > data is a complex and frequently messy business on both technical > (statistics), practical (messy data), and aesthetic (graphics, tables) > levels, it is perhaps to be expected that "a programming language and > environment for all kinds of computing involving data" is complex. > Personally, I find that (Chambers's next sentence) R's ability "To turn > ideas into software, quickly and faithfully," to be a boon. Right. So in 2 months I will finish my MD program here in the U.S. I also have a master's degree in Epidemiology (in which we used SAS)--but that hardly qualifies me as statistics expert. Nonetheless, I have learned to use R out of necessity without undue difficulty. So have multiple of my colleagues around me with MDs, PhDs, and Master's degrees. We do mainly microarray analysis, so the availability of a rapidly developing and customizable toolset (BioC packages) is essential to our work. And, in the same vein of others' comments, R's "nuts and bolts" characteristics make me think, learn, and improve. And the fear of getting Ripleyed on the mailing list also makes me think, read, and improve before submitting half baked questions to the list. So in sum, I use R because it encourages thoughtful analysis, it is flexible and extensible, and it is free. I feel that these are strengths of the environment, not weaknesses. So if an individual finds another tool better suited for their work that is obviously just fine, but I hardly think these characteristics of R are grounds for criticism, excellent proposals for evolution of documentation and mailing lists notwithstanding. -Eric This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] newbie R question
On Tue, 2006-01-03 at 16:07 -0500, Mark Leeds wrote: > I'm sorry to bother everyone with a stupid > question but, when I am at an R prompt in Windows, > is there a way to see what packages > you already have installed from the R site so > that you can just do library(name_of_package) > and it will work. > > I've looked at help etc but I can't find > a command like this. Maybe there > isn't one which is fine. library() HTH, Eric This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] removal of an element from a vector
Gynmeerut asks... > Dear All, > I have some problem in R which I'm explaining using an example: > x<-(120,235,172,95,175,200,233,142) > i want to remove the elements which are lesser than 100 and as a result i > want two vectors > > y<-(containing elements <100) > z<-(remaining elements) x<-c(120,235,172,95,175,200,233,142) y <- x[which(x < 100)] z <- x[which(x >= 100)] > Moreover if I wish to use two different programs for vectors y and z. > which command shall I use(will IF-ELSE work ?) This part of the question I do not quite understand. Now that you have y and z, you can do whatever you like with them. But R certainly does have conditional control statements (if/else) as described in An Introduction to R. -Eric > > > > Thanks and regards, > > GS > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting- > guide.html This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Why doesn't this nested loop work?
Teresa Nelson > Hi there, > > > > I can get the for-loop to work, I can get the while loop to work. But I > can't get a for loop to work nested within the while loop - why? > > > > Please help, > > Teresa It actually does work, but I think the problem is with your matrix indexing. See the sample below. You could also check out ?seq, ?rep, and ?apply for solving this problem with fewer lines of code. n.max <- 300 NUM <- 25 n.sim <- 10 j <- (n.max/NUM)*n.sim results <- matrix(0, nrow=j, ncol=2) while(NUM <= n.max){ for(i in 1:n.sim){ k <- (NUM/25)*i results[((NUM / 25) - 1) * n.sim + i, 1] <- k results[((NUM / 25) - 1) * n.sim + i, 2] <- NUM cat("Iteration", i, ": NUM=", NUM, "k=", k, "\n") } NUM <- NUM + 25 } This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to produce this graphic
Lisa Wang asks... > Subject: [R] How to produce this graphic > > Hello there, > > I would like to produce a plot of x<-c(4,5,6),which is the mean of each > group and y<-c('groupA','groupB','groupC'). > > plot (x,y) can not produce any graphics because y is not numerical. > > What should I do to produce this graphic? > One possibility: x <- c(4,5,6) plot(x, axes=F) axis(1, c(1:3), labels=y) or see ?bar.plot -Eric > > Thank you in advance > > Lisa Wang > Princess Margaret Hospital > Toronto,Ca > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting- > guide.html This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Suggestion for big files [was: Re: A comment about R:]
> -Original Message- > > [ronggui] > > >R's week when handling large data file. I has a data file : 807 vars, > >118519 obs.and its CVS format. Stata can read it in in 2 minus,but In > >my PC,R almost can not handle. my pc's cpu 1.7G ;RAM 512M. > > Just (another) thought. I used to use SPSS, many, many years ago, on > CDC machines, where the CPU had limited memory and no kind of paging > architecture. Files did not need to be very large for being too large. > > SPSS had a feature that was then useful, about the capability of > sampling a big dataset directly at file read time, quite before > processing starts. Maybe something similar could help in R (that is, > instead of reading the whole data in memory, _then_ sampling it.) > > One can read records from a file, up to a preset amount of them. If the > file happens to contain more records than that preset number (the number > of records in the whole file is not known beforehand), already read > records may be dropped at random and replaced by other records coming > from the file being read. If the random selection algorithm is properly > chosen, it can be made so that all records in the original file have > equal probability of being kept in the final subset. > > If such a sampling facility was built right within usual R reading > routines (triggered by an extra argument, say), it could offer > a compromise for processing large files, and also sometimes accelerate > computations for big problems, even when memory is not at stake. > Since I often work with images and other large data sets, I have been thinking about a "BLOb" (binary large object--though it wouldn't necessarily have to be binary) package for R--one that would handle I/O for such creatures and only bring as much data into the R space as was actually needed. So I see 3 possibilities: 1. The sort of functionality you describe is implemented in the R internals (by people other than me). 2. Some individuals (perhaps myself included) write such a package. 3. This thread fizzles out and we do nothing. I guess I will see what, if any, discussion ensues from this point to see which of these three options seems worth pursuing. > -- > François Pinard http://pinard.progiciels-bpi.ca > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting- > guide.html This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] matrix export
Dear listers, I need to export a distance matrix in the following format : a 0.0 1.0 0.2 1.0 1.0 b 1.0 0.0 1.0 1.0 1.0 c 0.2 1.0 0.0 1.0 1.0 d 1.0 1.0 1.0 0.0 1.0 e 1.0 1.0 1.0 1.0 0.0 I tried write.matrix() from the MASS library, which gives: a b c d e 0.0 1.0 0.2 1.0 1.0 1.0 0.0 1.0 1.0 1.0 0.2 1.0 0.0 1.0 1.0 1.0 1.0 1.0 0.0 1.0 1.0 1.0 1.0 1.0 0.0 Does anyone know of an R trick to change the location of the headers ?or do I need to do this externally, through perl or bash ? Thanks in advance for your help, Eric Eric Pante College of Charleston, Grice Marine Laboratory 205 Fort Johnson Road, Charleston SC 29412 "On ne force pas la curiosite, on l'eveille ..." Daniel Pennac __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matrix export
Thanks, Bert write.table won't do the trick, because distance matrices in R are presented as lower triangular matrices. write.table "cannot coerce class "dist" into a data.frame". maybe there is a way to transform the lower triangular matrix into a full matrix, and then use write.table ? cheers, Eric On Jan 19, 2006, at 1:38 PM, Berton Gunter wrote: > Just use write.table() from the base package with row.names=TRUE (the > default). > > -- Bert Gunter > Genentech Non-Clinical Statistics > South San Francisco, CA > > "The business of the statistician is to catalyze the scientific > learning > process." - George E. P. Box > > > >> -Original Message- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On Behalf Of Eric Pante >> Sent: Thursday, January 19, 2006 10:09 AM >> To: r-help@stat.math.ethz.ch >> Subject: [R] matrix export >> >> Dear listers, >> >> I need to export a distance matrix in the following format : >> >> a 0.0 1.0 0.2 1.0 1.0 >> b 1.0 0.0 1.0 1.0 1.0 >> c 0.2 1.0 0.0 1.0 1.0 >> d 1.0 1.0 1.0 0.0 1.0 >> e 1.0 1.0 1.0 1.0 0.0 >> >> I tried write.matrix() from the MASS library, which gives: >> >> a b c d e >> 0.0 1.0 0.2 1.0 1.0 >> 1.0 0.0 1.0 1.0 1.0 >> 0.2 1.0 0.0 1.0 1.0 >> 1.0 1.0 1.0 0.0 1.0 >> 1.0 1.0 1.0 1.0 0.0 >> >> Does anyone know of an R trick to change the location of the headers >> ?or do I need to do this externally, through perl or bash ? >> >> Thanks in advance for your help, >> Eric >> >> >> Eric Pante >> >> College of Charleston, Grice Marine Laboratory >> 205 Fort Johnson Road, Charleston SC 29412 >> >> >> "On ne force pas la curiosite, on l'eveille ..." >> Daniel Pennac >> >> __ >> R-help@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide! >> http://www.R-project.org/posting-guide.html >> > > Eric Pante College of Charleston, Grice Marine Laboratory 205 Fort Johnson Road, Charleston SC 29412 "On ne force pas la curiosite, on l'eveille ..." Daniel Pennac __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Image Processing packages
Thomas Kaliwe wrote: > Hi, > > I've been looking for Image Processing packages. Thresholding, Edge > Filters, Dct, Segmentation, Restoration. I'm aware, that Octave, Matlab > etc. would be a good address but then I'm missing the "statistical > power" of R. Does anybody know of packages, projects etc. Comments on > wether the use of R for such matters is useful are welcome. > See also my package rtiff for reading tiff images. I routinely do image analysis in R. Yes, it is relatively slow compared to dedicated solutions, but I like the smooth integration with the associated statistical analysis and the ability to have a single script that performs the image analysis and multiple files and subsequent statistical analysis, and with modern computing equipment R is fast enough for my purposes. I have a variety of standard image processing functions written in R, but have yet to distribute them because most people choose not to perform image analysis in R for the previously stated reasons. So in general I would agree that R is sub-optimal for image processing (and this is certainly outside the realm of things R was intended to do if I read the early mailing list archives correctly). However, it can be done and it might be desirable to do so from a work-flow perspective. -Eric > Greetings > > Thomas Kaliwe This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Image Processing packages
Charles Annis, P.E. writes... > Eric: > > I use R to quantify the efficacy of ultrasonic inspections of metal > components (e.g. looking for nonmetallic inclusions in forgings) and use R > for image processing, but my methods have been rather a kluge. I am > interested in your R functions, if you will make them available. > Unfortunately, making a package for CRAN is (in my opinion) WAY too hard > on > Windows, and I've given up, but I hope that you do not. I second Stephan > Matthiesen's recent suggestion that you make your image processing > functions > available to fellow R users, if not on CRAN, then perhaps as ascii files > from your website. I knew I was asking for trouble when I sent that post. =) Ok, I will clean up my code and put together a package, hopefully in the next couple of weeks. -Eric > > Thanks. > > Charles Annis, P.E. This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Image Processing packages
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Hi, > > Is it possible that I could see some of your functions and/or results of > those functions(Eric, Charles, Stephan). It's more about that I'd like > to see what already has been accomplished and the way that was chosen > thus circumventing reinvention and getting an overview. > Yes. I sent some examples to you off list (didn't want to clog the mailing list with the images). > > Cheers > > Thomas > This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Image Processing packages
Nice. May I incorporate these into the collection I am packaging up for redistribution? -Eric -Original Message- From: Vincent Zoonekynd [mailto:[EMAIL PROTECTED] Sent: Mon 1/30/2006 6:48 PM To: R-help@stat.math.ethz.ch Cc: [EMAIL PROTECTED]; Kort, Eric; [EMAIL PROTECTED]; Thomas Kaliwe Subject: Re: [R] Image Processing packages A couple of years ago, I was using R as a first step before implementing image analysis algorithms on a portable biochip reader. Here is the code I had written at the time, should someone find it useful (it mainly contains "morphological operations"): http://zoonek2.free.fr/UNIX/48_R/morphology.R There are a few examples (commented in French) at the end of http://zoonek.free.fr/Ecrits/2004_BioRet.pdf.bz2 The code of those examples: http://zoonek2.free.fr/UNIX/48_R/Rapport_final_morphologie.Rnw -- Vincent This email message, including any attachments, is for the so...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] matching tables
Dear Listers, I am trying to match tables that DO NOT have the same length. The tables result from the function "table()" so they look like this: table 1 2 3 4 3 5 7 table 2 1 2 3 6 4 5 I need the following output: (NOTICE THE ZEROS) 1 2 3 4 table1 0 3 5 7 table2 6 4 5 0 Unfortunately, I was not successful using "match()". Previous postings explain how to do similar matching, but for tables for same length, specifically. Any thoughts ? Thanks ! eric Eric Pante College of Charleston, Grice Marine Laboratory 205 Fort Johnson Road, Charleston SC 29412 Phone: 843-953-9190 (lab) -9200 (main office) "On ne force pas la curiosite, on l'eveille ..." Daniel Pennac __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Creating multiple copies of rows in data frames
ListeRs, Within the last two months, I thought I saw mention of an R function that would create a new data frame composed of duplicates or multiple copies of rows of an input data frame given one or several columns of values indicating how many times each row should be copied. As a simple example, given a dataframe: > in.df x y 1 A 1 2 B 2 3 C 3 "func.name (in.df, in.df$y)" would produce something like: x y 1 A 1 2 B 2 3 B 2 4 C 3 5 C 3 6 C 3 For the life of me, I can't remember what that function was called, nor can I find it using help.search or RSiteSearch on terms like "duplicate" or "copy". Perhaps it had another primary purpose, but this was a side-effect or secondary capability. Was I hallucinating, or does this exist as a function in base R? Or, will I have to make one with "rep"? Thanks in advance! e. -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R and marine protected areas: algorithms for site selection
Dear listers, a central problem in conservation biology is the selection of sites in reserve network design. many algorithms have been published, and I was wondering any have been implemented in R. I did not seen anything on CRAN or R-help, or on the web in general. Best regards, Eric Eric Pante College of Charleston, Grice Marine Laboratory 205 Fort Johnson Road, Charleston SC 29412 Phone: 843-953-9190 (lab) -9200 (main office) "On ne force pas la curiosite, on l'eveille ..." Daniel Pennac __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Rmpi and rsprng for Windows
Dear f_R_iends, I'm new on parallel programming and trying to use a machine with Windows to access a linux computer cluster. I could install the 'snow' package, but not 'Rmpi' nor 'rsprng'. Some tips for intalling such packages for Windows R ? All the best, -- Barba Departamento de Ciências Exatas Universidade Federal de Lavras Minas Gerais - Brasil [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] GAM for censored data? (survival analysis)
First let me admit that I am no statistician... rather, an ecologist with just enough statistical knowledge to be dangerous. I've got a dataset with percent ground cover values for species and other entities. The data are left censored at zero, in that percent ground cover cannot be negative. (My data rarely reach 100% cover so I haven't bothered with adding a right censoring at 100). I've done some previous analyses using survival analysis methods to create a predictive model for an entity of particular interest... library("survival"); survreg(Surv(Y) ~ X). However, I know my data do not really match linear modeling and would like to work with some alternate methods, one of which is GAM. I noticed that Yee and Mitchell (1991, p.589) stated that GAM is appropriate for "certain types of survival data". How do I implement a survival data model in GAM with R? I've searched both R help and the R site search, but not found anything relevant. Would it be as simple as library("survival"); library("mgcv"); gam(Surv(Y) ~ X) ??? While I have your attention, I have a related second question. I'd like to model one entity (percent ground cover) as a function of another (also percent ground cover). Is there any way to deal with a censored predictor variable as well as the censored response? Citation: Yee, T. W. & N. D. Mitchell. 1991. Generalized additive models in plant ecology. Journal of Vegetation Science 2: 587-602. Thanks, -Eric Peterson Vegetation Ecologist Nevada Natural Heritage Program [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] import data
Hello! I wonder if you might help me with informations about how to import data with a 2.4.1 R version without the menu "Import data". Best regards. Eric Duplex ZOUKEKANG Ingénieur Zootechnicien Montpellier SupAgro Master2 AAA-PARC tel : +33(0)661432340 [EMAIL PROTECTED] ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] access to 'formula' terms in a user function
This is probably buried somewhere in the R help archives, but I've been unable to find it, so perhaps the keywords I use here will help bring the topic to the surface more easily for future users. I want to write my own modeling function (ultimately for some multidimensional windowing - but this question is on scripting basics). For purposes of figuring out my needs, lets just consider writing a function that takes a formula and a dataset, and outputs the mean of each variable in the formula model. So: MyFunction <- function(AFormula, ADataFrame) { ... } >MyFunction(Y ~ A + B, TheData) would give results something like: Mean of MyData$Y is 5.3 Mean of MyData$A is 3.4 Mean of MyData$B is 8.2 QUESTION 1: How do I determine the terms in the formula within the function? QUESTION 2: How do I use one of those terms to get to the individual columns, like MyData$Y ? Thanks! -Eric --- Eric Peterson Vegetation Ecologist Nevada Natural Heritage Program [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Combine R2HTML and Rcmd BATCH?
Hi Dieter, There are two ways in R2HTML to work woth graphics. - HTMLplot, that may require the interactive environment depending on how you use it - HTMLInsertGraph that is more suitable for batch scripting but requires some more work. First method: HTMLplot and plotFunction (use print for trellis graphics). Not recommended. Second method; - Create the graphic in the format you need - use HTMLInsertGraph to write HTML linking tag Synopsis: myGraphic <- file.path(outdir,"graph1.png") png(file=myGraphic) hist(rnorm(100)) dev.off() HTMLInsertGraph("graph1.png",Caption="Graph1") Do not hesitate to send me your file if more help is required Best wishes, Eric 2007/7/17, Dieter Vanderelst <[EMAIL PROTECTED]>: > > Hi All, > > I have an R script that spawns output in the form of an HTML page. This > is done by the R2HTML package. > > Now I want to run the same script using Rcmd BATCH. However, it seems > that it is not possible to use R2HTML in this case. > > My script ends with this error message: > # > Error in dev.print(png, file = AbsGraphFileName, width = Width, height = > Height, : > > can only print from screen device > > Execution halted > # > > I can not find how to work around this problem in the R2HTML manual or > the help archives. > > Has anybody done a similar thing before? Any suggestions? > > Greetings, > Dieter > > -- > Dieter Vanderelst > [EMAIL PROTECTED] > Department of Industrial Design > Designed Intelligence > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Eric Lecoutre Consultant - Business & Decision Business Intelligence & Customer Intelligence __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] the large dataset problem
Dear useRs, I recently began a job at a very large and heavily bureaucratic organization. We're setting up a research office and statistical analysis will form the backbone of our work. We'll be working with large datasets such the SIPP as well as our own administrative data. Due to the bureaucracy, it will take some time to get the licenses for proprietary software like Stata. Right now, R is the only statistical software package on my computer. This, of course, is a huge limitation because R loads data directly into RAM making it difficult (if not impossible) to work with large datasets. My computer only has 1000 MB of RAM, of which Microsucks Winblows devours 400 MB. To make my memory issues even worse, my computer has a virus scanner that runs everyday and I do not have the administrative rights to turn the damn thing off. I need to find some way to overcome these constraints and work with large datasets. Does anyone have any suggestions? I've read that I should "carefully vectorize my code." What does that mean ??? !!! The "Introduction to R" manual suggests modifying input files with Perl. Any tips on how to get started? Would Perl Data Language (PDL) be a good choice? http://pdl.perl.org/index_en.html I wrote a script which loads large datasets a few lines at a time, writes the dozen or so variables of interest to a CSV file, removes the loaded data and then (via a "for" loop) loads the next few lines I managed to get it to work with one of the SIPP core files, but it's SLW. Worse, if I discover later that I omitted a relevant variable, then I'll have to run the whole script all over again. Any suggestions? Thanks, - Eric __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] the large dataset problem
Dear useRs, I recently began a job at a very large and heavily bureaucratic organization. We're setting up a research office and statistical analysis will form the backbone of our work. We'll be working with large datasets such the SIPP as well as our own administrative data. Due to the bureaucracy, it will take some time to get the licenses for proprietary software like Stata. Right now, R is the only statistical software package on my computer. This, of course, is a huge limitation because R loads data directly into RAM making it difficult (if not impossible) to work with large datasets. My computer only has 1000 MB of RAM, of which Microsucks Winblows devours 400 MB. To make my memory issues even worse, my computer has a virus scanner that runs everyday and I do not have the administrative rights to turn the damn thing off. I need to find some way to overcome these constraints and work with large datasets. Does anyone have any suggestions? I've read that I should "carefully vectorize my code." What does that mean ??? !!! The "Introduction to R" manual suggests modifying input files with Perl. Any tips on how to get started? Would Perl Data Language (PDL) be a good choice? http://pdl.perl.org/index_en.html I wrote a script which loads large datasets a few lines at a time, writes the dozen or so variables of interest to a CSV file, removes the loaded data and then (via a "for" loop) loads the next few lines I managed to get it to work with one of the SIPP core files, but it's SLW. Worse, if I discover later that I omitted a relevant variable, then I'll have to run the whole script all over again. Any suggestions? Thanks, - Eric __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] the large dataset problem
Just a note of thanks for all the help I have received. I haven't gotten a chance to implement any of your suggestions because I'm still trying to catalog all of them! Thank you so much! Just to recap (for my own benefit and to create a summary for others): Bruce Bernzweig suggested using the R.huge package. Ben Bolker pointed out that my original message wasn't clear and asked what I want to do with the data. At this point, just getting a dataset loaded would be wonderful, so I'm trying to trim variables (and if possible, I would also like to trim observations). He also provided an example of "vectorizing." Ted Harding suggested that I use AWK to process the data and provided the necessary code. He also tested his code on older hardware running GNU-Linux (or Unix?) and showed that AWK can process the data even when the computer has very little memory and processing power. Jim Holtman had similar success when he used Cygwin's UNIX utilities on a machine running MS Windows. They both used the following code: gawk 'BEGIN{FS=","}{print $(1) "," $(1000) "," $(1275) "," $(5678)}' < tempxx.txt > newdata.csv Fortunately, there is a version of GAWK for MS Windows. ... Not that I like MS Windows. It's just that I'm forced to use that 19th century operating system on the job. (After using Debian at home and happily running RKWard for my dissertation, returning to Windows World is downright depressing). Roland Rau suggested that I use a database with RSQLite and pointed out that RODBC can work with MS Access. He also pointed me to a sub-chapter in Venables and Ripley's _S Programming_ and "The Whole-Object View" pages in John Chamber's _Programming with Data_. Greg Snow recommended biglm for regression analysis with data that is too large to fit into memory. Last, but not least, Peter Dalgaard pointed out that there are options within R. He suggests using the colClasses= argument for when "reading" data and the what= argument for "scanning" data, so that you don't load more columns than necessary. He also provided the following script: dict <- readLines("ftp://www.sipp.census.gov/pub/sipp/2004/l04puw1d.txt";) D.lines <- grep("^D ", dict) vdict <- read.table(con <- textConnection(dict[D.lines])); close(con) head(vdict) I'll try these solutions and report back on my success. Thanks again! - Eric __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] MTBF Reliability calculations
I'm working on a project involving reliability values (known failure rates) for a system with approximately 700 components with a set cconfiguration. I'm looking to compute a "parts-count" MTBF (mean time between failures) for the system. (See also MIL-HDBK-217) Is there anything in R that can help me with this? Thanks, Eric Jennings QA Technical Assistant Crane Electronics --Redmond 10301 Willows Road P.O. Box 97005 Redmond, WA 98073 PH 425.895.5039 e-mail [EMAIL PROTECTED] Attention: The information contained in this email message may be privileged and is confidential information intended only for the use of the recipient, or any employee or agent responsible to deliver it to the intended recipient. Any unauthorized use, distribution or copying of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender immediately and destroy the original message and all attachments from your electronic files. -- This message has been scanned for viruses and\ dangerous con...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rfImpute
I am having trouble with the rfImpute function in the randomForest package. Here is a sample... clunk.roughfix<-na.roughfix(clunk) > > clunk.impute<-rfImpute(CONVERT~.,data=clunk) ntree OOB 1 2 300: 26.80% 3.83% 85.37% ntree OOB 1 2 300: 18.56% 5.74% 51.22% Error in randomForest.default(xf, y, ntree = ntree, ..., do.trace = ntree, : NA not permitted in predictors So roughFix works, but rfImpute doesn't.... Thanks, Eric ent3c *at* virginia.edu -- Eric Turkheimer, PhD Department of Psychology University of Virginia PO Box 400400 Charlottesville, VA 22904-4400 434-982-4732 434-982-4766 (FAX) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] book and website announcement
The 2nd Edition of my book (with Jiahui Wang) Modeling Financial Time Series with S-PLUS has recently been published by Springer-Verlag. The 2nd Edition is updated to cover S-PLUS 7 and S+FinMetrics 2.0. I have also created a website for the 2nd Edition, which can be found at http://faculty.washington.edu/ezivot/MFTS2ndEdition.htm The website contains scripts for all of the examples in the book, as well as a substantial amount of additional material and examples. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] subsetting and NAs
R-help, I'm getting some unexpected behavior with subsetting a data frame (aircraft flight data) that I can't sort out. Here is a simplified version of my data frame and problem: > flight FlightID TailNo FlightDate HobbsTime FlightCost Date year 1 4497 6009K 2.2 330.0 NA 2 4498 6009K 0.8 120.0 NA 3 4499 6009K 0.9 135.0 NA 4 4500 6009K 1.1 165.0 NA 5 4501 6009K 1.5 225.0 NA 2587 7083 9206N 4/8/2009 1.5 103.5 2009-04-08 2009 2588 7084 9206N 4/10/2009 1.3 89.7 2009-04-10 2009 2589 7085 9206N 4/11/2009 1.9 131.1 2009-04-11 2009 2590 7086 9206N 4/12/2009 1.3 89.7 2009-04-12 2009 2591 7087 9206N 4/15/2009 1.1 75.9 2009-04-15 2009 2979335208 91630 1/21/2006 1.4 107.8 2006-01-21 2006 2979435209 91630 1/21/2006 0.7 53.9 2006-01-21 2006 2979535210 9725B 1/21/2006 1.4 138.6 2006-01-21 2006 2979635212 91630 1/28/2006 1.0 77.0 2006-01-28 2006 2979735213 91630 1/28/2006 1.6 123.2 2006-01-28 2006 2979835214 3386E 1/5/2006 1.1 86.9 2006-01-05 2006 I then try to extract the error years : > errors <- flight[flight$year > 2006,] > errors FlightID TailNo FlightDate HobbsTime FlightCost Date year NA NA NA NA NA NA.1 NA NA NA NA NA.2 NA NA NA NA NA.3 NA NA NA NA NA.4 NA NA NA NA 2587 7083 9206N 4/8/2009 1.5 103.5 2009-04-08 2009 2588 7084 9206N 4/10/2009 1.3 89.7 2009-04-10 2009 2589 7085 9206N 4/11/2009 1.9 131.1 2009-04-11 2009 2590 7086 9206N 4/12/2009 1.3 89.7 2009-04-12 2009 2591 7087 9206N 4/15/2009 1.1 75.9 2009-04-15 2009 Would someone please explain to me why the new data frame has all columns (and row names) replaced with NA where year was NA and how to avoid this behavior?. Thanks in advance. I am using R v2.2.1 on Windows XP. Cheers, eric Sample Data: structure(list(FlightID = c(4497, 4498, 4499, 4500, 4501, 7083, 7084, 7085, 7086, 7087, 35208, 35209, 35210, 35212, 35213, 35214 ), TailNo = structure(c(28, 28, 28, 28, 28, 49, 49, 49, 49, 49, 47, 47, 54, 47, 47, 15), .Label = c("12345", "133BW", "152GB", "172CM", "172RW", "1955L", "2219E", "222WC", "231NW", "2496M", "2630V", "2726E", "2903A", "2977G", "3386E", "3803E", "3979V", "409EV", "43160", "46275", "4644B", "47885", "4922D", "4975F", "5073H", "5317P", "5335P", "6009K", "6013X", "6036J", "6360D", "64048", "6495R", "66038", "67844", "6913R", "733XL", "734BT", "738QA", "808LP", "8148F", "8164Z", "8269T", "8451R", "8654V", "8715E", "91630", "9199Z", "9206N", "92SA", "936GW", "9488G", "9596H", "9725B", "9756U", "ELITE", "N20BY", "N53MF"), class = "factor"), FlightDate = c(NA, NA, NA, NA, NA, "4/8/2009", "4/10/2009", "4/11/2009", "4/12/2009", "4/15/2009", "1/21/2006", "1/21/2006", "1/21/2006", "1/28/2006", "1/28/2006", "1/5/2006"), HobbsTime = c(2.2, 0.8, 0.9, 1.1, 1.5, 1.5, 1.3, 1.9, 1.3, 1.1, 1.4, 0.7, 1.4, 1, 1.6, 1.1), FlightCost = c(330, 120, 135, 165, 225, 103.5, 89.7, 131.1, 89.7, 75.9, 107.8, 53.9, 138.6, 77, 123.2, 86.9 ), Date = structure(c(NA, NA, NA, NA, NA, 1239174000, 1239346800, 1239433200, 1239519600, 1239778800, 1137830400, 1137830400, 1137830400, 1138435200, 1138435200, 1136448000), tzone = "", class = c("POSIXt", "POSIXct")), year = c(NA, NA, NA, NA, NA, 2009, 2009, 2009, 2009, 2009, 2006, 2006, 2006, 2006, 2006, 2006)), .Names = c("FlightID", "TailNo", "FlightDate", "HobbsTime", "FlightCost", "Date", "year" ), row.names = c("1", "2", "3", "4", "5", "2587", "2588", "2589", "2590", "2591", "29793", "29794", "29795", "29796", "29797", "29798"), class = "data.frame") -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] subsetting and NAs
Had I just looked at flight$year > 2006, I would've seen what was up. Thanks much Peter! Cheers, eric P Ehlers wrote: > > [snip] > > flight$year > 2006 will return TRUE/FALSE, not row numbers. Try this: > > errors <- subset(flight, subset = year > 2006) > > Peter Ehlers > -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Adding values to top of bars in barchart
Given the following data frame ("freq.sp"), > str(freq.sp) `data.frame': 42 obs. of 4 variables: $ behav : Factor w/ 6 levels "approach","bowride",..: 1 1 1 1 1 1 1 2 2 2 ... $ species: Factor w/ 7 levels "COAST_SPOT","EAST_SPINR",..: 1 2 3 4 5 6 7 1 2 3 ... $ n : int 193 194 563 357 570 369 74 194 208 633 ... $ pct: num 0.725 0.340 0.252 0.381 0.072 ... I create a trellis barchart with the following command, barchart(pct ~ behav | species, data=freq.sp, as.table=TRUE, xlab="Behavior", ylab="Frequency", ylim=c(0,1), main="Frequencies of Behaviors", scales=list(x=list(rot=45))) In this graph, I would like to include the sample sizes (the value of freq.sp$n corresponding to each freq.sp$pct) at the top of each bar. I don't see a specific command in barchart that will allow me to do this and am fairly new to lattice graphics. I've done RSiteSearches on keywords that I could think of, but didn't run across anything I recognized as useful. Any pointers on how to accomplish this would be greatly appreciated. Thanks in advance. Cheers, eric -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Adding values to top of bars in barchart
Deepayan, Thanks much! That works perfectly! Cheers, eric Deepayan Sarkar wrote: > On 4/14/06, Eric Archer <[EMAIL PROTECTED]> wrote: > >> Given the following data frame ("freq.sp"), >> >> > str(freq.sp) >> `data.frame': 42 obs. of 4 variables: >> $ behav : Factor w/ 6 levels "approach","bowride",..: 1 1 1 1 1 1 1 2 >> 2 2 ... >> $ species: Factor w/ 7 levels "COAST_SPOT","EAST_SPINR",..: 1 2 3 4 5 6 >> 7 1 2 3 ... >> $ n : int 193 194 563 357 570 369 74 194 208 633 ... >> $ pct: num 0.725 0.340 0.252 0.381 0.072 ... >> >> I create a trellis barchart with the following command, >> >> barchart(pct ~ behav | species, data=freq.sp, as.table=TRUE, >> xlab="Behavior", >> ylab="Frequency", ylim=c(0,1), main="Frequencies of Behaviors", >> scales=list(x=list(rot=45))) >> >> In this graph, I would like to include the sample sizes (the value of >> freq.sp$n corresponding to each freq.sp$pct) at the top of each bar. I >> don't see a specific command in barchart that will allow me to do this >> and am fairly new to lattice graphics. I've done RSiteSearches on >> keywords that I could think of, but didn't run across anything I >> recognized as useful. Any pointers on how to accomplish this would be >> greatly appreciated. Thanks in advance. >> > > Here's an example using the barley data. For more flexible placement > of the text, use grid.text from the grid package directly (instead of > panel.text): > > > library(lattice) > > barchart(I(yield / sum(yield)) ~ variety | site, barley, > subset = (year == "1931"), > scales = list(x = list(rot = 45)), > label = round(barley$yield), > panel = function(x, y, label, subscripts, ...) { > lab <- label[subscripts] > panel.barchart(x, y, ..., subscripts = subscripts) > panel.text(x = x, y = y + 0.001, lab = lab, > cex = 0.5) > }) > > Deepayan > -- > http://www.stat.wisc.edu/~deepayan/ > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] (sem assunto)
Dear R-colleagues, Is it possible to mix TEXT and VALUE of objects in y (or x) label of a plot? For instance: f<-2 plot(..., ylab='Axis f', ...) where "f" means the VALUE of "f". Thany you in advance, Eric. -- Barba Departamento de Ciências Exatas Universidade Federal de Lavras Minas Gerais - Brasil [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] (sem assunto)
Thak you very much indeed! Eric. On 4/20/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > > Try paste: > > paste("Axis", f) > > On 4/20/06, Eric Ferreira <[EMAIL PROTECTED]> wrote: > > Dear R-colleagues, > > > > Is it possible to mix TEXT and VALUE of objects in y (or x) label of a > plot? > > > > For instance: > > > > f<-2 > > plot(..., ylab='Axis f', ...) > > > > where "f" means the VALUE of "f". > > > > Thany you in advance, > > > > > > Eric. > > > > -- > > Barba > > Departamento de Ciências Exatas > > Universidade Federal de Lavras > > Minas Gerais - Brasil > > > >[[alternative HTML version deleted]] > > > > > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > > > -- Barba Departamento de Ciências Exatas Universidade Federal de Lavras Minas Gerais - Brasil [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] installation problem with 2.3.0
Hello, I'm in the process of trying to upgrade our R software from version 2.2.3 to 2.3.0 on our Sun workstations. In the installation process I'm encountering some puzzling errors whe I do the 'make install.' After installing the doc files successfully the installation process crashes while trying to install the etc files, with the following messages: make[1]: Leaving directory `/usr/local/R-2.3.0/doc' make[1]: Entering directory `/usr/local/R-2.3.0/etc' installing etc ... /bin/bash: -c: line 1: syntax error near unexpected token `;' /bin/bash: -c: line 1: `for f in ; do ../tools/install-sh -c -m 644 ${f} "/usr/local/lib/R/etc"; done' make[1]: *** [install] Error 2 make[1]: Leaving directory `/usr/local/R-2.3.0/etc' make: *** [install] Error 1 I've been studying the Makefile trying to figure out what would cause such an error but so far I haven't been able to figure it out. We are using Solaris 8 with GNU make version 3.79.1. I've also tried using the Sun default make (i.e. /usr/ccs/bin/make) but I get the same result. I've installed R (previous versions) many times on Solaris previously without any problems and I'm puzzled as to why we're encountering this problem in 2.3.0. Does anybody have any suggestions for things I can try to remedy this problem? Thanks very much, Eric __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] random walk on graph
Hi all, I'm having issues coding a random walk on a fully connected, undirected graph G with probability transition matrix P = (p_ij). Here is what I have so far ... for(i in 1:n){ for(m in 1:M){ x <- as.vector(matrix(rep(0,N+1),nc=N+1)) x[1] <- i for(k in 2:N+1){ y <- as.vector(matrix(rep(0,n),nc=n)) r <- runif(1) c <- c(0,cumsum(P[x[k-1],])) for(j in 1:n){ y[j] <- (r >= c[j] & r < c[j+1]) } x[k] <- which(y == 1) } L[i,m] <- x[N+1] } } its giving me the error: Error in "[<-"(`*tmp*`, k, value = integer(0)) : nothing to replace with no matter what I do I cant fix it ... any suggestions ? Thanks Eric Blabac PhD Student - ASU Dept of Mathematics/Statistics __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Vector searching and counting speed optimization
R-users, I'm seeking any suggestions on optimizing some code for speed. Here's the setup: the code below is part of a larger chunk that is calculating Fst values across loci and alleles. This chunk is designed to calculate the proportion ('p.a') of an allele ('a') at a locus in each population ('p') and the proportion of individuals heterozygous for that allele ('h.a'). I'm not concerned with being slick in terms of using the most convenient functions, but would rather have it do the calculations as fast as possible as this bit is getting run very frequently and seems to be taking the most compute time. Profiling seems to indicate that functions like 'length(which(...))' and 'table(factor(...,level=a))' are more expensive than the logical vector creation scheme below. I just want to make sure I haven't overlooked any other viable options that might be available. Any and all suggestions are gladly welcomed. Thanks in advance. Cheers, eric --- Variables used : 'pop' - population i.d. , 'a1' & 'a2' - alleles 1 and 2 at locus : all character vectors of equal length (no NAs) nvec - vector of number of individuals in population 'p' a - allele for which 'p.a' and 'p.het.a' are being calculated Here's some example data and then the code snippet in question: test <- structure(list(pop = c("1", "1", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "3", "3", "3", "3", "3" ), loc4.a1 = c("3", "3", "4", "3", "3", "4", "4", "4", "3", "4", "4", "3", "4", "2", "4", "4", "4", "4", "2", "4", "2"), loc4.a2 = c("3", "3", "3", "3", "4", "3", "3", "3", "2", "3", "3", "3", "4", "2", "3", "4", "3", "4", "1", "3", "1")), .Names = c("pop", "loc4.a1", "loc4.a2"), na.action = structure(36, .Names = "36", class = "omit"), row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21"), class = "data.frame") pop <- test$pop a1 <- test$loc4.a1 a2 <- test$loc4.a2 nvec <- table(pop) a <- "3" with.a <- a1 == a | a2 == a allele.stats <- sapply(names(nvec), function(p) { this.pop <- pop == p & with.a a.in.a1 <- a1[this.pop] == a a.in.a2 <- a2[this.pop] == a na1 <- length(a.in.a1[a.in.a1]) na2 <- length(a.in.a2[a.in.a2]) p.a <- (na1 + na2) / nvec[p] / 2 is.het <- a1[this.pop] != a2[this.pop] p.het.a <- length(is.het[is.het]) / nvec[p] c(p.a, p.het.a) }) -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Vector searching and counting speed optimization
Richard, Thanks! I never would've thought of using sum() to count the TRUEs in a logical vector, but it makes perfect sense. Cheers, e. Richard M. Heiberger wrote: > sum() looks faster to me > > tmp <- as.logical(rbinom(100,1,.5)) > > >> system.time(for (i in 1:1) length(tmp[tmp])) >> > [1] 0.09 0.00 0.09 NA NA > >> system.time(for (i in 1:1) sum(tmp)) >> > [1] 0.03 0.00 0.03 NA NA > > I am running on Windows XP > > >> Sys.getenv()[20] >> > PROCESSOR_IDENTIFIER > "x86 Family 15 Model 2 Stepping 4, GenuineIntel" > > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] "Lighthouses are more helpful than churches." - Benjamin Franklin "Cogita tute" - Think for yourself __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] microarray-like graph
Hi, I am beginning to learn R and have a data table that I would like to produce a microarray-like plot. The table looks like this: 3 0 0 3 -377.61 1.94 3 0 0 3 -444.80 2.36 2 1 0 3 -519.60 2.39 1 1 1 3 -54.88 2.49 2 1 1 4 -536.55 2.53 1 0 1 2 108.29 2.62 2 0 0 2 39.56 2.62 3 0 1 4 108.32 2.63 2 0 0 2 -455.23 2.84 1 0 0 1 -432.30 2.98 ... I would like to assign colors to the first three columns and plot the last column against fourth column which is the sum of the first three at each row. Can anyone point to me how to approach this? Thanks for your suggestions. Regards, -Eric [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html