[R] error occurring in batch mode, not interactive mode: how to find cause of problem
Dear all, I use R version 2.15.1 on x86_64-pc-linux-gnu (64-bit). I run a simulation where I have to call a series of R scripts in batch mode. When I run the following two lines, this works well for PERIOD='17' but not for PERIOD='08': R CMD BATCH --no-save --args PERIOD='08' YEAR='203O' SC='BAU' preparecostvectors.R preparecostvectors08_2030.Rout R CMD BATCH --no-save --args PERIOD='17' YEAR='2030' SC='BAU' preparecostvectors.R preparecostvectors17_2030.Rout The error message I get for PERIOD='08' is (but I do not think this is relevant for my main question): Error in names(votlist) - votname : 'names' attribute [3] must be the same length as the vector [0] I get this error message for all values of YEAR. Oddly enough, when I run the script preparecostvectors.R interactively, all works perfectly fine. However, this is not a structural solution, because I need to be able to run my simulation for a large number of years. I was wondering if any tools exist that could help me to reconstruct what went wrong in batch mode. I think I am familiar with most debugging tools in interactive mode, but how can I trace the origin of the problem when I get an error in batch mode? Just to avoid any misunderstanding: I am not asking any help on the error message itself, just some suggestions on how I could trace what goes wrong when running R in batch mode. Laurent Franckx, PhD VITO NV Boeretang 200, 2400 MOL, Belgium Tel. + 32 14 33 58 22 Skype: laurent.franckx laurent.fran...@vito.be Visit our website: www.vito.be/english and http://www.vito.be/transport VITO Disclaimer: http://www.vito.be/e-maildisclaimer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gettext weirdness
The 'wierdness' is that 'R' is a domain of C messages and you are trying to use it from R. How messages are massaged before being sent for translation depends on the language, including how trailing spaces are handled. There is no reason to expect domains intended for C code to work in R-level gettext(), nor in stop() etc. This was really an R-devel question: see the posting guide. On Mon, 4 Feb 2013, Florent Angly wrote: Hi, I am trying to use the gettext() function to translate some text. I have never used this function before, so, it's entirely possible that I am doing something wrong. The issue that I am encountering is that gettext() properly translates some text, but not some other. Natural language was compiled in my R (installed from the Debian repositories): $ R R version 2.15.1 (2012-06-22) -- Roasted Marshmallows [...] Natural language support but running in an English locale [...] q() Here is some text that has some translation in the file ./po/fr.po: #: src/main/errors.c:290 msgid invalid option \warning.expression\ msgstr option incorrecte \warning.expression\ [...] #: src/main/errors.c:582 msgid Error in msgstr Erreur dans Start R in French and see if I can get something translated to French: $ LANG=fr_FR.UTF8 R stop('This is an error') Erreur : This is an error bindtextdomain(R) # does not seem necessary, but just to be safe... [1] /usr/share/R/share/locale gettext(Error in , domain=R) [1] Error in invalid option \warning.expression\ - msg; gettext(msg, domain=R) [1] option incorrecte \warning.expression\ So, the stop() function successfully translates. I can also manually translate some entries, but why can does it not work for gettext(Error in , domain=R)? Any idea? Thanks Florent __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RandomForest, Party and Memory Management
On Sun, 3 Feb 2013, Lorenzo Isella wrote: Dear All, For a data mining project, I am relying heavily on the RandomForest and Party packages. Due to the large size of the data set, I have often memory problems (in particular with the Party package; RandomForest seems to use less memory). I really have two questions at this point 1) Please see how I am using the Party and RandomForest packages. Any comment is welcome and useful. myparty - cforest(SalePrice ~ ModelID+ ProductGroup+ ProductGroupDesc+MfgYear+saledate3+saleday+ salemonth, data = trainRF, control = cforest_unbiased(mtry = 3, ntree=300, trace=TRUE)) rf_model - randomForest(SalePrice ~ ModelID+ ProductGroup+ ProductGroupDesc+MfgYear+saledate3+saleday+ salemonth, data = trainRF,na.action = na.omit, importance=TRUE, do.trace=100, mtry=3,ntree=300) 2) I have another question: sometimes R crashes after telling me that it is unable to allocate e.g. an array of 1.5 Gb. Do not use the word 'crash': see the posting guide. I suspect it gives you an error message. However, I have 4Gb of ram on my box, so...technically the memory is there, but is there a way to enable R to use more of it? Yes. I am surmising this is Windows but you have not told us so. See the rw-FAQ. The real answer is to run a 64-bit OS: your computer may have 4GB of RAM, but your OS has a 2GB address space which could be raised to 3GB. Many thanks Lorenzo -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Calculating Weights for Variable Groups
Hello and Thanks in advance for your suggestions. As a new member, I do not know exactly if such problem has ever been discussed in this forum. I need a small help using FactoMineR and RcmdrPlugin.FactoMineR package to calculate weights for the individual observational units. My data looks like: You can treat the data spaced instead of tabbed. (I_1_3)(I_1_4)(Weight_I_1)(I_2_1)(I_2_2)(I_2_3)(I_2_4)(I_2_5)(I_2_6)(I_2_7)(I_2_8)(Weight_I_2)20-3122-20-3122-30-22213342-30-22213342-30-3322-24-0211-24-0211-23-20013143-23-20013143-34-02013144-35-22213144-35-20013111-34-22213322-30-22111322- up to 55 observations and more variables, where the header are names of 12 variables in the data and each value is for corresponding variable while - is the required (to find) weights. I think I will get the idea if someone help with piece of code for one variable of the example data above above. I need to fill the columns of weights (now - but actually new variables) for the variables. Please note that I (may) need to use Multiple Correspondence Analysis (MCA), MFA, PCA etc but I dont know exactly. I would highly appreciate a code if possible from using the two packages above. I am sorry if this is not that clear. I can guess I will be pardoned being new old guy here. Thanks, Best Anees [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Wide character in print?
Note that this is a Perl message (nothing to do with R), as the message from gdata says pretty clearly. Ask the gdata maintainer (see our posting guide) or on a Perl forum. There are less restricted ways to read .xls files in R: XLConnect can read this file, for example. On Sun, 3 Feb 2013, Spencer Graves wrote: Hello: I get Wide character in print from trying read.xls(22_data.xls) in the gdata package, with 22_data.xls downloaded from Varieties_Country_A-E.xls at http://www.reinhartandrogoff.com/data/browse-by-topic/topics/7/: library(gdata) read.xls(22_data.xls) Wide character in print at C:/Users/sgraves/pgms/R/R-2.15.2/library/gdata/perl/xls2csv.pl line 270. sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] gdata_2.12.0 loaded via a namespace (and not attached): [1] gtools_2.7.0 I get the same message from xls2sep(22_data.xls). It's only a comment, so I suppose I could ignore it. However, it's generated by a function I'm adding to the Ecdat package, and I'd rather find a way to avoid it. (I suppose I could dump it to sink, but that's pretty extreme and could mask other problems.) Thanks, Spencer -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 plotting errorbars.
I have no problem specifying the mapping in both ggplot and various geom_* functions. However, it is important to specify data and mapping parameter names in the geom_* functions, particularly so because the parameter ordering is different there. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Rafael Robledo xid...@gmail.com wrote: Hi, it seems to be a problem about using aes both in ggplot as also in geom_bar. You could specify fill property for your geom_bar in ggplot initialization, in order to avoid this issue (you could also do the same thing for ymin and ymax properties for errorbar :P), i.e: dodge -position_dodge(width=0.9) ggplot(dfm, aes(x=X, y=value, fill=variable, ymin=value-er, ymax=value+er)) + geom_bar(position=dodge) + geom_errorbar(position=dodge, width=0.25) Hope it helps. On Sun, Feb 3, 2013 at 5:01 PM, Pieter Coussement dencous...@gmail.com wrote: Hi, i'm using this lines of code: dodge -position_dodge(width=0.9) ggplot(dfm,aes(x = X,y = value)) + geom_bar(aes(fill = variable), position=dodge, stat=identity) + geom_errorbar(aes(ymin=value-er, ymax=value+er),width=0.25, position=dodge,stat=identity) to plot this data frame X variable valueer 1 A X4 58.74 9.44 2 B X4 52.41 10.01 3 C X4 95.52 4.88 4 A X1 75.51 8.54 5 B X1 0.73 23.20 6 C X1 96.66 1.18 7 A X5 76.70 9.60 8 B X5 0.56 34.50 9 C X5 100.58 10.87 result: As you see the error bars are still very much wrongly positioned. How do i solve this? thanks for the help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Rafael R. On Sun, Feb 3, 2013 at 5:01 PM, Pieter Coussement dencous...@gmail.com wrote: Hi, i'm using this lines of code: dodge -position_dodge(width=0.9) ggplot(dfm,aes(x = X,y = value)) + geom_bar(aes(fill = variable), position=dodge, stat=identity) + geom_errorbar(aes(ymin=value-er, ymax=value+er),width=0.25, position=dodge,stat=identity) to plot this data frame X variable valueer 1 A X4 58.74 9.44 2 B X4 52.41 10.01 3 C X4 95.52 4.88 4 A X1 75.51 8.54 5 B X1 0.73 23.20 6 C X1 96.66 1.18 7 A X5 76.70 9.60 8 B X5 0.56 34.50 9 C X5 100.58 10.87 result: As you see the error bars are still very much wrongly positioned. How do i solve this? thanks for the help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Rafael R. On Sun, Feb 3, 2013 at 5:01 PM, Pieter Coussement dencous...@gmail.com wrote: Hi, i'm using this lines of code: dodge -position_dodge(width=0.9) ggplot(dfm,aes(x = X,y = value)) + geom_bar(aes(fill = variable), position=dodge, stat=identity) + geom_errorbar(aes(ymin=value-er, ymax=value+er),width=0.25, position=dodge,stat=identity) to plot this data frame X variable valueer 1 A X4 58.74 9.44 2 B X4 52.41 10.01 3 C X4 95.52 4.88 4 A X1 75.51 8.54 5 B X1 0.73 23.20 6 C X1 96.66 1.18 7 A X5 76.70 9.60 8 B X5 0.56 34.50 9 C X5 100.58 10.87 result: As you see the error bars are still very much wrongly positioned. How do i solve this? thanks for the help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Rafael R. On Sun, Feb 3, 2013 at 5:01 PM, Pieter Coussement dencous...@gmail.com wrote: Hi, i'm using this lines of code: dodge -position_dodge(width=0.9) ggplot(dfm,aes(x = X,y = value)) + geom_bar(aes(fill = variable), position=dodge, stat=identity) + geom_errorbar(aes(ymin=value-er, ymax=value+er),width=0.25, position=dodge,stat=identity) to plot this data frame X variable valueer 1 A X4 58.74 9.44 2 B X4 52.41 10.01 3 C
[R] Script for conditional sums of vectors
Hi guys, I hope you can help me with this (probably) simple query: I have a data frame: -- a=c(1,1,1,1,1,1,2,2,2,2,2,2) b=c(1,1,1,2,3,4,1,1,2,2,3,4) c=c(400,200,300,100,500,300,200,100,500,400,200,100) data=data.frame(a=a,b=b,c=c) -- And I would like to get the following output: -- b a 1 2 3 4 1 900 100 500 300 2 300 900 200 100 -- The values in the output represent the sum of values c in data frame data, for each a and b combination. For example, where a = 1 and b = 1, the output is 400+200+300 = 900. Please would anyone be able to provide a script to create my desired output? Many thanks in advance, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Script for conditional sums of vectors
Hi Ben, let me suggest some background reading - Peter Dalgaard's or Phil Spector's book will set you up with what you need. You can also read one of the many free, contributed sets of notes kept on CRAN. I hope that this helps Andrew On Mon, Feb 4, 2013 at 8:29 PM, Benjamin Gillespie gy...@leeds.ac.ukwrote: Hi guys, I hope you can help me with this (probably) simple query: I have a data frame: -- a=c(1,1,1,1,1,1,2,2,2,2,2,2) b=c(1,1,1,2,3,4,1,1,2,2,3,4) c=c(400,200,300,100,500,300,200,100,500,400,200,100) data=data.frame(a=a,b=b,c=c) -- And I would like to get the following output: -- b a 1 2 3 4 1 900 100 500 300 2 300 900 200 100 -- The values in the output represent the sum of values c in data frame data, for each a and b combination. For example, where a = 1 and b = 1, the output is 400+200+300 = 900. Please would anyone be able to provide a script to create my desired output? Many thanks in advance, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Director (A/g), ACERA Senior Lecturer in Applied Statistics Tel: +61-3-8344-6410 Department of Mathematics and StatisticsFax: +61-3-8344 4599 University of Melbourne, VIC 3010 Australia Email: a.robin...@ms.unimelb.edu.auWebsite: http://www.ms.unimelb.edu.au FAwR: http://www.ms.unimelb.edu.au/~andrewpr/FAwR/ SPuR: http://www.ms.unimelb.edu.au/spuRs/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Script for conditional sums of vectors
try this: a - c(1,1,1,1,1,1,2,2,2,2,2,2) b - c(1,1,1,2,3,4,1,1,2,2,3,4) c - c(400,200,300,100,500,300,200,100,500,400,200,100) DF - data.frame(a, b, c) with(DF, tapply(c, list(a, b), sum)) I hope it helps. Best, Dimitris On 2/4/2013 10:29 AM, Benjamin Gillespie wrote: Hi guys, I hope you can help me with this (probably) simple query: I have a data frame: -- a=c(1,1,1,1,1,1,2,2,2,2,2,2) b=c(1,1,1,2,3,4,1,1,2,2,3,4) c=c(400,200,300,100,500,300,200,100,500,400,200,100) data=data.frame(a=a,b=b,c=c) -- And I would like to get the following output: -- b a 1 2 3 4 1 900 100 500 300 2 300 900 200 100 -- The values in the output represent the sum of values c in data frame data, for each a and b combination. For example, where a = 1 and b = 1, the output is 400+200+300 = 900. Please would anyone be able to provide a script to create my desired output? Many thanks in advance, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshape help
Hi Robert, how about this? tmp-read.table(text=ID Dx Anausea Adiabetes Akidney_failure Aheart_attack Afever Bfever Bpneumonia Bheart_attack Bnausea Bcough Ckidney_failure Cnausea Cfoot_pain,header=T) data.frame(cbind(ID=levels(tmp$ID),(table(tmp$ID,tmp$Dx hth. Am 04.02.2013 09:16, schrieb Robert Strother: Dear R users - I have a list of patient identifiers and diagnoses from inpatient admissions. I would like to reorganize the list, presently in a long format to a wide format in reshape, but in the absence of a time element, I am uncertain how to do this - any help greatly appreciated. ID Dx Anausea Adiabetes Akidney failure Aheart attack Afever Bfever Bpneumonia Bheart attack Bnausea Bcough Ckidney failure Cnausea Cfoot pain I want this to be IDnausea diabetes kidney_failure heart_attack fever pneumonia A 11 1 1 1 0 B 00 0 1 1 1 R. Matthew Strother, MD Clinical Pharmacology Medical Oncology [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Script for conditional sums of vectors
Here are some examples of data aggregation functions in R: http://www.slideshare.net/djandrija/data-aggregation-in-r http://www.psychwire.co.uk/2011/04/data-aggregation-in-r-plyr-sqldf-and-data-table/ Andrija On Mon, Feb 4, 2013 at 10:29 AM, Benjamin Gillespie gy...@leeds.ac.ukwrote: Hi guys, I hope you can help me with this (probably) simple query: I have a data frame: -- a=c(1,1,1,1,1,1,2,2,2,2,2,2) b=c(1,1,1,2,3,4,1,1,2,2,3,4) c=c(400,200,300,100,500,300,200,100,500,400,200,100) data=data.frame(a=a,b=b,c=c) -- And I would like to get the following output: -- b a 1 2 3 4 1 900 100 500 300 2 300 900 200 100 -- The values in the output represent the sum of values c in data frame data, for each a and b combination. For example, where a = 1 and b = 1, the output is 400+200+300 = 900. Please would anyone be able to provide a script to create my desired output? Many thanks in advance, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Modifying a function programmatically
Dear list # I have a function ff - function(a,b=2,c=4){a+b+c} # which I programmatically want to modify to a more specialized function in which a is replaced by 1 ff1 - function(b=2,c=4){1+b+c} # I do as follows: vals - list(a=1) (expr1 - as.expression(body(ff))) expression({ a + b + c }) (expr2 - do.call(substitute, list(expr1[[1]], vals))) { 1 + b + c } # This works, eval(expr2, list(b=10,c=12)) [1] 23 # - but I would like a function. Hence I do: ll - alist(b=, c=, eval(expr2)) ff2 - as.function(ll) ff2(b=10,c=12) [1] 23 # BUT I am only half-way where I want to be because the alist(b=, c=, ...) # requires me plugin the remaining formals by hand. I do: newformals -setdiff(names(formals(ff)), names(vals)) vv - vector(list, length(newformals)) names(vv) - newformals (hh - c(vv, expr2)) $b NULL $c NULL [[3]] { 1 + b + c } (ff3 - as.function(hh)) function (b = NULL, c = NULL) { 1 + b + c } ff3(10,12) [1] 23 # Hence I get the function that returns what I want (given the correct input) # but the arguments will have default values that I don't want. # I want to retain the original default values (if any) ff1() [1] 7 ff3() numeric(0) I have two questions: 1) How to fix the above? 2) Aren't there more elegant alternatives? Any help would be appreciated. Regards Søren __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Script for conditional sums of vectors
Hello, First, don't use data for a data frame, as it is a R function. Here is a way to do what you are looking for: a=c(1,1,1,1,1,1,2,2,2,2,2,2) b=c(1,1,1,2,3,4,1,1,2,2,3,4) c=c(400,200,300,100,500,300,200,100,500,400,200,100) dat=data.frame(a=a,b=b,c=c) dat.sum - aggregate(c ~ a+b, dat, sum) dat.sum - reshape(dat.sum, timevar='b', idvar='a', direction='wide') colnames(dat.sum) - c('a','b.1','b.2','b.3','b.4') HTH, Pascal Le 04/02/2013 18:29, Benjamin Gillespie a écrit : Hi guys, I hope you can help me with this (probably) simple query: I have a data frame: -- a=c(1,1,1,1,1,1,2,2,2,2,2,2) b=c(1,1,1,2,3,4,1,1,2,2,3,4) c=c(400,200,300,100,500,300,200,100,500,400,200,100) data=data.frame(a=a,b=b,c=c) -- And I would like to get the following output: -- b a 1 2 3 4 1 900 100 500 300 2 300 900 200 100 -- The values in the output represent the sum of values c in data frame data, for each a and b combination. For example, where a = 1 and b = 1, the output is 400+200+300 = 900. Please would anyone be able to provide a script to create my desired output? Many thanks in advance, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Modifying a function programmatically
Hi, Is it what you are looking for? ff - function(a,b,c){a+b+c} ff(1,10,12) [1] 23 ff(589,2,4) [1] 595 HTH, Pascal Le 04/02/2013 19:00, Søren Højsgaard a écrit : Dear list # I have a function ff - function(a,b=2,c=4){a+b+c} # which I programmatically want to modify to a more specialized function in which a is replaced by 1 ff1 - function(b=2,c=4){1+b+c} # I do as follows: vals - list(a=1) (expr1 - as.expression(body(ff))) expression({ a + b + c }) (expr2 - do.call(substitute, list(expr1[[1]], vals))) { 1 + b + c } # This works, eval(expr2, list(b=10,c=12)) [1] 23 # - but I would like a function. Hence I do: ll - alist(b=, c=, eval(expr2)) ff2 - as.function(ll) ff2(b=10,c=12) [1] 23 # BUT I am only half-way where I want to be because the alist(b=, c=, ...) # requires me plugin the remaining formals by hand. I do: newformals -setdiff(names(formals(ff)), names(vals)) vv - vector(list, length(newformals)) names(vv) - newformals (hh - c(vv, expr2)) $b NULL $c NULL [[3]] { 1 + b + c } (ff3 - as.function(hh)) function (b = NULL, c = NULL) { 1 + b + c } ff3(10,12) [1] 23 # Hence I get the function that returns what I want (given the correct input) # but the arguments will have default values that I don't want. # I want to retain the original default values (if any) ff1() [1] 7 ff3() numeric(0) I have two questions: 1) How to fix the above? 2) Aren't there more elegant alternatives? Any help would be appreciated. Regards Søren __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Script for conditional sums of vectors
Thanks everyone - this seems to be the most efficient answer, I'll do a bit of reading around too as suggested. Thanks again, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT From: D. Rizopoulos [d.rizopou...@erasmusmc.nl] Sent: 04 February 2013 09:35 To: Benjamin Gillespie Cc: r-help@r-project.org Subject: Re: [R] Script for conditional sums of vectors try this: a - c(1,1,1,1,1,1,2,2,2,2,2,2) b - c(1,1,1,2,3,4,1,1,2,2,3,4) c - c(400,200,300,100,500,300,200,100,500,400,200,100) DF - data.frame(a, b, c) with(DF, tapply(c, list(a, b), sum)) I hope it helps. Best, Dimitris On 2/4/2013 10:29 AM, Benjamin Gillespie wrote: Hi guys, I hope you can help me with this (probably) simple query: I have a data frame: -- a=c(1,1,1,1,1,1,2,2,2,2,2,2) b=c(1,1,1,2,3,4,1,1,2,2,3,4) c=c(400,200,300,100,500,300,200,100,500,400,200,100) data=data.frame(a=a,b=b,c=c) -- And I would like to get the following output: -- b a 1 2 3 4 1 900 100 500 300 2 300 900 200 100 -- The values in the output represent the sum of values c in data frame data, for each a and b combination. For example, where a = 1 and b = 1, the output is 400+200+300 = 900. Please would anyone be able to provide a script to create my desired output? Many thanks in advance, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Modifying a function programmatically
No, this is not really what I want. But I have (later) realized that what I am looking for can be achieved as shown below. I am just not sure how bullet-proof the solution is. Suggestions are welcome! Regards Søren -- specialize - function(ff, vals){ expr1 - as.expression(body(ff)) expr2 - do.call(substitute, list(expr1[[1]], vals)) gg - formals(ff) idx -match(names(vals), names(gg)) gg - gg[-idx] as.function(c(gg, expr2)) } ff - function(a,b=2,c=4){a+b+c} (ans-specialize(ff, list(a=1))) function (b = 2, c = 4) { 1 + b + c } environment: 0x08b51c68 ans() [1] 7 ans(b=10) [1] 15 (ans-specialize(rnorm, list(n=10))) function (mean = 0, sd = 1) .Internal(rnorm(10, mean, sd)) environment: 0x08b5a0b8 ans() [1] 0.1783645319 2.1151344735 -0.6744270178 0.0009751497 -0.1477708270 0.1710790055 [7] -0.0064331250 0.5935787352 -0.1426050990 -0.1390478788 ans(sd=.0001) [1] 1.386604e-06 -6.616540e-05 6.592326e-05 -1.299638e-04 1.322658e-05 -4.515388e-05 [7] -2.809639e-05 -5.719492e-05 1.554319e-04 -1.186992e-04 -Original Message- From: Pascal Oettli [mailto:kri...@ymail.com] Sent: 4. februar 2013 11:11 To: Søren Højsgaard Cc: r-help@r-project.org Subject: Re: [R] Modifying a function programmatically Hi, Is it what you are looking for? ff - function(a,b,c){a+b+c} ff(1,10,12) [1] 23 ff(589,2,4) [1] 595 HTH, Pascal Le 04/02/2013 19:00, Søren Højsgaard a écrit : Dear list # I have a function ff - function(a,b=2,c=4){a+b+c} # which I programmatically want to modify to a more specialized function in which a is replaced by 1 ff1 - function(b=2,c=4){1+b+c} # I do as follows: vals - list(a=1) (expr1 - as.expression(body(ff))) expression({ a + b + c }) (expr2 - do.call(substitute, list(expr1[[1]], vals))) { 1 + b + c } # This works, eval(expr2, list(b=10,c=12)) [1] 23 # - but I would like a function. Hence I do: ll - alist(b=, c=, eval(expr2)) ff2 - as.function(ll) ff2(b=10,c=12) [1] 23 # BUT I am only half-way where I want to be because the alist(b=, c=, ...) # requires me plugin the remaining formals by hand. I do: newformals -setdiff(names(formals(ff)), names(vals)) vv - vector(list, length(newformals)) names(vv) - newformals (hh - c(vv, expr2)) $b NULL $c NULL [[3]] { 1 + b + c } (ff3 - as.function(hh)) function (b = NULL, c = NULL) { 1 + b + c } ff3(10,12) [1] 23 # Hence I get the function that returns what I want (given the correct input) # but the arguments will have default values that I don't want. # I want to retain the original default values (if any) ff1() [1] 7 ff3() numeric(0) I have two questions: 1) How to fix the above? 2) Aren't there more elegant alternatives? Any help would be appreciated. Regards Søren __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Script for conditional sums of vectors
Hello, In what follows, I've renamed the data.frame 'dat', 'data' already is an R function. xtabs(c ~ a + b, data = dat) Hope this helps, Rui Barradas Em 04-02-2013 09:29, Benjamin Gillespie escreveu: Hi guys, I hope you can help me with this (probably) simple query: I have a data frame: -- a=c(1,1,1,1,1,1,2,2,2,2,2,2) b=c(1,1,1,2,3,4,1,1,2,2,3,4) c=c(400,200,300,100,500,300,200,100,500,400,200,100) data=data.frame(a=a,b=b,c=c) -- And I would like to get the following output: -- b a 1 2 3 4 1 900 100 500 300 2 300 900 200 100 -- The values in the output represent the sum of values c in data frame data, for each a and b combination. For example, where a = 1 and b = 1, the output is 400+200+300 = 900. Please would anyone be able to provide a script to create my desired output? Many thanks in advance, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot and colors
Hello, I have a problem with ggplot and colors I used this function to draw somes lines and I want them to be all black (just to test) however, I dont get any black line in the figure. Do you have any experience with ggplot and manual colors?? ggplot(cmax, aes(cmax[,3], cmax[,6],colour=interaction(cmax[,1],cmax[,2]))) + geom_line() + geom_point() + scale_fill_manual(values=c(black, black , black, black, black, black, black, black, black, black, black, black )) best regards -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 attachment: test.png__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] useR! 2013 Call for Abstracts
We are happy to inform you that abstract submission for useR! 2013 is now available online, see http://www.R-project.org/useR-2013 This meeting of the R user community will take place at the University of Castilla-La Mancha, Albacete, Spain, July 10-12, 2013. Pre-conference tutorials will be offered on July 9. A list of tutorials is available at http://www.r-project.org/useR-2013/Tutorials/ Participants are encouraged to submit a one-page abstract for oral or poster presentation at the conference. Contributed oral presentations will be allowed 17 minutes, followed by 3 minutes discussion. Following previous conferences, all participants are invited to present a Lightning Talk, for which no abstract is required. The format for Lightning Talks is a 15-slide version of Pecha Kucha. Participants wishing to give a Lightning Talk must provide an informative title on their registration form. Registration will open shortly. For regular talks and posters, please use the recently updated LaTeX or Microsoft Word/LibreOffice Writer abstract templates available at the conference website: http://www.r-project.org/useR-2013#Call The deadline for abstract submission is March 31. The preferred method of abstract and tutorial proposal submission is via the web form at the conference website: http://www.r-project.org/useR-2013/submission.html We look forward to seeing you at useR! 2013 in Albacete! -- Virgilio Gómez Rubio, on behalf of the useR! 2013 local organizing committee Departamento de Matemáticas Escuela de Ingenieros Industriales de Albacete Universidad de Castilla-La Mancha Avda. España s/n 02071 Albacete - SPAIN Tel: 967 59 92 00 ext. 8250 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] x-axis labelling
Hi Dave, Thanks for your reply. I can't reproduce the last line of code your code. The ifelse argument throws back an error saying it was not used. A On Fri, Feb 1, 2013 at 10:56 PM, David Winsemius dwinsem...@comcast.netwrote: On Feb 1, 2013, at 9:30 AM, Alfredo Tello wrote: Hi Folks! I have a question regarding an issue on which I´ve read a few threads but can´t resolve -- Labelling every other tick mark on the x-axis using factors. Here´s an example: Why not: db-data.frame(date=as.factor(**c(1:50)),var=rnorm(50)) barplot(db$var,names.arg=**ifelse( rep( c(TRUE,FALSE), length=length(levels(db$date) ) ), levels(db$date), ),las=2,cex.axis=0.8,cex=0.**8) barplot(db$var,names.arg=**ifelse( c(TRUE,FALSE), levels(db$date), },las=2,cex.axis=0.8,cex=0.**8) -- David. This labels all the tickmarks in my barplot, which is the default behavior. I would like to label every other tick mark in the barplot -- 1,3,5,7 and so on. Thank you very much for your help! All the best, A -- Alfredo Tello (http://alfredotello.com) Sustainable Aquaculture Group Institute of Aquaculture University of Stirling Scotland, UK. [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Alameda, CA, USA -- Alfredo Tello (http://alfredotello.com) Sustainable Aquaculture Group Institute of Aquaculture University of Stirling Scotland, UK. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rJava works with 32-bit but not 64
On Feb 4, 2013, at 6:33 AM, Spencer Graves wrote: On 2/3/2013 11:21 PM, Pascal Oettli wrote: Hello, Do you have a 64-bit version of Java? rJava says to you: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) I think I probably have a 32-bit version and not a 64-bit, because it works with 32-bit R but not 64-bit R. Is it feasible to have both installed in a way that allows the each version of R to select its own version of Java? Yes, that is the default. 32-bit R will only see 32-bit Java and vice versa, because Windows separates 32-bit and 64-bit registries. A comment on stackoverflow suggests that may not be easy (http://stackoverflow.com/questions/5272216/is-it-possible-to-install-both-32bit-and-64bit-java-on-windows-7). Ehm, it says Yes, it is absolutely no problem. -- which part of it suggests it's not easy? SO is a good source of rumors, seldom facts -- but in this case it's not too far from the truth. Cheers, Simon Thanks, Spencer Regards, Pascal Le 04/02/2013 14:27, Spencer Graves a écrit : Hello: rJava works for me under 32-bit but under not 64-bit R; see below. Suggestions? Thanks, Spencer library(rJava) Error : .onLoad failed in loadNamespace() for 'rJava', details: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) error: object 'key' not found Error: package/namespace load failed for 'rJava' sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base ## library(rJava) sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rJava_0.9-3 -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot and colors
Hi, fill is not the same as color. You need scale_color_manual(values=c(black, black , black, black, black, black, black, black, black, black, black, black )) although it is not clear why you are using aesthetic mapping to set everything to black... Best, Ista On Mon, Feb 4, 2013 at 6:17 AM, Adel ESSAFI adeless...@gmail.com wrote: Hello, I have a problem with ggplot and colors I used this function to draw somes lines and I want them to be all black (just to test) however, I dont get any black line in the figure. Do you have any experience with ggplot and manual colors?? ggplot(cmax, aes(cmax[,3], cmax[,6],colour=interaction(cmax[,1],cmax[,2]))) + geom_line() + geom_point() + scale_fill_manual(values=c(black, black , black, black, black, black, black, black, black, black, black, black )) best regards -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Meaning of .noemail extension for CRAN uploads?
Hi all! I've uploaded two packages to CRAN via FTP [1] about a week ago, and while one was promptly processed by Brian Ripley (thanks for that!), the second got the .noemail extension added, and nothing else happened. So I wonder whether CRAN maintainers are waiting for some action on my side or whether I should just wait without worrying. (Of course, I did send a manual e-mail stating I accept CRAN policies -- I even sent it twice.) I'm aware that CRAN policies [2] state: Part of the processing is that uploads may be renamed by adding one of the extensions .save, .pending or .noemail: the presence of such a file is a sign that a submission is still pending (and such a file name should never be uploaded). But this does not give me the meaning of this intriguing .noemail extension. :-) I guess this message can also be useful for people looking for this in the future, since currently Web searches do not return anything interesting for CRAN .noemail. Thanks! 1: ftp://cran.r-project.org/incoming 2: http://cran.r-project.org/web/packages/policies.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rJava works with 32-bit but not 64
Le lundi 04 février 2013 à 08:19 -0400, Simon Urbanek a écrit : On Feb 4, 2013, at 6:33 AM, Spencer Graves wrote: On 2/3/2013 11:21 PM, Pascal Oettli wrote: Hello, Do you have a 64-bit version of Java? rJava says to you: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) Simon, have you noticed there seem to be a bug in rJava about the missing 'key' variable? The error message would be (slightly) cleaner if the stop() call succeeded, wouldn't it? ;-) Thanks for your work I think I probably have a 32-bit version and not a 64-bit, because it works with 32-bit R but not 64-bit R. Is it feasible to have both installed in a way that allows the each version of R to select its own version of Java? Yes, that is the default. 32-bit R will only see 32-bit Java and vice versa, because Windows separates 32-bit and 64-bit registries. A comment on stackoverflow suggests that may not be easy (http://stackoverflow.com/questions/5272216/is-it-possible-to-install-both-32bit-and-64bit-java-on-windows-7). Ehm, it says Yes, it is absolutely no problem. -- which part of it suggests it's not easy? SO is a good source of rumors, seldom facts -- but in this case it's not too far from the truth. Cheers, Simon Thanks, Spencer Regards, Pascal Le 04/02/2013 14:27, Spencer Graves a écrit : Hello: rJava works for me under 32-bit but under not 64-bit R; see below. Suggestions? Thanks, Spencer library(rJava) Error : .onLoad failed in loadNamespace() for 'rJava', details: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) error: object 'key' not found Error: package/namespace load failed for 'rJava' sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base ## library(rJava) sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rJava_0.9-3 -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rJava works with 32-bit but not 64
On 2/3/2013 11:21 PM, Pascal Oettli wrote: Hello, Do you have a 64-bit version of Java? rJava says to you: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) I think I probably have a 32-bit version and not a 64-bit, because it works with 32-bit R but not 64-bit R. Is it feasible to have both installed in a way that allows the each version of R to select its own version of Java? A comment on stackoverflow suggests that may not be easy (http://stackoverflow.com/questions/5272216/is-it-possible-to-install-both-32bit-and-64bit-java-on-windows-7). Thanks, Spencer Regards, Pascal Le 04/02/2013 14:27, Spencer Graves a écrit : Hello: rJava works for me under 32-bit but under not 64-bit R; see below. Suggestions? Thanks, Spencer library(rJava) Error : .onLoad failed in loadNamespace() for 'rJava', details: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) error: object 'key' not found Error: package/namespace load failed for 'rJava' sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base ## library(rJava) sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rJava_0.9-3 -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RandomForest, Party and Memory Management
Dear Dennis and dear All, It was probably not my best post. I am running R on a Debian box (amd64 architecture) and that is why I was surprised to see memory issues when dealing with a vector larger than 1Gb. The memory is there, but probably it is not contiguous. I will investigate into the matter and post again (generating an artificial dataframe if needed). Many thanks Lorenzo On 4 February 2013 00:50, Dennis Murphy djmu...@gmail.com wrote: Hi Lorenzo: On Sun, Feb 3, 2013 at 11:47 AM, Lorenzo Isella lorenzo.ise...@gmail.com wrote: Dear All, For a data mining project, I am relying heavily on the RandomForest and Party packages. Due to the large size of the data set, I have often memory problems (in particular with the Party package; RandomForest seems to use less memory). I really have two questions at this point 1) Please see how I am using the Party and RandomForest packages. Any comment is welcome and useful. As noted elsewhere, the example is not reproducible so I can't help you there. myparty - cforest(SalePrice ~ ModelID+ ProductGroup+ ProductGroupDesc+MfgYear+saledate3+saleday+ salemonth, data = trainRF, control = cforest_unbiased(mtry = 3, ntree=300, trace=TRUE)) rf_model - randomForest(SalePrice ~ ModelID+ ProductGroup+ ProductGroupDesc+MfgYear+saledate3+saleday+ salemonth, data = trainRF,na.action = na.omit, importance=TRUE, do.trace=100, mtry=3,ntree=300) 2) I have another question: sometimes R crashes after telling me that it is unable to allocate e.g. an array of 1.5 Gb. However, I have 4Gb of ram on my box, so...technically the memory is there, but is there a way to enable R to use more of it? 4Gb is not a lot of RAM for data mining projects. I have twice that and run into memory limits on some fairly simple tasks (e.g., 2D tables) in large simulations with 1M or 10M runs. Part of the problem is that data is often copied, sometimes more than once. If you have a 1Gb input data frame, three copies and you're out of space. Moreover, copied objects need contiguous memory, and this becomes very difficult to achieve with large objects and limited RAM. With 4Gb RAM, you need to be more clever: * eliminate as many other processes that access RAM as possible (e.g., no active browser) * think of ways to process your data in chunks (which is harder to do when the objective is model fitting) * type ?Memory-limits (including the quotes) at the console for explanations about memory limits and a few places to look for potential solutions * look into 'big data' packages like ff or bigmemory, among others * if you're in an (American ?) academic institution, you can get a free license for Revolution R, which is supposed to be better for big data problems than vanilla R It's hard to be specific about potential solutions, but the above should broaden your perspective on the big data problem and possible avenues for solving it. Dennis Many thanks Lorenzo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rJava works with 32-bit but not 64
On 2/4/2013 5:22 AM, Milan Bouchet-Valat wrote: Le lundi 04 février 2013 à 08:19 -0400, Simon Urbanek a écrit : On Feb 4, 2013, at 6:33 AM, Spencer Graves wrote: On 2/3/2013 11:21 PM, Pascal Oettli wrote: Hello, Do you have a 64-bit version of Java? rJava says to you: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) Simon, have you noticed there seem to be a bug in rJava about the missing 'key' variable? The error message would be (slightly) cleaner if the stop() call succeeded, wouldn't it? ;-) A subtle bug which only appears with the 64-bit but not the 32-bit version ... ? I agree: Thanks very much for your work. Spencer Thanks for your work I think I probably have a 32-bit version and not a 64-bit, because it works with 32-bit R but not 64-bit R. Is it feasible to have both installed in a way that allows the each version of R to select its own version of Java? Yes, that is the default. 32-bit R will only see 32-bit Java and vice versa, because Windows separates 32-bit and 64-bit registries. A comment on stackoverflow suggests that may not be easy (http://stackoverflow.com/questions/5272216/is-it-possible-to-install-both-32bit-and-64bit-java-on-windows-7). Ehm, it says Yes, it is absolutely no problem. -- which part of it suggests it's not easy? SO is a good source of rumors, seldom facts -- but in this case it's not too far from the truth. Cheers, Simon Thanks, Spencer Regards, Pascal Le 04/02/2013 14:27, Spencer Graves a écrit : Hello: rJava works for me under 32-bit but under not 64-bit R; see below. Suggestions? Thanks, Spencer library(rJava) Error : .onLoad failed in loadNamespace() for 'rJava', details: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) error: object 'key' not found Error: package/namespace load failed for 'rJava' sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base ## library(rJava) sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rJava_0.9-3 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Looping through rows of all elements of a list that has variable length
Just modified your code a bit, hope this helps: a=expand.grid(1:2,1:2) b=expand.grid(1:2,1:2,1:2) c=expand.grid(1:2,1:2,1:2,1:2) l.long-list(a,b,c) mygrid-do.call(expand.grid,lapply(l.long,function(x) 1:nrow(x))) out-vector(list,nrow(mygrid)) for(gridrow in 1:nrow(mygrid)) { sum_rows=0 for (i in seq_along(mygrid)) { myrow-mygrid[gridrow,i] sum_rows=sum_rows+sum(l.long[[i]][myrow,]) } out[[gridrow]]=sum_rows } Pratap --- On Sun, 3/2/13, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: From: Dimitri Liakhovitski dimitri.liakhovit...@gmail.com Subject: [R] Looping through rows of all elements of a list that has variable length To: r-help r-help@r-project.org Date: Sunday, 3 February, 2013, 11:03 PM Dear R-ers, I have a list of data frames such that the length of the list is unknown in advance (it could be 1 or 2 or more). Each element of the list contains a data frame. I need to loop through all rows of the list element 1 AND (if applicable) of the list element 2 etc. and do something at each iteration. I am trying to figure out how to write a code that is generic, i.e., loops through the rows of all elements of my lists even if the total number of the list elments is unknown in advance. Below is an example. a=expand.grid(1:2,1:2) b=expand.grid(1:2,1:2,1:2) # # My list that can have 1 element, e.g.: l.short-vector(list,1) l.short[[1]]-a # I need to loop through rows of l.short[[1]] and do somethinig (it's unimportant what exactly) with them, e.g.: out-vector(list,nrow(l.short[[1]])) for(i in 1:nrow(l.short[[1]])){ # i-1 out[[i]]-sum(l.short[[1]][i,]) } (out) # # Or my list could have 1 elements, e.g., 2 like below (or 3 or more). # The total length of my list varies. l.long-list(a,b) # I need to loop through rows of l.long[[1]] AND of l.long[[2]] simultaneously # and do something with both, - see example below. # Below, I am doing it manually by using expand.grid to create all combinations of rows of 2 elements of 'l.long': mygrid-expand.grid(1:nrow(l.long[[1]]),1:nrow(l.long[[2]])) out-vector(list,nrow(mygrid)) for(gridrow in 1:nrow(mygrid)){ # gridrow-1 row.a-mygrid[gridrow,1] row.b-mygrid[gridrow,2] out[[gridrow]]-sum(l.long[[1]][row.a,])+sum(l.long[[2]][row.b,]) } [[elided Yahoo spam]] -- Dimitri Liakhovitski gfk.com http://marketfusionanalytics.com/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Looping through rows of all elements of a list that has variable length
Thanks a lot, Pratap! Dimitri On Mon, Feb 4, 2013 at 9:43 AM, nalluri pratap pratap_s...@yahoo.co.inwrote: Just modified your code a bit, hope this helps: a=expand.grid(1:2,1:2) b=expand.grid(1:2,1:2,1:2) c=expand.grid(1:2,1:2,1:2,1:2) l.long-list(a,b,c) mygrid-do.call(expand.grid,lapply(l.long,function(x) 1:nrow(x))) out-vector(list,nrow(mygrid)) for(gridrow in 1:nrow(mygrid)) { sum_rows=0 for (i in seq_along(mygrid)) { myrow-mygrid[gridrow,i] sum_rows=sum_rows+sum(l.long[[i]][myrow,]) } out[[gridrow]]=sum_rows } Pratap --- On *Sun, 3/2/13, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com * wrote: From: Dimitri Liakhovitski dimitri.liakhovit...@gmail.com Subject: [R] Looping through rows of all elements of a list that has variable length To: r-help r-help@r-project.org Date: Sunday, 3 February, 2013, 11:03 PM Dear R-ers, I have a list of data frames such that the length of the list is unknown in advance (it could be 1 or 2 or more). Each element of the list contains a data frame. I need to loop through all rows of the list element 1 AND (if applicable) of the list element 2 etc. and do something at each iteration. I am trying to figure out how to write a code that is generic, i.e., loops through the rows of all elements of my lists even if the total number of the list elments is unknown in advance. Below is an example. a=expand.grid(1:2,1:2) b=expand.grid(1:2,1:2,1:2) # # My list that can have 1 element, e.g.: l.short-vector(list,1) l.short[[1]]-a # I need to loop through rows of l.short[[1]] and do somethinig (it's unimportant what exactly) with them, e.g.: out-vector(list,nrow(l.short[[1]])) for(i in 1:nrow(l.short[[1]])){ # i-1 out[[i]]-sum(l.short[[1]][i,]) } (out) # # Or my list could have 1 elements, e.g., 2 like below (or 3 or more). # The total length of my list varies. l.long-list(a,b) # I need to loop through rows of l.long[[1]] AND of l.long[[2]] simultaneously # and do something with both, - see example below. # Below, I am doing it manually by using expand.grid to create all combinations of rows of 2 elements of 'l.long': mygrid-expand.grid(1:nrow(l.long[[1]]),1:nrow(l.long[[2]])) out-vector(list,nrow(mygrid)) for(gridrow in 1:nrow(mygrid)){ # gridrow-1 row.a-mygrid[gridrow,1] row.b-mygrid[gridrow,2] out[[gridrow]]-sum(l.long[[1]][row.a,])+sum(l.long[[2]][row.b,]) } Thank you very much for any suggestions! -- Dimitri Liakhovitski gfk.com http://marketfusionanalytics.com/ [[alternative HTML version deleted]] __ R-help@r-project.orghttp://in.mc1909.mail.yahoo.com/mc/compose?to=R-help@r-project.orgmailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitri Liakhovitski gfk.com http://marketfusionanalytics.com/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rJava works with 32-bit but not 64
On Feb 4, 2013, at 10:27 AM, Spencer Graves wrote: On 2/4/2013 5:22 AM, Milan Bouchet-Valat wrote: Le lundi 04 février 2013 à 08:19 -0400, Simon Urbanek a écrit : On Feb 4, 2013, at 6:33 AM, Spencer Graves wrote: On 2/3/2013 11:21 PM, Pascal Oettli wrote: Hello, Do you have a 64-bit version of Java? rJava says to you: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) Simon, have you noticed there seem to be a bug in rJava about the missing 'key' variable? The error message would be (slightly) cleaner if the stop() call succeeded, wouldn't it? ;-) A subtle bug which only appears with the 64-bit but not the 32-bit version ... ? Just a subtle bug in the error message if there is no Java installed (has nothing to do with the architecture). Now fixed. Cheers, Simon I agree: Thanks very much for your work. Spencer Thanks for your work I think I probably have a 32-bit version and not a 64-bit, because it works with 32-bit R but not 64-bit R. Is it feasible to have both installed in a way that allows the each version of R to select its own version of Java? Yes, that is the default. 32-bit R will only see 32-bit Java and vice versa, because Windows separates 32-bit and 64-bit registries. A comment on stackoverflow suggests that may not be easy (http://stackoverflow.com/questions/5272216/is-it-possible-to-install-both-32bit-and-64bit-java-on-windows-7). Ehm, it says Yes, it is absolutely no problem. -- which part of it suggests it's not easy? SO is a good source of rumors, seldom facts -- but in this case it's not too far from the truth. Cheers, Simon Thanks, Spencer Regards, Pascal Le 04/02/2013 14:27, Spencer Graves a écrit : Hello: rJava works for me under 32-bit but under not 64-bit R; see below. Suggestions? Thanks, Spencer library(rJava) Error : .onLoad failed in loadNamespace() for 'rJava', details: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) error: object 'key' not found Error: package/namespace load failed for 'rJava' sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base ## library(rJava) sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rJava_0.9-3 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem loading hdf5 file
*Hi everyone, I am a new subscriber, so I hope I'm posting in the right way. I need to load a hdf5 file, so I installed the hdf5 libraries ad the hdf5 R package; in downloaded a small sample file from the hdf5 website and I could correctly load it. But when I try to load my file: * require(hdf5) rm(list=ls()) ls() hdf5load(my_file.h5, verbosity=3) *I get this error message: * Errore in hdf5load(my_file.h5, verbosity = 1) : unable to open HDF file: my_file.h5 HDF5-DIAG: Error detected in HDF5 (1.8.4-patch1) thread 0: #000: /Builds/unix/hdf5-1.8.4-patch1/src/H5F.c line 1514 in H5Fopen(): unable to open file major: File accessability minor: Unable to open file #001: /Builds/unix/hdf5-1.8.4-patch1/src/H5F.c line 1218 in H5F_open(): unable to open file major: File accessability minor: Unable to open file #002: /Builds/unix/hdf5-1.8.4-patch1/src/H5FD.c line 1079 in H5FD_open(): open failed major: Virtual File Layer minor: Unable to initialize object #003: /Builds/unix/hdf5-1.8.4-patch1/src/H5FDsec2.c line 365 in H5FD_sec2_open(): unable to open file major: File accessability minor: Unable to open file #004: /Builds/unix/hdf5-1.8.4-patch1/src/H5FDsec2.c line 365 in H5FD_sec2_open(): No such file or directory major: Internal error (too specific to document in detail) minor: System error message *I really can't see the problem. I get the same error both with OSX and Ubuntu; could it simply be that the file is too large? In that case, what could I try to do? Thanks in advance,* * * *Flavio* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] What methods you use for choosing attributes for kmeans and other clustering (unsupervised) methods?
What characteristics makes attribute great for kmeans clustering and how do you measure these characteristics? Do you look at the distribution shape, correlation matrix between attributes, pairs graphs, statistical tests...? -- View this message in context: http://r.789695.n4.nabble.com/What-methods-you-use-for-choosing-attributes-for-kmeans-and-other-clustering-unsupervised-methods-tp4657464.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshape help
Hi, Try this: library(reshape2) dat1-read.table(text=ID Dx A nausea A diabetes A kidney_failure A heart_attack A fever B fever B pneumonia B heart_attack B nausea B cough C kidney_failure C nausea C foot_pain,header=T,stringsAsFactors=F,sep=) dcast(dat1,ID~Dx,length,value.var=Dx) # ID cough diabetes fever foot_pain heart_attack kidney_failure nausea #1 A 0 1 1 0 1 1 1 #2 B 1 0 1 0 1 0 1 #3 C 0 0 0 1 0 1 1 #pneumonia #1 0 #2 1 #3 0 A.K. - Original Message - From: Robert Strother rstro...@gmail.com To: r-help@r-project.org Cc: Sent: Monday, February 4, 2013 3:16 AM Subject: [R] reshape help Dear R users - I have a list of patient identifiers and diagnoses from inpatient admissions. I would like to reorganize the list, presently in a long format to a wide format in reshape, but in the absence of a time element, I am uncertain how to do this - any help greatly appreciated. ID Dx A nausea A diabetes A kidney failure A heart attack A fever B fever B pneumonia B heart attack B nausea B cough C kidney failure C nausea C foot pain I want this to be ID nausea diabetes kidney_failure heart_attack fever pneumonia A 1 1 1 1 1 0 B 0 0 0 1 1 1 R. Matthew Strother, MD Clinical Pharmacology Medical Oncology [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Script for conditional sums of vectors
Hi, library(reshape2) dcast(DF,a~b,value.var=c,sum) # a 1 2 3 4 #1 1 900 100 500 300 #2 2 300 900 200 100 A.K. - Original Message - From: Benjamin Gillespie gy...@leeds.ac.uk To: r-help@r-project.org r-help@r-project.org Cc: Sent: Monday, February 4, 2013 4:29 AM Subject: [R] Script for conditional sums of vectors Hi guys, I hope you can help me with this (probably) simple query: I have a data frame: -- a=c(1,1,1,1,1,1,2,2,2,2,2,2) b=c(1,1,1,2,3,4,1,1,2,2,3,4) c=c(400,200,300,100,500,300,200,100,500,400,200,100) data=data.frame(a=a,b=b,c=c) -- And I would like to get the following output: -- b a 1 2 3 4 1 900 100 500 300 2 300 900 200 100 -- The values in the output represent the sum of values c in data frame data, for each a and b combination. For example, where a = 1 and b = 1, the output is 400+200+300 = 900. Please would anyone be able to provide a script to create my desired output? Many thanks in advance, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rprof causing R to crash
Am also having trouble with Rprof. I am using on R 2.15.2 on the Mac (Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)). The example above without profiling takes around a minute to run: z = 1 for (i in 1:1e8) z = z+1/i z [1] 19.9979 With profiling: Rprof() z = 1 for (i in 1:1e8) z = z+1/i [INFO] Feb 4, 2013 12:45:20 PM - R stopped. Crashes within a second or so. This is consistent with the problem I'm having in my own code in which there is a reasonable amount of memory used (but not a massive amount). Any help much appreciated. Am happy to post this as a bug if that is now appropriate. regards Steven -- View this message in context: http://r.789695.n4.nabble.com/Rprof-causing-R-to-crash-tp4652846p4657482.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Exponentiate very large numbers
Dear R experts, I have the logarithms of 2 values: log(a) = 1347 log(b) = 1351 And I am trying to solve this expression: exp( ln(a) ) - exp( ln(0.1) + ln(b) ) But of course every time I try to exponentiate the log(a) or log(b) values I get Inf. Are there any tricks I can use to get a real result for exp( ln(a) ) - exp( ln(0.1) + ln(b) ), either in logarithm or exponential form? Thank you very much for the help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem loading hdf5 file
*I'm sorry, in some way I didn't see I was in the wrong directory. * *The real error message is the following:* hdf5_global_verbosity=3 load=1 Processing object: DNS .. which is a Group Processing object: BEAM .. its a dataset...Dataset has ID83886084 Dataset has tid 50331968 Dataset has space id 67108870 Dataset has rank 2 Dataset has dims/maxdims: 4720 3184 / -1 -1 Allocating matrix with rank=2 dim=4720 0 calling vector_io. Hangs here with big datsets Errore in hdf5load(RM-2007-GRAD-2048.St0.0.h5, verbosity = 3) : Can't get type for R type: 19 (IO) 2013/2/4 Flavio Pons flavio.p...@gmail.com *Hi everyone, I am a new subscriber, so I hope I'm posting in the right way. I need to load a hdf5 file, so I installed the hdf5 libraries ad the hdf5 R package; in downloaded a small sample file from the hdf5 website and I could correctly load it. But when I try to load my file: * require(hdf5) rm(list=ls()) ls() hdf5load(my_file.h5, verbosity=3) *I get this error message: * Errore in hdf5load(my_file.h5, verbosity = 1) : unable to open HDF file: my_file.h5 HDF5-DIAG: Error detected in HDF5 (1.8.4-patch1) thread 0: #000: /Builds/unix/hdf5-1.8.4-patch1/src/H5F.c line 1514 in H5Fopen(): unable to open file major: File accessability minor: Unable to open file #001: /Builds/unix/hdf5-1.8.4-patch1/src/H5F.c line 1218 in H5F_open(): unable to open file major: File accessability minor: Unable to open file #002: /Builds/unix/hdf5-1.8.4-patch1/src/H5FD.c line 1079 in H5FD_open(): open failed major: Virtual File Layer minor: Unable to initialize object #003: /Builds/unix/hdf5-1.8.4-patch1/src/H5FDsec2.c line 365 in H5FD_sec2_open(): unable to open file major: File accessability minor: Unable to open file #004: /Builds/unix/hdf5-1.8.4-patch1/src/H5FDsec2.c line 365 in H5FD_sec2_open(): No such file or directory major: Internal error (too specific to document in detail) minor: System error message *I really can't see the problem. I get the same error both with OSX and Ubuntu; could it simply be that the file is too large? In that case, what could I try to do? Thanks in advance,* * * *Flavio* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help on conditional selection of data.frame data...
Hello, I have trouble with using data.frame data. 1. I loaded data using the following: ff lt;- read.table(E:/R/VM/matrix.txt, header=T) The data I used is attached. I want to use at least 2 conditions for selecting of data. But I failed. It works. -gt; fff lt;- ff[ff$HG == GUEST,] lt;- fff[fff$WR == READ,] But it doesn't work -gt; ff[ff$HG == GUEST,ff$WR==READ] How can I use 2 or more conditions together in one sentence ? 2. I want to plot Throuput data using BlockSize as x-axis like the following: plot($BlockSize, $Throughput, type=o) But, Gap between 2 axis values are not consistent in the graph. So I tried to use log() like the following: plot( log($BlockSize), $Throughput, type=o) The problem seems to be fixed. But x-axis sting is shown not as (1,2,4,8,16,32,64,128) but as (0,1,2,3,4,5), which is not my intention. How can I fix this problem ? Thanks in advance, SK Park Throughput VM HG WR BlockSize 210.25 KVM HOSTWRITE 1 192.21 KVM HOSTWRITE 2 210.25 KVM HOSTWRITE 4 192.21 KVM HOSTWRITE 8 210.25 KVM HOSTWRITE 16 192.21 KVM HOSTWRITE 32 210.25 KVM HOSTWRITE 64 192.21 KVM HOSTWRITE 128 510.25 KVM HOSTREAD1 493.21 KVM HOSTREAD2 510.25 KVM HOSTREAD4 493.21 KVM HOSTREAD8 502.25 KVM HOSTREAD16 492.21 KVM HOSTREAD32 510.25 KVM HOSTREAD64 492.21 KVM HOSTREAD128 210.25 KVM GUEST WRITE 1 192.21 KVM GUEST WRITE 2 210.25 KVM GUEST WRITE 4 192.21 KVM GUEST WRITE 8 210.25 KVM GUEST WRITE 16 192.21 KVM GUEST WRITE 32 210.25 KVM GUEST WRITE 64 192.21 KVM GUEST WRITE 128 510.25 KVM GUEST READ1 532.21 KVM GUEST READ2 520.25 KVM GUEST READ4 522.21 KVM GUEST READ8 510.25 KVM GUEST READ16 503.21 KVM GUEST READ32 530.25 KVM GUEST READ64 509.21 KVM GUEST READ128 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help on conditional selection of data.frame data...
Hi, Look at the help page for ?Logic, and in particular the section that describes and |. Best, Ista On Mon, Feb 4, 2013 at 9:01 AM, skpark birdfir...@naver.com wrote: Hello, I have trouble with using data.frame data. 1. I loaded data using the following: ff lt;- read.table(E:/R/VM/matrix.txt, header=T) The data I used is attached. I want to use at least 2 conditions for selecting of data. But I failed. It works. -gt; fff lt;- ff[ff$HG == GUEST,] lt;- fff[fff$WR == READ,] But it doesn't work -gt; ff[ff$HG == GUEST,ff$WR==READ] How can I use 2 or more conditions together in one sentence ? 2. I want to plot Throuput data using BlockSize as x-axis like the following: plot($BlockSize, $Throughput, type=o) But, Gap between 2 axis values are not consistent in the graph. So I tried to use log() like the following: plot( log($BlockSize), $Throughput, type=o) The problem seems to be fixed. But x-axis sting is shown not as (1,2,4,8,16,32,64,128) but as (0,1,2,3,4,5), which is not my intention. How can I fix this problem ? Thanks in advance, SK Park __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Finding predicted probabilities and their confidence intervals for a logit model
Hi, I think you are looking for as.data.frame(effect(value, mod)) Best, Ista On Tue, Jan 29, 2013 at 6:08 PM, Abraham Mathew abmathe...@gmail.com wrote: I want to construct a logit model, plot the probability curve with the confidence intervals, and then I want to print out a data frame with the predictor, response value, predicted value, the low ci predicted value, and the high ci predicted value. So it should look something like: value low_ci prob hi_ci 50.10 0.12 0.13 60.11 0.130.16 70.13 0.150.17 Here's some sample data, the glm model, and a plot using the effects. I have the plot, I just need the presided data. dt - data.frame(won=c(rep(1,50),rep(0,50)), value=c(rnorm(100))) mod - glm(won ~ value, data=dt, family=binomial) mod library(effects) plot(effect(value, mod), rescale.axis=FALSE, multiline=TRUE) Help! Thank You! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] qdap 0.2.0 released
qdap (Quantitative Discourse Analysis Package) is an R package designed to assist in quantitative discourse analysis. The package stands as a bridge between qualitative transcripts of dialogue and statistical analysis and visualization. This is the first CRAN release of qdap: http://cran.r-project.org/web/packages/qdap/index.html The qdap package automates many of the tasks associated with quantitative discourse analysis of transcripts containing discourse including frequency counts of sentence types, words, sentence, turns of talk, syllable counts and other assorted analysis tasks. The package provides parsing tools for preparing transcript data. Many functions enable the user to aggregate data by any number of grouping variables providing analysis and seamless integration with other R packages that undertake higher level analysis and visualization of text. This provides the user with a more efficient and targeted analysis. Github development version: https://github.com/trinker/qdap As qdap is further developed the following are planned: (a) a github hosted website via statics (b) a help video section and (c) a vignette detailing workflow and use of qdap. Tyler Rinker ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Modifying a function programmatically
On Mon, Feb 4, 2013 at 5:00 AM, Søren Højsgaard sor...@math.aau.dk wrote: Dear list # I have a function ff - function(a,b=2,c=4){a+b+c} # which I programmatically want to modify to a more specialized function in which a is replaced by 1 ff1 - function(b=2,c=4){1+b+c} This a currying operation. Try: library(functional) ff1 - Curry(ff, a = 1) # test identical(ff1(2, 4), ff(1, 2, 4)) # TRUE -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Wide character in print?
Hello: Googling for Wide characters in print led me to a discussion that pushed me to review the read.table help page. Careful study there suggested I try setting fileEncoding to something; it suggested I look at the Encoding section in the help file for file. This suggested that anything I got to work on my computer might not be portable. Suggestions? Thanks, Spencer ### I get Wide character in print from trying read.xls(22_data.xls) in the gdata package, with 22_data.xls downloaded from Varieties_Country_A-E.xls at http://www.reinhartandrogoff.com/data/browse-by-topic/topics/7/: library(gdata) read.xls(22_data.xls) Wide character in print at C:/Users/sgraves/pgms/R/R-2.15.2/library/gdata/perl/xls2csv.pl line 270. sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] gdata_2.12.0 loaded via a namespace (and not attached): [1] gtools_2.7.0 I get the same message from xls2sep(22_data.xls). It's only a comment, so I suppose I could ignore it. However, it's generated by a function I'm adding to the Ecdat package, and I'd rather find a way to avoid it. (I suppose I could dump it to sink, but that's pretty extreme and could mask other problems.) Thanks, Spencer -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Correcting and Adding to Data Frame [RESOLVED]
On Fri, 1 Feb 2013, Rich Shepard wrote: Running on Slackware here with R-2.15.2. There is a data frame I need to edit to correct mis-spellings and to add a row. I used the edit() command with emacs but could not find the mis-spelled strings nor figure out how to add another row. The solution is to apply write.table(), edit the file in emacs, then apply read.table() to put it back into R format. Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rprof causing R to crash
Could you be a little more explicit of what the error message is. On my Windows system 32-bit, I get the following: Rprof() z - 1 system.time(for (i in 1:1e8) z - z + 1/i) Error: cannot allocate vector of size 381.5 Mb Which is probably due to trying to allocate 1e8 elements of integers (400MB). Could you have a similar problem? Now you could restructure your code to not allocate the large vector by: Rprof() z - 1 i - 0 system.time(while((i - i + 1) 1e8) z - z + 1/i) z Rprof(NULL) On Mon, Feb 4, 2013 at 7:48 AM, c97sr s...@stevenriley.net wrote: Am also having trouble with Rprof. I am using on R 2.15.2 on the Mac (Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)). The example above without profiling takes around a minute to run: z = 1 for (i in 1:1e8) z = z+1/i z [1] 19.9979 With profiling: Rprof() z = 1 for (i in 1:1e8) z = z+1/i [INFO] Feb 4, 2013 12:45:20 PM - R stopped. Crashes within a second or so. This is consistent with the problem I'm having in my own code in which there is a reasonable amount of memory used (but not a massive amount). Any help much appreciated. Am happy to post this as a bug if that is now appropriate. regards Steven -- View this message in context: http://r.789695.n4.nabble.com/Rprof-causing-R-to-crash-tp4652846p4657482.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] x-axis labelling
On Feb 4, 2013, at 4:00 AM, Alfredo Tello wrote: Hi Dave, Thanks for your reply. I can't reproduce the last line of code your code. The ifelse argument throws back an error saying it was not used. Did you look at your graphics window? On my machine the plot you asked for was created by the preceding line: barplot(db$var, names.arg=ifelse( rep( c(TRUE,FALSE), length=length(levels(db$date) ) ), levels(db$date), ), las=2,cex.axis=0.8,cex=0.8) True, the line in question was copied to the message by mistake, but an arguably workable answer was presented. -- David. A On Fri, Feb 1, 2013 at 10:56 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 1, 2013, at 9:30 AM, Alfredo Tello wrote: Hi Folks! I have a question regarding an issue on which I´ve read a few threads but can´t resolve -- Labelling every other tick mark on the x-axis using factors. Here´s an example: Why not: db-data.frame(date=as.factor(c(1:50)),var=rnorm(50)) barplot(db$var,names.arg=ifelse( rep( c(TRUE,FALSE), length=length(levels(db$date) ) ), levels(db$date), ),las=2,cex.axis=0.8,cex=0.8) barplot(db$var,names.arg=ifelse( c(TRUE,FALSE), levels(db$date), },las=2,cex.axis=0.8,cex=0.8) -- David. This labels all the tickmarks in my barplot, which is the default behavior. I would like to label every other tick mark in the barplot -- 1,3,5,7 and so on. Thank you very much for your help! All the best, A -- Alfredo Tello (http://alfredotello.com) Sustainable Aquaculture Group Institute of Aquaculture University of Stirling Scotland, UK. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Alameda, CA, USA -- Alfredo Tello (http://alfredotello.com) Sustainable Aquaculture Group Institute of Aquaculture University of Stirling Scotland, UK. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Combining data from different saved files with same object names into one data frame
Try this storing them to a list with the j,k,l,m as an index: result - list() for(j in 1:2){ for(k in 1:6){ for(l in 1:2){ for(m in 1:2){ fsumstatZINB=paste(/Users/chris/Dropbox/phd/analysis/Simulation/zinbmodels/summaries/zinbsumstat-,j,k,l,m,.rdata, sep=) load(fsumstatZINB) print(zinbMeans[,1]) result[[paste(j,k,l,m)]] - zinbMeans } } } } On Mon, Feb 4, 2013 at 12:02 PM, Christopher Desjardins cddesjard...@gmail.com wrote: Hi, I am simulating data from a zero-inflated negative binomial model. I have 4 different conditions and I've saved various information about the models in zinbsumbstat-jklm.rdata (as shown below). What I want to do is print information from each of these *.rdata and store them in one large object (a matrix or a data frame). However, within each data the objects all have the same name. So I don't know how to combine these into one object. Below is the code that I could use to paste all the information into the console. for(j in 1:2){ for(k in 1:6){ for(l in 1:2){ for(m in 1:2){ fsumstatZINB=paste(/Users/chris/Dropbox/phd/analysis/Simulation/zinbmodels/summaries/zinbsumstat-,j,k,l,m,.rdata, sep=) load(fsumstatZINB) print(zinbMeans[,1]) } } } } How could I combine all the information from these loops into a matrix() or a data.frame()? Two of the datasets [1,2] are pasted in a public Dropbox. Thanks! Chris [1] https://dl.dropbox.com/u/1501309/zinbsumstat-.rdata [2] https://dl.dropbox.com/u/1501309/zinbsumstat-1112.rdata [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Combining data from different saved files with same object names into one data frame
Thanks Jim. That'll work for me! Chris On Mon, Feb 4, 2013 at 11:17 AM, jim holtman jholt...@gmail.com wrote: Try this storing them to a list with the j,k,l,m as an index: result - list() for(j in 1:2){ for(k in 1:6){ for(l in 1:2){ for(m in 1:2){ fsumstatZINB=paste(/Users/chris/Dropbox/phd/analysis/Simulation/zinbmodels/summaries/zinbsumstat-,j,k,l,m,.rdata, sep=) load(fsumstatZINB) print(zinbMeans[,1]) result[[paste(j,k,l,m)]] - zinbMeans } } } } On Mon, Feb 4, 2013 at 12:02 PM, Christopher Desjardins cddesjard...@gmail.com wrote: Hi, I am simulating data from a zero-inflated negative binomial model. I have 4 different conditions and I've saved various information about the models in zinbsumbstat-jklm.rdata (as shown below). What I want to do is print information from each of these *.rdata and store them in one large object (a matrix or a data frame). However, within each data the objects all have the same name. So I don't know how to combine these into one object. Below is the code that I could use to paste all the information into the console. for(j in 1:2){ for(k in 1:6){ for(l in 1:2){ for(m in 1:2){ fsumstatZINB=paste(/Users/chris/Dropbox/phd/analysis/Simulation/zinbmodels/summaries/zinbsumstat-,j,k,l,m,.rdata, sep=) load(fsumstatZINB) print(zinbMeans[,1]) } } } } How could I combine all the information from these loops into a matrix() or a data.frame()? Two of the datasets [1,2] are pasted in a public Dropbox. Thanks! Chris [1] https://dl.dropbox.com/u/1501309/zinbsumstat-.rdata [2] https://dl.dropbox.com/u/1501309/zinbsumstat-1112.rdata [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Wide character in print?
On Feb 4, 2013, at 10:39 AM, Spencer Graves spencer.gra...@structuremonitoring.com wrote: Hello: Googling for Wide characters in print led me to a discussion that pushed me to review the read.table help page. Careful study there suggested I try setting fileEncoding to something; it suggested I look at the Encoding section in the help file for file. This suggested that anything I got to work on my computer might not be portable. Suggestions? Thanks, Spencer ### I get Wide character in print from trying read.xls(22_data.xls) in the gdata package, with 22_data.xls downloaded from Varieties_Country_A-E.xls at http://www.reinhartandrogoff.com/data/browse-by-topic/topics/7/: library(gdata) read.xls(22_data.xls) Wide character in print at C:/Users/sgraves/pgms/R/R-2.15.2/library/gdata/perl/xls2csv.pl line 270. sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] gdata_2.12.0 loaded via a namespace (and not attached): [1] gtools_2.7.0 I get the same message from xls2sep(22_data.xls). It's only a comment, so I suppose I could ignore it. However, it's generated by a function I'm adding to the Ecdat package, and I'd rather find a way to avoid it. (I suppose I could dump it to sink, but that's pretty extreme and could mask other problems.) Thanks, Spencer Spencer, The error message is coming from Perl, not from R and from what I understand, is typically encountered when there are UTF-8/Unicode characters in the source. Wide character apparently referring to multi-byte encodings. Having downloaded the Excel file you indicate above, my first reaction is that it is not really structured in a way to facilitate automated parsing to a CSV file (the intermediate step before using read.table()) to then be read into R to a data frame. They are not purely rows and columns of data, which is the typical application for read.xls(). There are lengthy header lines in the worksheets, some of which include copyright symbols, which is likely why you are getting the error from Perl. There are also embedded objects in the worksheets, which appear to be image crops of tables from a paper. I honestly don't know if read.xls() is set up to handle that stuff and you may need to contact the maintainers. Given the above, I am not sure what I would recommend if your goal is to parse the raw data contained in the Excel worksheets and include them in a package. You may need to copy and paste the data ranges to the OS clipboard and read them into R from there, or consider using a different R package that has more flexibility in defining the specific Excel worksheet cell ranges that you want to extract. Others may have different ideas for you. Regards, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] If() values in one dataframe then return values from another
I have a large data frame (data1) that looks like: A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 [1,] 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 [2,] 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 [3,] 1 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 [4,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 2 [5,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 2 0 2 [6,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 2 2 2 [7,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [8,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [9,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [10,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [11,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [12,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [13,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [14,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [15,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [16,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 [17,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 [18,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 [19,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 2 2 [20,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [21,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [22,] 0 0 0 2 0 0 0 0 0 0 0 2 0 0 0 1 0 0 0 0 [23,] 0 0 0 2 0 0 0 1 0 0 0 2 0 0 0 2 0 0 0 2 [24,] 0 0 1 2 0 0 0 2 0 0 1 1 0 1 0 1 0 0 2 2 [25,] 0 1 1 2 0 2 2 2 1 1 1 1 0 1 1 1 1 0 2 2 [26,] 1 1 1 1 1 2 2 2 1 1 1 1 2 1 1 1 1 2 2 2 [27,] 1 1 1 1 1 2 1 2 1 1 1 1 2 1 1 1 1 2 2 2 [28,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [29,] 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 2 2 2 [30,] 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 2 1 2 2 2 [31,] 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 2 2 2 [32,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [33,] 1 1 1 1 1 3 3 3 3 1 3 3 1 1 2 1 1 2 2 2 [34,] 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2 [35,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 [36,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [37,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [38,] 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 [39,] 0 0 0 0 0 0 0 0 0 2 0 0 2 0 0 2 0 0 0 2 [40,] 1 1 2 1 1 2 1 2 2 2 2 2 2 1 1 1 1 2 3 2 (data1 is actually 1,080 rows long.) If there is a 3 in any row above, I'd like to be given the values from a second data frame (meter): meter 1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 1011 1110 12 9 13 8 14 7 15 6 16 5 17 4 18 3 19 2 20 1 2120 2219 2318 2417 2516 2615 2714 2813 29 8 30 7 31 6 32 2 33 1 3410 35 4 36 3 37 2 3818 3917 4015 (meter is actually 1,080 rows long) If there is no 3 row i of data1, I'd like to R to return NA. I've tried for(i in 1:40){ if( (any(data1[i,] == 3)) ) mA - meter[i,] else mA - NA } But I'm given: mA [1] 15 Levels: 1 10 11 12 13 14 15 16 17 18 19 2 20 3 4 5 6 7 8 9 Can anyone give me some additional ideas to try? Thanks - SR Steven H. Ranney __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
Re: [R] Meaning of .noemail extension for CRAN uploads?
On 04.02.2013 14:17, Milan Bouchet-Valat wrote: Hi all! I've uploaded two packages to CRAN via FTP [1] about a week ago, and while one was promptly processed by Brian Ripley (thanks for that!), the second got the .noemail extension added, and nothing else happened. So I wonder whether CRAN maintainers are waiting for some action on my side or whether I should just wait without worrying. (Of course, I did send a manual e-mail stating I accept CRAN policies -- I even sent it twice.) I'm aware that CRAN policies [2] state: Part of the processing is that uploads may be renamed by adding one of the extensions .save, .pending or .noemail: the presence of such a file is a sign that a submission is still pending (and such a file name should never be uploaded). But this does not give me the meaning of this intriguing .noemail extension. :-) I guess this message can also be useful for people looking for this in the future, since currently Web searches do not return anything interesting for CRAN .noemail. Please ask CRAN@, readers of this mailing list cannot know. The .noemail extension typically indicates that the CRAN admins do not have received any submission message and hence do not know if the submission comes from the maintainer or someone else. Best, Uwe Ligges Thanks! 1: ftp://cran.r-project.org/incoming 2: http://cran.r-project.org/web/packages/policies.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] developing package: dealing with namespaces
I am tweaking an R package for which I have the source; the relevant code is in R not C. I'm making changes to the package code. What is the best workflow for doing this? I recall the advice used to be to remove the NAMESPACE during development, but I don't think this is possible anymore. For simplicity, suppose I have an outer level function f defined in f.R and an innder g in g.R defined in the package. My understanding is that if I modify g.R and load it (e.g., C-c C-l in ESS) this will have no effect on the code the f calls, since the latter is in a namespace. If I modify f.R and import it, I'm not sure if it can find g at all if it has not been exported. Web searches and reviewing the R Extensions manual have turned up information on how to trace into functions in namesapces, but not on the larger development cycle. Thanks. Ross __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Meaning of .noemail extension for CRAN uploads?
Le lundi 04 février 2013 à 18:58 +0100, Uwe Ligges a écrit : On 04.02.2013 14:17, Milan Bouchet-Valat wrote: Hi all! I've uploaded two packages to CRAN via FTP [1] about a week ago, and while one was promptly processed by Brian Ripley (thanks for that!), the second got the .noemail extension added, and nothing else happened. So I wonder whether CRAN maintainers are waiting for some action on my side or whether I should just wait without worrying. (Of course, I did send a manual e-mail stating I accept CRAN policies -- I even sent it twice.) I'm aware that CRAN policies [2] state: Part of the processing is that uploads may be renamed by adding one of the extensions .save, .pending or .noemail: the presence of such a file is a sign that a submission is still pending (and such a file name should never be uploaded). But this does not give me the meaning of this intriguing .noemail extension. :-) I guess this message can also be useful for people looking for this in the future, since currently Web searches do not return anything interesting for CRAN .noemail. Please ask CRAN@, readers of this mailing list cannot know. That's what I did (twice!), so I figured here I would get an answer, and I would be able to check that my message correctly arrived to its destination. The .noemail extension typically indicates that the CRAN admins do not have received any submission message and hence do not know if the submission comes from the maintainer or someone else. OK, so I was right to be concerned about it. ;-) This e-mail will at least serve as a reference for future Googlers, but it might be useful to mention the meaning of .noemail you just gave me in the CRAN policies page. Currently, the explanation (see above) sounds rather like: don't worry, this means the upload is in progress, which is not the case with .noemail. I'm transferring you privately the mail I sent to CRAN@, since it seems I'm not able to send it directly (blocked SMTP server?). Thanks for your reply! Best, Uwe Ligges Thanks! 1: ftp://cran.r-project.org/incoming 2: http://cran.r-project.org/web/packages/policies.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] If() values in one dataframe then return values from another
On Feb 4, 2013, at 9:48 AM, Steven Ranney wrote: I have a large data frame (data1) that looks like: A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 [1,] 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 [2,] 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 [3,] 1 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 [4,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 2 [5,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 2 0 2 [6,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 2 2 2 [7,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [8,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [9,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [10,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [11,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [12,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [13,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [14,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [15,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [16,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 [17,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 [18,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 [19,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 2 2 [20,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [21,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [22,] 0 0 0 2 0 0 0 0 0 0 0 2 0 0 0 1 0 0 0 0 [23,] 0 0 0 2 0 0 0 1 0 0 0 2 0 0 0 2 0 0 0 2 [24,] 0 0 1 2 0 0 0 2 0 0 1 1 0 1 0 1 0 0 2 2 [25,] 0 1 1 2 0 2 2 2 1 1 1 1 0 1 1 1 1 0 2 2 [26,] 1 1 1 1 1 2 2 2 1 1 1 1 2 1 1 1 1 2 2 2 [27,] 1 1 1 1 1 2 1 2 1 1 1 1 2 1 1 1 1 2 2 2 [28,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [29,] 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 2 2 2 [30,] 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 2 1 2 2 2 [31,] 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 2 2 2 [32,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [33,] 1 1 1 1 1 3 3 3 3 1 3 3 1 1 2 1 1 2 2 2 [34,] 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2 [35,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 [36,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [37,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [38,] 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 [39,] 0 0 0 0 0 0 0 0 0 2 0 0 2 0 0 2 0 0 0 2 [40,] 1 1 2 1 1 2 1 2 2 2 2 2 2 1 1 1 1 2 3 2 (data1 is actually 1,080 rows long.) If there is a 3 in any row above, I'd like to be given the values from a second data frame (meter): meter 1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 1011 1110 12 9 13 8 14 7 15 6 16 5 17 4 18 3 19 2 20 1 2120 2219 2318 2417 2516 2615 2714 2813 29 8 30 7 31 6 32 2 33 1 3410 35 4 36 3 37 2 3818 3917 4015 (meter is actually 1,080 rows long) One hopes for the success of htis effort that 'data1' has an equal number of rows. If there is no 3 row i of data1, I'd like to R to return NA. I've tried for(i in 1:40){ if( } Generally sequential testing is best handled with `ifelse` rather than with for loops and `if () {} else{}` mA - ifelse ( apply(data, 1, any), meter, NA) But I'm given: mA [1] 15 Levels: 1 10 11 12 13 14 15 16
Re: [R] If() values in one dataframe then return values from another
Hi Steven, You are not indexing mA properly within the loop. In order not to change the elements of the object, I'll create a new vector, mA2 -not strictly necessary, though. Let's start with an empty vector: mA2 - rep(0,40) Now, the loop with the correct indexing: for(i in 1:40){ + if( (any(data1[i,] == 3)) ) mA2[i] - mA$meter[i] else mA2[i] - NA } You'll get: mA2 [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [26] NA NA NA NA NA NA NA 1 NA NA NA NA NA NA 15 Hope this helps, José José Iparraguirre Chief Economist Age UK -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steven Ranney Sent: 04 February 2013 17:48 To: r-help@r-project.org Subject: [R] If() values in one dataframe then return values from another I have a large data frame (data1) that looks like: A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 [1,] 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 [2,] 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 [3,] 1 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 [4,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 2 [5,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 2 0 2 [6,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 2 2 2 [7,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [8,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [9,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [10,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [11,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [12,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [13,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [14,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [15,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [16,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 [17,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 [18,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 [19,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 2 2 [20,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [21,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [22,] 0 0 0 2 0 0 0 0 0 0 0 2 0 0 0 1 0 0 0 0 [23,] 0 0 0 2 0 0 0 1 0 0 0 2 0 0 0 2 0 0 0 2 [24,] 0 0 1 2 0 0 0 2 0 0 1 1 0 1 0 1 0 0 2 2 [25,] 0 1 1 2 0 2 2 2 1 1 1 1 0 1 1 1 1 0 2 2 [26,] 1 1 1 1 1 2 2 2 1 1 1 1 2 1 1 1 1 2 2 2 [27,] 1 1 1 1 1 2 1 2 1 1 1 1 2 1 1 1 1 2 2 2 [28,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [29,] 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 2 2 2 [30,] 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 2 1 2 2 2 [31,] 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 2 2 2 [32,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [33,] 1 1 1 1 1 3 3 3 3 1 3 3 1 1 2 1 1 2 2 2 [34,] 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2 [35,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 [36,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [37,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [38,] 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 [39,] 0 0 0 0 0 0 0 0 0 2 0 0 2 0 0 2 0 0 0 2 [40,] 1 1 2 1 1 2 1 2 2 2 2 2 2 1 1 1 1 2 3 2 (data1 is actually 1,080 rows long.) If there is a 3 in any row above, I'd like to be given the values from a second data frame (meter): meter 1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 1011 1110 12 9 13 8 14 7 15 6 16 5 17 4 18 3 19 2 20 1 2120 2219 2318 2417 2516 2615 2714 2813 29
Re: [R] If() values in one dataframe then return values from another
Hello, Try the following. mA - sapply(seq_len(nrow(data1)), function(i) if(any(data1[i,] == 3)) meter[i, 1] else NA) Hope this helps, Rui Barradas Em 04-02-2013 17:48, Steven Ranney escreveu: I have a large data frame (data1) that looks like: A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 [1,] 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 [2,] 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 [3,] 1 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 [4,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 2 [5,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 2 0 2 [6,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 2 2 2 [7,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [8,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [9,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [10,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [11,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [12,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [13,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [14,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [15,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [16,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 [17,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 [18,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 [19,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 2 2 [20,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [21,] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [22,] 0 0 0 2 0 0 0 0 0 0 0 2 0 0 0 1 0 0 0 0 [23,] 0 0 0 2 0 0 0 1 0 0 0 2 0 0 0 2 0 0 0 2 [24,] 0 0 1 2 0 0 0 2 0 0 1 1 0 1 0 1 0 0 2 2 [25,] 0 1 1 2 0 2 2 2 1 1 1 1 0 1 1 1 1 0 2 2 [26,] 1 1 1 1 1 2 2 2 1 1 1 1 2 1 1 1 1 2 2 2 [27,] 1 1 1 1 1 2 1 2 1 1 1 1 2 1 1 1 1 2 2 2 [28,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [29,] 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 2 2 2 [30,] 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 2 1 2 2 2 [31,] 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 2 2 2 [32,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [33,] 1 1 1 1 1 3 3 3 3 1 3 3 1 1 2 1 1 2 2 2 [34,] 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2 [35,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 [36,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [37,] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [38,] 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 [39,] 0 0 0 0 0 0 0 0 0 2 0 0 2 0 0 2 0 0 0 2 [40,] 1 1 2 1 1 2 1 2 2 2 2 2 2 1 1 1 1 2 3 2 (data1 is actually 1,080 rows long.) If there is a 3 in any row above, I'd like to be given the values from a second data frame (meter): meter 1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 1011 1110 12 9 13 8 14 7 15 6 16 5 17 4 18 3 19 2 20 1 2120 2219 2318 2417 2516 2615 2714 2813 29 8 30 7 31 6 32 2 33 1 3410 35 4 36 3 37 2 3818 3917 4015 (meter is actually 1,080 rows long) If there is no 3 row i of data1, I'd like to R to return NA. I've tried for(i in 1:40){ if( (any(data1[i,] == 3)) ) mA - meter[i,] else mA - NA } But I'm given: mA [1] 15 Levels: 1 10 11 12 13 14 15 16 17 18 19 2 20 3 4 5 6 7 8 9 Can anyone give me some additional
Re: [R] developing package: dealing with namespaces
On 04/02/2013 12:59 PM, Ross Boylan wrote: I am tweaking an R package for which I have the source; the relevant code is in R not C. I'm making changes to the package code. What is the best workflow for doing this? I recall the advice used to be to remove the NAMESPACE during development, but I don't think this is possible anymore. For simplicity, suppose I have an outer level function f defined in f.R and an innder g in g.R defined in the package. My understanding is that if I modify g.R and load it (e.g., C-c C-l in ESS) this will have no effect on the code the f calls, since the latter is in a namespace. If I modify f.R and import it, I'm not sure if it can find g at all if it has not been exported. Web searches and reviewing the R Extensions manual have turned up information on how to trace into functions in namesapces, but not on the larger development cycle. I think the best workflow is to do the edits outside of R, and re-install the package to test. It is possible to do edits to a loaded package, using the assignInNamespace() function, but I don't think there's a simple workflow that doesn't end up with multiple copies of functions, and possible confusion over which version - is in the source, so will be saved - is in the global env, so will be executed by a user at the top level - is in the namespace, so will be executed by calls from other functions in the namespace. This is something that could probably be handled well by a smart editor. I don't know if any of the existing IDEs do it. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] developing package: dealing with namespaces
On Mon, Feb 4, 2013 at 6:23 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 04/02/2013 12:59 PM, Ross Boylan wrote: I am tweaking an R package for which I have the source; the relevant code is in R not C. I'm making changes to the package code. What is the best workflow for doing this? I recall the advice used to be to remove the NAMESPACE during development, but I don't think this is possible anymore. For simplicity, suppose I have an outer level function f defined in f.R and an innder g in g.R defined in the package. My understanding is that if I modify g.R and load it (e.g., C-c C-l in ESS) this will have no effect on the code the f calls, since the latter is in a namespace. If I modify f.R and import it, I'm not sure if it can find g at all if it has not been exported. Web searches and reviewing the R Extensions manual have turned up information on how to trace into functions in namesapces, but not on the larger development cycle. I think the best workflow is to do the edits outside of R, and re-install the package to test. Isn't the best[1] workflow to use devtools? Edit the code in-place, do load_all(packagefolder) and devtools' magic does the rest? Without polluting the workspace. Since I started doing that I hardly ever C-c C-l into ESS any more. All my functions are in packages, sometimes the package is just created ad-hoc with devtools' create(packagefolder) function. Lightweight, yet fully-functional packages. Dream. Barry [1] for some value of best __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exponentiate very large numbers
Hello, Use a simple transfomation. Divide both t log.a - 1347 log.b - 1351 tmp1 - exp(log.a - log(0.1) - log.b) - 1 result - tmp1 * exp(0.1 + log.b) # -Inf Using base 10, the result would be -4.405386507*10^585 a number too large for R. See the help page ?.Machine Hope this helps, Rui Barradas Em 04-02-2013 15:11, francesca casalino escreveu: Dear R experts, I have the logarithms of 2 values: log(a) = 1347 log(b) = 1351 And I am trying to solve this expression: exp( ln(a) ) - exp( ln(0.1) + ln(b) ) But of course every time I try to exponentiate the log(a) or log(b) values I get Inf. Are there any tricks I can use to get a real result for exp( ln(a) ) - exp( ln(0.1) + ln(b) ), either in logarithm or exponential form? Thank you very much for the help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exponentiate very large numbers
Sorry, it should be: Divide both terms by exp(log(0.1) + log.b) to give tmp1 - exp(log.a - log(0.1) - log.b) - 1 result - tmp1 * exp(log(0.1) + log.b) Rui Barradas Em 04-02-2013 18:53, Rui Barradas escreveu: Hello, Use a simple transfomation. Divide both t log.a - 1347 log.b - 1351 tmp1 - exp(log.a - log(0.1) - log.b) - 1 result - tmp1 * exp(0.1 + log.b) # -Inf Using base 10, the result would be -4.405386507*10^585 a number too large for R. See the help page ?.Machine Hope this helps, Rui Barradas Em 04-02-2013 15:11, francesca casalino escreveu: Dear R experts, I have the logarithms of 2 values: log(a) = 1347 log(b) = 1351 And I am trying to solve this expression: exp( ln(a) ) - exp( ln(0.1) + ln(b) ) But of course every time I try to exponentiate the log(a) or log(b) values I get Inf. Are there any tricks I can use to get a real result for exp( ln(a) ) - exp( ln(0.1) + ln(b) ), either in logarithm or exponential form? Thank you very much for the help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] developing package: dealing with namespaces
On 04/02/2013 1:48 PM, Barry Rowlingson wrote: On Mon, Feb 4, 2013 at 6:23 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 04/02/2013 12:59 PM, Ross Boylan wrote: I am tweaking an R package for which I have the source; the relevant code is in R not C. I'm making changes to the package code. What is the best workflow for doing this? I recall the advice used to be to remove the NAMESPACE during development, but I don't think this is possible anymore. For simplicity, suppose I have an outer level function f defined in f.R and an innder g in g.R defined in the package. My understanding is that if I modify g.R and load it (e.g., C-c C-l in ESS) this will have no effect on the code the f calls, since the latter is in a namespace. If I modify f.R and import it, I'm not sure if it can find g at all if it has not been exported. Web searches and reviewing the R Extensions manual have turned up information on how to trace into functions in namesapces, but not on the larger development cycle. I think the best workflow is to do the edits outside of R, and re-install the package to test. Isn't the best[1] workflow to use devtools? Edit the code in-place, do load_all(packagefolder) and devtools' magic does the rest? Without polluting the workspace. Thanks for the pointer. I hadn't tried that. Duncan Murdoch Since I started doing that I hardly ever C-c C-l into ESS any more. All my functions are in packages, sometimes the package is just created ad-hoc with devtools' create(packagefolder) function. Lightweight, yet fully-functional packages. Dream. Barry [1] for some value of best __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Modifying Package Data
The bio.infer package contains a data frame /usr/lib/R/library/bio.infer/data/itis.ttable.rda that needs to be modified. After loading the bio.infer package and attaching the data frame with the data() function, I wrote the data frame to a text file. After adding another row to the data frame I applied read.table() to create a data frame, but it's in my pwd, not the R library data subdirectory for the bio.infer package. What is the R function to copy/save/write either the text file or the local copy of itis.ttable to /usr/lib/R/library/bio.infer/data/itis.ttable.rda? Thanks, Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] is it possible to create a trellis object with multiple colorkeys/z-scale axis?
Dear R users- Do the lattice/latticeExtra packages support multiple tileplots with unique colorkeys? I am trying to create a visualization of the encounter rate of certain stocks of salmon across two years. The issue I am having is that some stocks are encountered at much higher rates than others.the high encounter rate for one stock washes out the patterns I'm hoping to visualize across the other, less common, stocks. In the example below, the high encounter rate of Central Valley Fall (CVF) in San Francisco (SF) during June of 2011 makes it impossible to identify differences in encounter rate of the other stocks. Is there a way to create the same plot but with a unique colorkey for each panel? #Please first load packages RCurl and latticeExtra #Import data getdata-getURL(https://docs.google.com/spreadsheet/pub?hl=enhl=enkey=0Aj zYZNH9Dw9qdENjREl2ZkVlcFA4MDN2S1h6Vi03ZUEsingle=truegid=0output=csv,ssl. verifypeer=FALSE) test-read.csv(textConnection(getdata),header=T) test$year-as.factor(test$year) head(test) ##Custom color ramp jet.colors - colorRampPalette(c(#7F, blue, #007FFF, cyan, #7FFF7F, yellow, #FF7F00, red, #7F)) ##create trellis of tileplots betweenyear-tileplot(index~month*-area|stock+year,test,col.regions=jet.colo rs(256), scales=list(x=list(at=5:9, labels=c('May' ,'Jun','Jul','Aug','Sep'),cex=0.6), y=list(at=(-1):-8,labels=c('T','N','C','B','KC','FB','SF','MO'))), main = list(label=Stock specific encounter rate by WCGSI: 2010 versus 2011,cex=0.75) , xlab= Month, ylab= Management Area, border = black, panel = function(...){ panel.fill(black) panel.voronoi(...) }) ##plot object plot(betweenyear) Thank you for your time and consideration. Regards, Ryan Ryan Flaherty Oregon State University College of Oceanic and Atmospheric Science Marine Resource Management 541-513-0293 rflahe...@coas.oregonstate.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is it possible to create a trellis object with multiple colorkeys/z-scale axis?
This will get you started library(lattice) library(latticeExtra) D1 - data.frame(y=1:3, x=4:6) D2 - data.frame(y=7:10, x=11:14) T1 - xyplot(y ~ x, data=D1, key=list(space=right, text=list(LETTERS[1:3], col=c(red,green,blue T2 - xyplot(y ~ x, data=D2, key=list(space=right, text=list(LETTERS[4:7], col=c(orange,purple,brown,pink c(T1, T2, layout=c(1,2), merge.legends=TRUE) Rich On Mon, Feb 4, 2013 at 2:37 PM, Ryan Flaherty ryan1.flahe...@gmail.comwrote: Dear R users- Do the lattice/latticeExtra packages support multiple tileplots with unique colorkeys? I am trying to create a visualization of the encounter rate of certain stocks of salmon across two years. The issue I am having is that some stocks are encountered at much higher rates than others.the high encounter rate for one stock washes out the patterns I'm hoping to visualize across the other, less common, stocks. In the example below, the high encounter rate of Central Valley Fall (CVF) in San Francisco (SF) during June of 2011 makes it impossible to identify differences in encounter rate of the other stocks. Is there a way to create the same plot but with a unique colorkey for each panel? #Please first load packages RCurl and latticeExtra #Import data getdata-getURL( https://docs.google.com/spreadsheet/pub?hl=enhl=enkey=0Aj zYZNH9Dw9qdENjREl2ZkVlcFA4MDN2S1h6Vi03ZUEsingle=truegid=0output=csv ,ssl. verifypeer=FALSE) test-read.csv(textConnection(getdata),header=T) test$year-as.factor(test$year) head(test) ##Custom color ramp jet.colors - colorRampPalette(c(#7F, blue, #007FFF, cyan, #7FFF7F, yellow, #FF7F00, red, #7F)) ##create trellis of tileplots betweenyear-tileplot(index~month*-area|stock+year,test,col.regions=jet.colo rs(256), scales=list(x=list(at=5:9, labels=c('May' ,'Jun','Jul','Aug','Sep'),cex=0.6), y=list(at=(-1):-8,labels=c('T','N','C','B','KC','FB','SF','MO'))), main = list(label=Stock specific encounter rate by WCGSI: 2010 versus 2011,cex=0.75) , xlab= Month, ylab= Management Area, border = black, panel = function(...){ panel.fill(black) panel.voronoi(...) }) ##plot object plot(betweenyear) Thank you for your time and consideration. Regards, Ryan Ryan Flaherty Oregon State University College of Oceanic and Atmospheric Science Marine Resource Management 541-513-0293 rflahe...@coas.oregonstate.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is it possible to create a trellis object with multiple colorkeys/z-scale axis?
On further thought, this might be better as it keeps the keys distinct library(lattice) library(latticeExtra) D1 - data.frame(y=1:3, x=4:6) D2 - data.frame(y=7:10, x=11:14) T1 - xyplot(y ~ x, data=D1, key=list(space=right, text=list(LETTERS[1:3], col=c(red,green,blue T2 - xyplot(y ~ x, data=D2, key=list(space=right, text=list(LETTERS[4:7], col=c(orange,purple,brown,pink c(T1, T2, layout=c(1,2), merge.legends=TRUE) print(update(T1, xlim=c(3,15)), split=c(1,1,1,2), more=TRUE) print(update(T2, xlim=c(3,15)), split=c(1,2,1,2), more=FALSE) On Mon, Feb 4, 2013 at 3:06 PM, Richard M. Heiberger r...@temple.edu wrote: This will get you started library(lattice) library(latticeExtra) D1 - data.frame(y=1:3, x=4:6) D2 - data.frame(y=7:10, x=11:14) T1 - xyplot(y ~ x, data=D1, key=list(space=right, text=list(LETTERS[1:3], col=c(red,green,blue T2 - xyplot(y ~ x, data=D2, key=list(space=right, text=list(LETTERS[4:7], col=c(orange,purple,brown,pink c(T1, T2, layout=c(1,2), merge.legends=TRUE) Rich On Mon, Feb 4, 2013 at 2:37 PM, Ryan Flaherty ryan1.flahe...@gmail.comwrote: Dear R users- Do the lattice/latticeExtra packages support multiple tileplots with unique colorkeys? I am trying to create a visualization of the encounter rate of certain stocks of salmon across two years. The issue I am having is that some stocks are encountered at much higher rates than others.the high encounter rate for one stock washes out the patterns I'm hoping to visualize across the other, less common, stocks. In the example below, the high encounter rate of Central Valley Fall (CVF) in San Francisco (SF) during June of 2011 makes it impossible to identify differences in encounter rate of the other stocks. Is there a way to create the same plot but with a unique colorkey for each panel? #Please first load packages RCurl and latticeExtra #Import data getdata-getURL( https://docs.google.com/spreadsheet/pub?hl=enhl=enkey=0Aj zYZNH9Dw9qdENjREl2ZkVlcFA4MDN2S1h6Vi03ZUEsingle=truegid=0output=csvhttps://docs.google.com/spreadsheet/pub?hl=enhl=enkey=0AjzYZNH9Dw9qdENjREl2ZkVlcFA4MDN2S1h6Vi03ZUEsingle=truegid=0output=csv ,ssl. verifypeer=FALSE) test-read.csv(textConnection(getdata),header=T) test$year-as.factor(test$year) head(test) ##Custom color ramp jet.colors - colorRampPalette(c(#7F, blue, #007FFF, cyan, #7FFF7F, yellow, #FF7F00, red, #7F)) ##create trellis of tileplots betweenyear-tileplot(index~month*-area|stock+year,test,col.regions=jet.colo rs(256), scales=list(x=list(at=5:9, labels=c('May' ,'Jun','Jul','Aug','Sep'),cex=0.6), y=list(at=(-1):-8,labels=c('T','N','C','B','KC','FB','SF','MO'))), main = list(label=Stock specific encounter rate by WCGSI: 2010 versus 2011,cex=0.75) , xlab= Month, ylab= Management Area, border = black, panel = function(...){ panel.fill(black) panel.voronoi(...) }) ##plot object plot(betweenyear) Thank you for your time and consideration. Regards, Ryan Ryan Flaherty Oregon State University College of Oceanic and Atmospheric Science Marine Resource Management 541-513-0293 rflahe...@coas.oregonstate.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rJava works with 32-bit but not 64
Is it feasible to have both installed in a way that allows the each version of R to select its own version of Java? A comment on stackoverflow suggests that may not be easy (http://stackoverflow.com/questions/5272216/is-it-possible-to-install-both-32bit-and-64bit-java-on-windows-7). One of the simplest ways to be sure of getting 64-bit Java is to use the 64-bit version of Internet Explorer which makes things almost automatic. Rob -- Robert W. Baer, Ph.D. Professor of Physiology Kirksille College of Osteopathic Medicine A. T. Still University of Health Sciences Kirksville, MO 63501 USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Modifying a function programmatically
Dear Gabor, Thanks for pointing me to this; didn't know the Curry function. For what it is worth, the two approaches perform somewhat differently in terms of computing time (my specialize function is given at the end): library(functional) ## EXAMPLE 1 ff - function(a,b=2,c=4){a+b+c} ff1 - specialize(ff, vals=list(a=1,bb=123)) ff2 - Curry(ff, a = 1) rbenchmark::benchmark(ff1(b=10), ff2(b=10), replications=10) test replications elapsed relative user.self sys.self user.child sys.child 1 ff1(b = 10) 100.391.000 0.390 NA NA 2 ff2(b = 10) 100.812.077 0.790 NA NA ## EXAMPLE 2 gg - rnorm gg1 - specialize(gg, list(n=10)) gg2 - Curry(gg, n=1000) rbenchmark::benchmark(gg1(), gg2(), replications=10) test replications elapsed relative user.self sys.self user.child sys.child 1 gg1() 100.531.000 0.53 0.00 NANA 2 gg2() 109.25 17.453 9.22 0.01 NANA where specialize - function(ff, vals){ expr1 - as.expression(body(ff)) expr2 - do.call(substitute, list(expr1[[1]], vals)) gg - formals(ff) idx -match(names(vals), names(gg)) idx - idx[!is.na(idx)] if (length(idx)0){ gg - gg[-idx]} as.function(c(gg, expr2)) } Best regards Søren -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: 4. februar 2013 17:31 To: Søren Højsgaard Cc: r-help@r-project.org Subject: Re: [R] Modifying a function programmatically On Mon, Feb 4, 2013 at 5:00 AM, Søren Højsgaard sor...@math.aau.dk wrote: Dear list # I have a function ff - function(a,b=2,c=4){a+b+c} # which I programmatically want to modify to a more specialized function in which a is replaced by 1 ff1 - function(b=2,c=4){1+b+c} This a currying operation. Try: library(functional) ff1 - Curry(ff, a = 1) # test identical(ff1(2, 4), ff(1, 2, 4)) # TRUE -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loading a list into the environment
An often better approach is to use a function like with or within. These allow you to run a command with your list (data frame, environment, etc.) in the first position of the search list so they behave like they are in the global environment (actually better because they temporarily mask rather than overwrite other objects of the same name), but do not clutter up your global environment and/or search list. You can use the attach (and detach) functions, but this is generally not as good as with/within since the variables in your list can still be masked and if you don't clean up after yourself then the search path gets really cluttered (and therefore more masking and related problems). On Fri, Feb 1, 2013 at 3:24 PM, Jonathan Greenberg j...@illinois.eduwrote: R-helpers: Say I have a list: myvariables - list(a=1:10,b=20) Is there a way to load the list components into the environment as variables based on the component names? i.e. by applying this theoretical function to myvariables I would have the variables a and b loaded into the environment without having to explicitly define them. --j -- Jonathan A. Greenberg, PhD Assistant Professor Global Environmental Analysis and Remote Sensing (GEARS) Laboratory Department of Geography and Geographic Information Science University of Illinois at Urbana-Champaign 607 South Mathews Avenue, MC 150 Urbana, IL 61801 Phone: 217-300-1924 http://www.geog.illinois.edu/~jgrn/ AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Banff Canada: Mixed modelling course
There are 8 remaining seats on the following course: Introduction to linear mixed effects modelling and GLMM course. Where: Banff, Canada When: 27-31 May, 2013 For details see the flyer at: http://www.highstat.com/Courses/FlyerCanada2013.pdf or: http://www.highstat.com/statscourse.htm Kind regards, Alain Zuur -- Dr. Alain F. Zuur First author of: 1. Analysing Ecological Data (2007). Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p. URL: www.springer.com/0-387-45967-7 2. Mixed effects models and extensions in ecology with R. (2009). Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer. http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9 3. A Beginner's Guide to R (2009). Zuur, AF, Ieno, EN, Meesters, EHWG. Springer http://www.springer.com/statistics/computational/book/978-0-387-93836-3 4. Zero Inflated Models and Generalized Linear Mixed Models with R. (2012) Zuur, Saveliev, Ieno. http://www.highstat.com/book4.htm Other books: http://www.highstat.com/books.htm Statistical consultancy, courses, data analysis and software Highland Statistics Ltd. 6 Laverock road UK - AB41 6FN Newburgh Tel: 0044 1358 788177 Email: highs...@highstat.com URL: www.highstat.com URL: www.brodgar.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rJava works with 32-bit but not 64
On 2/4/2013 7:03 AM, Simon Urbanek wrote: On Feb 4, 2013, at 10:27 AM, Spencer Graves wrote: On 2/4/2013 5:22 AM, Milan Bouchet-Valat wrote: Le lundi 04 février 2013 à 08:19 -0400, Simon Urbanek a écrit : On Feb 4, 2013, at 6:33 AM, Spencer Graves wrote: On 2/3/2013 11:21 PM, Pascal Oettli wrote: Hello, Do you have a 64-bit version of Java? rJava says to you: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) Simon, have you noticed there seem to be a bug in rJava about the missing 'key' variable? The error message would be (slightly) cleaner if the stop() call succeeded, wouldn't it? ;-) A subtle bug which only appears with the 64-bit but not the 32-bit version ... ? Just a subtle bug in the error message if there is no Java installed (has nothing to do with the architecture). Now fixed. Great. How can I get the new version? [If it were on R-Forge, I could get it via install.packages(rJava, repos=http://R-Forge.R-project.org;).] Thanks, Spencer Cheers, Simon I agree: Thanks very much for your work. Spencer Thanks for your work I think I probably have a 32-bit version and not a 64-bit, because it works with 32-bit R but not 64-bit R. Is it feasible to have both installed in a way that allows the each version of R to select its own version of Java? Yes, that is the default. 32-bit R will only see 32-bit Java and vice versa, because Windows separates 32-bit and 64-bit registries. A comment on stackoverflow suggests that may not be easy (http://stackoverflow.com/questions/5272216/is-it-possible-to-install-both-32bit-and-64bit-java-on-windows-7). Ehm, it says Yes, it is absolutely no problem. -- which part of it suggests it's not easy? SO is a good source of rumors, seldom facts -- but in this case it's not too far from the truth. Cheers, Simon Thanks, Spencer Regards, Pascal Le 04/02/2013 14:27, Spencer Graves a écrit : Hello: rJava works for me under 32-bit but under not 64-bit R; see below. Suggestions? Thanks, Spencer library(rJava) Error : .onLoad failed in loadNamespace() for 'rJava', details: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) error: object 'key' not found Error: package/namespace load failed for 'rJava' sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base ## library(rJava) sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rJava_0.9-3 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Spencer Graves, PE, PhD President and Chief Technology Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 web: www.structuremonitoring.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rJava works with 32-bit but not 64
On Feb 4, 2013, at 7:14 PM, Spencer Graves wrote: On 2/4/2013 7:03 AM, Simon Urbanek wrote: On Feb 4, 2013, at 10:27 AM, Spencer Graves wrote: On 2/4/2013 5:22 AM, Milan Bouchet-Valat wrote: Le lundi 04 février 2013 à 08:19 -0400, Simon Urbanek a écrit : On Feb 4, 2013, at 6:33 AM, Spencer Graves wrote: On 2/3/2013 11:21 PM, Pascal Oettli wrote: Hello, Do you have a 64-bit version of Java? rJava says to you: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) Simon, have you noticed there seem to be a bug in rJava about the missing 'key' variable? The error message would be (slightly) cleaner if the stop() call succeeded, wouldn't it? ;-) A subtle bug which only appears with the 64-bit but not the 32-bit version ... ? Just a subtle bug in the error message if there is no Java installed (has nothing to do with the architecture). Now fixed. Great. How can I get the new version? [If it were on R-Forge, I could get it via install.packages(rJava, repos=http://R-Forge.R-project.org;).] You got it almost right - it's slightly shorter than that: install.packages(rJava,, http://RForge.net;) but you know that if you ever looked at the rJava page ;) Cheers, Simon Thanks, Spencer Cheers, Simon I agree: Thanks very much for your work. Spencer Thanks for your work I think I probably have a 32-bit version and not a 64-bit, because it works with 32-bit R but not 64-bit R. Is it feasible to have both installed in a way that allows the each version of R to select its own version of Java? Yes, that is the default. 32-bit R will only see 32-bit Java and vice versa, because Windows separates 32-bit and 64-bit registries. A comment on stackoverflow suggests that may not be easy (http://stackoverflow.com/questions/5272216/is-it-possible-to-install-both-32bit-and-64bit-java-on-windows-7). Ehm, it says Yes, it is absolutely no problem. -- which part of it suggests it's not easy? SO is a good source of rumors, seldom facts -- but in this case it's not too far from the truth. Cheers, Simon Thanks, Spencer Regards, Pascal Le 04/02/2013 14:27, Spencer Graves a écrit : Hello: rJava works for me under 32-bit but under not 64-bit R; see below. Suggestions? Thanks, Spencer library(rJava) Error : .onLoad failed in loadNamespace() for 'rJava', details: call: stop(No CurrentVersion entry in ', key, '! Try re-installing Java and make sure R and Java have matching architectures.) error: object 'key' not found Error: package/namespace load failed for 'rJava' sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base ## library(rJava) sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rJava_0.9-3 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] download and save all files from FTP site?
What are good ways, within R, to download all files (perhaps including folders/directories?) from an FTP site and then save these files to a local hard drive? Is try(getURL) {RCurl} and save() the best functions to utilize? Any other suggestions? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] download and save all files from FTP site?
Hi Anika, Depending on your definition of within R, you might try system(wget -r URL) HTH, Ista On Mon, Feb 4, 2013 at 7:49 PM, Anika Masters anika.mast...@gmail.com wrote: What are good ways, within R, to download all files (perhaps including folders/directories?) from an FTP site and then save these files to a local hard drive? Is try(getURL) {RCurl} and save() the best functions to utilize? Any other suggestions? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] evaluation clusters
Hello, I was wondering if there is any package with several metrics for cluster estimation (estimating the k=2...10) (or evaluation..). Also if instead of euclidean distance in k-means I use some other kind of distance.. then for those evaluation metrics which takes into consideration the distance (n^2) matrix, i should also use that same distance metric i used for clustering? Or should i always use the euclidean? Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] duplicate data
Hello, I have a long list of x-, y- and z-data and try to generate a heatmap. Obviously there are several data with identical x- and y-values. I get the following error message: Error in interp.old(x, y, z, xo = xo, yo = yo, ncp = 0, extrap = extrap, : duplicate data points: need to set 'duplicate = ..' Unfortunately there seems no help screen on duplicate. I'd prefer to average the z-values in case there are identical x/y-values. Is that possible? If necessary for an answer I'll copy the short script below. Thanks for helping! Richard % #RM¨u 5.2.2013, r.muel...@oeko-sorpe.de require(akima) # Das Paket akima wird ben¨otigt, um # nicht vorhandene Punkte zu interpolieren# und einen sch¨onen Farbgradienten hinzukriegen sorpe - read.csv(bis_130204-korr.csv) pdf(sorpe.pdf)# Es wird nicht auf den Bildschirm gezeichnet, # sondern ein PDF-Dokument erstellt. zr - range(290,220)# Hier wird der Bereich f¨ur die z-Werte# festgelegt: plot(ylim = c(7.9, 8), # Der Bereich der Achsen wird definiert xlim = c(51.30, 51.4), x ~ y, # Es soll ein x-y-Diagramm werden sorpe, # Aufruf der x-, y-, z-Tabelle pch = NA) # Die Punkte f¨ur die x-y-Wertepaare sollen unsichtbar sein (’NA’) sorpe.li - interp(sorpe$x, sorpe$y, sorpe$z) # Hier werden die fehlenden Punkte interpoliert image(sorpe.li, # In das Diagramm wird ein Rasterbild aus den interpolierten Werten gezeichnet zlim = zr, # Der vorher definierte Wertebereich wird aufgerufen col = rev(rainbow( # Ein in R vordefiniertes Farbmodell wird verwendet 30, start = 0, end = 8/12)), # mit 30 Farbabstufungen, die den z-Werten zugeordnet werden. add = TRUE) # Das Bild wird ¨uber das bereits Vorhandene# gezeichnet contour(sorpe.li, # Isohypsen werden eingezeichnet add = TRUE) points(sorpe, # Die urspr¨unglichen Messpunkte werden pch = 1)# eingezeichnet, und zwar als Kreise -- Richard Müller . Am Spring 9 . D-58802 Balve http://www.oeko-sorpe.de - http://www.phytoplankton.info - http://independent.academia.edu/Richard __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] duplicate data
Hello, From ?interp.old duplicate character string indicating how to handle duplicate data points. Possible values are error produces an error message, strip remove duplicate z values, mean,median,user calculate mean , median or user defined function (dupfun) of duplicate z values. HTH, Pascal Le 13/02/05 16:06, Richard Müller a écrit : Hello, I have a long list of x-, y- and z-data and try to generate a heatmap. Obviously there are several data with identical x- and y-values. I get the following error message: Error in interp.old(x, y, z, xo = xo, yo = yo, ncp = 0, extrap = extrap, : duplicate data points: need to set 'duplicate = ..' Unfortunately there seems no help screen on duplicate. I'd prefer to average the z-values in case there are identical x/y-values. Is that possible? If necessary for an answer I'll copy the short script below. Thanks for helping! Richard % #RM¨u 5.2.2013, r.muel...@oeko-sorpe.de require(akima) # Das Paket akima wird ben¨otigt, um # nicht vorhandene Punkte zu interpolieren# und einen sch¨onen Farbgradienten hinzukriegen sorpe - read.csv(bis_130204-korr.csv) pdf(sorpe.pdf) # Es wird nicht auf den Bildschirm gezeichnet, # sondern ein PDF-Dokument erstellt. zr - range(290,220) # Hier wird der Bereich f¨ur die z-Werte# festgelegt: plot(ylim = c(7.9, 8), # Der Bereich der Achsen wird definiert xlim = c(51.30, 51.4), x ~ y, # Es soll ein x-y-Diagramm werden sorpe, # Aufruf der x-, y-, z-Tabelle pch = NA) # Die Punkte f¨ur die x-y-Wertepaare sollen unsichtbar sein (’NA’) sorpe.li - interp(sorpe$x, sorpe$y, sorpe$z) # Hier werden die fehlenden Punkte interpoliert image(sorpe.li, # In das Diagramm wird ein Rasterbild aus den interpolierten Werten gezeichnet zlim = zr, # Der vorher definierte Wertebereich wird aufgerufen col = rev(rainbow( # Ein in R vordefiniertes Farbmodell wird verwendet 30, start = 0, end = 8/12)), # mit 30 Farbabstufungen, die den z-Werten zugeordnet werden. add = TRUE) # Das Bild wird ¨uber das bereits Vorhandene# gezeichnet contour(sorpe.li, # Isohypsen werden eingezeichnet add = TRUE) points(sorpe, # Die urspr¨unglichen Messpunkte werden pch = 1)# eingezeichnet, und zwar als Kreise __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.