Re: [R] Fw: PROBLEM - - COMPARING AND COMBINING two DATASETS
Dear Sir,  Thanks a lot for your solution and guidance. It worked wonderfully.  Regards  Maithili --- On Thu, 27/8/09, Gabor Grothendieck ggrothendi...@gmail.com wrote: From: Gabor Grothendieck ggrothendi...@gmail.com Subject: Re: [R] Fw: PROBLEM - - COMPARING AND COMBINING two DATASETS To: Maithili Shiva maithili_sh...@yahoo.com Cc: r-help@r-project.org Date: Thursday, 27 August, 2009, 2:09 PM Try this: xtabs(B ~ factor(A, seq(max(A On Thu, Aug 27, 2009 at 8:26 AM, Maithili Shivamaithili_sh...@yahoo.com wrote: Dear Sirs, At the outset I sincerely apologize for reproducing my query to you. I also thank all of you for the solution you had provided. It has worked on the actual data I am working with. However, there is this peculiar problem which I had realized only after I had obtained my results. e.g. in the example I had attached A - c(2, 2, 1, 3, 7, 3, 3, 1, 14, 7, 31) B - c(0.0728,0.9538,4.0140,0.0020,2.5593,0.1620,2.513,0.3798, .0033,0..2282, 0.1614) tapply( B, A, sum) I get R output as â  1         2        3          7          14        31 4.3938  1.0266  2.6770   2.7875   0.0033   0.1614 However, my requirement is I should get the output as 1          2         3        4  5  6  7        8  9 â¦. 14 â¦â¦â¦..31 4.3938 1.0266  2.6770   0  0  0  2.7875  0  0 ..0.0033 .. 0.161 i.e. my output should include the values 4, 5, 6, etc. which are not part of dataset A and the corresponding totals in B (which are anyways 0âs). I need this for my further analysis. Its possible for me to add these 0âs manually, however when the dataset is large, its not practical. I am attaching herewith an excel file. I will be grateful if you can guide me. Thanks in advance Maithili start: 2009-08-18 end: -00-00 Thinking of ordering food? Find restaurant numbers on Yahoo! India Local    Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.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. Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.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] Best R text editors?
On 8/27/09, Jonathan Greenberg greenb...@ucdavis.edu wrote: Quick informal poll: what is everyone's favorite text editor for working with R? I'd like to hear from people who are using editors that have some level of direct R interface (e.g. Tinn-R, Komodo+SciViews). Thanks! JGR __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Best R text editors?
On Thu, 27 Aug 2009 12:43:41 -0700 Jonathan Greenberg greenb...@ucdavis.edu wrote: JG Quick informal poll: what is everyone's favorite text editor for JG working with R? I'd like to hear from people who are using editors JG that have some level of direct R interface (e.g. Tinn-R, JG Komodo+SciViews). Thanks! By my personal preference: Windows 1. Tinn-R 2. Notepad+ with npptor 3. JGR Linux 1. Rkward 2. Emacs+ESS (JGR useless here since it consumes 100% CPU at least with Fedora Linux) Cheers Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Best R text editors?
On 8/28/09, Stefan Grosse singularit...@gmx.net wrote: (JGR useless here since it consumes 100% CPU at least with Fedora Linux) The quick fix is to access Help About after the splash screen disappears at start-up. This works on Debian and Ubuntu. Liviu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Best R text editors?
Eclipse + StatET (the R plugin) both on Linux and Windows On Thursday 27 August 2009 20:43:41 Jonathan Greenberg wrote: Quick informal poll: what is everyone's favorite text editor for working with R? I'd like to hear from people who are using editors that have some level of direct R interface (e.g. Tinn-R, Komodo+SciViews). Thanks! --j -- Corrado Topi Global Climate Change Biodiversity Indicators Area 18,Department of Biology University of York, York, YO10 5YW, UK Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 plotting with ggplot2
Hi, Have you checked that you have the latest version of ggplot2 and plyr? Please post your sessionInfo() HTH, baptiste 2009/8/28 romunov romu...@gmail.com Dear R-Help subsribers, upon running into a wonderful ggplot2 package by accident, I abruptly encountered another problem. Almost every command run with ggplot2 results in some sort of error. The one below is far the most common one. Kind people from ggplot2 mailing list couldn't manage to solve the problem, so I'm re-posting it here to try my luck. I will recommend myself for any tips on how to solve this, as I would really benefit from using this package. head(cebelice) time c2 1 00:00 0 2 00:15 0 3 00:30 0 4 00:45 0 5 01:00 0 6 01:15 0 dim(cebelice) [1] 96 2 ggplot(cebelice, aes(x=time, y=c2)) + geom_histogram() Error in all.vars(as.formula(.$facets)) : could not find function as.formula This is straight from ggplot2 sample page for barplots: c - ggplot(mtcars, aes(factor(cyl))) c + geom_bar() Error in get(transform, env = ., inherits = TRUE)(., ...) : attempt to apply non-function Sincerely yours, Roman [[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. -- _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK http://newton.ex.ac.uk/research/emag __ [[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] Has any one tested R 2.9.2 on Snow Leopard?
Hi all, not sure if this is the right place to ask this but R not being such a mainstream app, can't find the answer anywhere. I plan to upgrade to Snow asap and just wondering if anyone else has already and has successfully used R on Mac OSX 10.6. If so, what version? and is it running in 64 bit mode? Thanks in advance, George. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Panel Data Analysis (PLM) - Fixed Effects - cannot allocate vector of length
Hello Peter. Sorry, I was on vacation. I hope my answer is still of some use to you. Strictly speaking, this is not a 'plm' problem. As you guessed, you're hitting memory limits in R. See ??memory and more specifically ?Memory ?Memory-limits to see whether you can increase them. Re 'plm' functions, it is possible that we used an inefficient solution here, and that the code be made more efficient in the future. We'll keep this on our list and see if we ever come up with a better memory management for 2-way FEs. The problem actually never surfaced because people seldom estimate models with so many FEs: actually, with such big samples, the independent sampling assumptions underlying RE estimators often look plausible. HTH, Giovanni Giovanni Millo Research Dept., Assicurazioni Generali SpA Via Machiavelli 4, 34132 Trieste (Italy) tel. +39 040 671184 fax +39 040 671160 -- Original message: Date: Fri, 21 Aug 2009 16:36:24 -0400 From: Peter Steele-Mosey pete...@gmail.com Subject: [R] Panel Data Analysis (PLM) - Fixed Effects - cannot allocatevector of length To: r-help@r-project.org Message-ID: e68753d70908211336t25d2fac6k2cefe8aa0b38a...@mail.gmail.com Content-Type: text/plain Hello to all on the list, I'm trying to estimate a fixed effects model from a large (unbalanced) panel data set. I have no problems when using only an individual effect or only a time effect, but I get an error message when I try for a twoways effect. Here is some of the code: paneldata27 is the entire panel data set: dim(paneldata27) [1] 1178831 8 paneldata27-plm.data(paneldata27,index=c(Account,Day.of.Sample)) nlevels(paneldata27$Account) [1] 1573 nlevels(paneldata27$Day.of.Sample) [1] 831 That is there will be 1573 individual effects and 831 time effects. paneldata27.fe-plm(LnMidpeak~DUM1,data=paneldata27,model=within,effec t=twoways) Error in model.matrix.default(~id - 1) : cannot allocate vector of length 1854301163 Is my panel data set just too large for R? Thanks very much in advance, Peter Steele-Mosey Giovanni Millo Research Dept., Assicurazioni Generali SpA Via Machiavelli 4, 34132 Trieste (Italy) tel. +39 040 671184 fax +39 040 671160 Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:13}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Best R text editors?
Hi! Corrado wrote: Eclipse + StatET (the R plugin) both on Linux and Windows Please, does it work with Eclipse 3.5 Galileo on a Mac OS X (10.5.8) box? Thanks! -- Ricardo Rodríguez Your XEN ICT Team __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Has any one tested R 2.9.2 on Snow Leopard?
Hi! Jorgy Porgee wrote: Hi all, not sure if this is the right place to ask this but R not being such a mainstream app, can't find the answer anywhere. I plan to upgrade to Snow asap and just wondering if anyone else has already and has successfully used R on Mac OSX 10.6. If so, what version? and is it running in 64 bit mode? This question is better intended to RsigMAC list. From an open thread there... http://snowleopard.wikidot.com/ R 2.9.2 is now listed as OK. HTH, Ricardo -- Ricardo Rodríguez Your XEN ICT Team __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Labeling and calculating distance from points
Hi all Can you help me label the points Si' s accordingly with subscripts, also to write a distance on between location S0 (0.5,0.5 ) and all order points Si lines if i have this kind of code: library(geoR) coords-matrix(c(0,0,1,1,0,1,0,1), nrow=4, ncol=2) data-c(3,5,6,4) coordata-data.frame(coords=coords,data=data) geo-as.geodata(coordata) plot(geo$coords, xlim = c(0, 1.2), ylim = c(0,1.2), xlab = X-axis, ylab = Y-axis) locations- matrix(c(0.5, 0.5), ncol = 2) text(locations, as.character(0), col = red) polygon(x = c(0, 1, 1, 0), y = c(0, 0, 1, 1),lty = 2) szero- krige.conv(geo, locations=locations, krige=krige.control(cov.pars=c(1,1))) [[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] Best R text editors?
I am using 3.4.2 not 3.5, I would not know. But it is worth visiting the STATET mailing list archive and subscribe to the mailing list. On Friday 28 August 2009 09:22:14 [Ricardo Rodriguez] Your XEN ICT Team wrote: Hi! Corrado wrote: Eclipse + StatET (the R plugin) both on Linux and Windows Please, does it work with Eclipse 3.5 Galileo on a Mac OS X (10.5.8) box? Thanks! -- Corrado Topi Global Climate Change Biodiversity Indicators Area 18,Department of Biology University of York, York, YO10 5YW, UK Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Best R text editors?
Thanks, Corrado. Corrado wrote: I am using 3.4.2 not 3.5, I would not know. But it is worth visiting the STATET mailing list archive and subscribe to the mailing list. FYI, here the available public testing version for Eclipse 3.5 http://lists.r-forge.r-project.org/pipermail/statet-user/2009-August/000187.html Greetings, Ricardo -- Ricardo Rodríguez Your XEN ICT Team __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using Test functions in Wavelet
Hi R users I thankfull all R users for helping each other. Could some one help me to define data set for the following test functions: Step, Wave, Blip, Angles, Parabolas for example , doppler function I can write dopp(n) to get data set of size n What about the functions mentioned above? [[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] regexp help needed.
Hi, I posted yesterday with a problem in a script. I still have the same problem, but I think I found a better way to explain my problem. I have a vector of character strings. Each string is unique, including numbers and letters. In the real world they represent a list of codes, so each position in the string has a meaning to me. I want to make a subset of the vector using wildcards. So for example, take all the strings that start with 3. Any ideas how to do that? Thanks for any help. [[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] breaking multi-modal histograms down into combinations of unimodal distributions
Dear All, Does anybody know if there is a functionality in R to break histograms that show a clear bi-modal (or multi-modal) distribution into a series of unimodal histograms that added up result in the original histogram? I was thinking of using QQ-plots (for which tools are available in R), and then observing the number of times the observed quantiles cross the 1:1 line, but this only gives an indication of how many peaks the current histogram has. Therefore I was wondering whether other approaches exist. Thanks in advance for any suggestions. p.s. also thanks to those who helped me on my previous question on Modelling different combinations of explanatory variables. The leaps package and the regsubsets command worked really well! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Regarding NaN output in sets package
Hi! I have built a program for fuzzy inference using the sets package. Though there are no errors after defuzzifying using gset_defuzzify() command, the output after using the centroid option is a NaN. What may be going wrong here? P.S: There are just 10 dependent factors and just five rules. All the membership function are Gaussian. Any help is appreciated. Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Best R text editors?
I'm using Emacs+ESS on Linux and OS X. Of course, since I use Emacs for pretty much everything it was an easy choice. :) -Bjorn 2009/8/27 Jonathan Greenberg greenb...@ucdavis.edu: Quick informal poll: what is everyone's favorite text editor for working with R? I'd like to hear from people who are using editors that have some level of direct R interface (e.g. Tinn-R, Komodo+SciViews). Thanks! --j -- Jonathan A. Greenberg, PhD Postdoctoral Scholar Center for Spatial Technologies and Remote Sensing (CSTARS) University of California, Davis One Shields Avenue The Barn, Room 250N Davis, CA 95616 Cell: 415-794-5043 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Best R text editors?
On 08/27/2009 09:43 PM, Jonathan Greenberg wrote: Quick informal poll: what is everyone's favorite text editor for working with R? I'd like to hear from people who are using editors that have some level of direct R interface (e.g. Tinn-R, Komodo+SciViews). Thanks! --j This wiki page is set to deal with the question, but not yet used that much. Maybe people replying to this thread could contribute to the wiki page as well. http://wiki.r-project.org/rwiki/doku.php?id=guis:projects Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/w33B : Completion for java objects |- http://tr.im/vzip : Code Snippet : List of CRAN packages `- http://tr.im/vsK1 : R parser package on CRAN __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] delete duplicated conditional
Hi, have anybody a hint, how i could keep the duplicated with a condition in a second column, i.e. maximum in column 620. nodups - apos[!duplicated(apos[,1]),c(1,620)] many thanks Christian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting to stdout
Philipp Pagel p.pagel at wzw.tum.de writes: On Wed, Aug 26, 2009 at 07:53:57PM +, Oliver Bandel wrote: is there a way to write the result of a plot to stdout? I mean even a binary thingy like a png-file, written to stdout?! I tried with the file-argument of png() and jpeg(), but did not get working results. I don't think you can do that. But if you could elaborate on your ultimate goal, perhaps someone can provide an alternative solution. [...] The goal was to produce a picture in a web-environment. At the moment rpy2 will be used maybe there are way to achieve something like that in this way, but I'm also new to rpy2. When the graphic could be written to stdout, the calling environment could reead it from the forked process. But maybe rpy2 works different. Any ideas on that on-the-fly creation of pictures? If there would be no temporary files this would be fine. That's the reason why I looked for stdout as output channel. Ciao, Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] breaking multi-modal histograms down into combinations o
On 28-Aug-09 10:34:46, Thomas Groen wrote: Dear All, Does anybody know if there is a functionality in R to break histograms that show a clear bi-modal (or multi-modal) distribution into a series of unimodal histograms that added up result in the original histogram? I was thinking of using QQ-plots (for which tools are available in R), and then observing the number of times the observed quantiles cross the 1:1 line, but this only gives an indication of how many peaks the current histogram has. Therefore I was wondering whether other approaches exist. Thanks in advance for any suggestions. p.s. also thanks to those who helped me on my previous question on Modelling different combinations of explanatory variables. The leaps package and the regsubsets command worked really well! There are a number of points of information which would help us to be more specific about suggestions. 1: Do you have the raw data from which the histogram was constructed? Decomposition of a multimodal sample into constituent unimodal components is best done by adopting a generic distirbution type (e.g. Normal) for each component, and then estimating the paramaters of each component from the data. There is more information (and there better estimation) in the raw data than in the histogram. 2: Do you have a preferred generic distribution type (e.g. Normal) for the component distributions? (If not, and you don't care what distribution you adopt, then what is to stop you drawing arbitary dividing lines between the peaks, and asserting that what lies between two consecutive divisions is one component of the mixture? Then you would end up with a set of disjoint histograms, one for each component, chosen in a somewhat arbitrary way. Since you presumably don't intend that to happen, you presumably have reasons why it should not happen which would amount to a preference for generic distribution type). Once the generic type is chosen, a specific method is indicated. For example, do an R Site Search on normal mixture in Functions at: http://finzi.psych.upenn.edu/nmz.html You may want to look at http://finzi.psych.upenn.edu/R/library/mclust/html/00Index.html (Model-Based Clustering / Normal Mixture Modeling). Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 28-Aug-09 Time: 12:12:36 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting to stdout
On Fri, Aug 28, 2009 at 1:06 PM, Oliver Bandeloli...@first.in-berlin.de wrote: [...] The goal was to produce a picture in a web-environment. At the moment rpy2 will be used maybe there are way to achieve something like that in this way, but I'm also new to rpy2. When the graphic could be written to stdout, the calling environment could reead it from the forked process. But maybe rpy2 works different. Any ideas on that on-the-fly creation of pictures? If there would be no temporary files this would be fine. That's the reason why I looked for stdout as output channel. Oliver, I have a similar problem and had a similar question on the list about a week ago all I could find out that some devices of the Cairo package are supposed to support plotting to R connections (including stdout), but it does not work in practice: library(Cairo) tc - textConnection(foo, w) CairoPNG(file=tc) Error in Cairo(width, height, type = png, file = filename, pointsize = pointsize, : file must be a filename. to support writing to a connection, recompile R and Cairo with the R Connection Patch. Information on the R connection Patch is welcome. Recompiling R and Cairo is not a problem for me, I am putting together a special environment anyway. Best, Gabor [...] -- Gabor Csardi gabor.csa...@unil.ch UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Plotting to stdout
On 08/28/2009 01:16 PM, Gábor Csárdi wrote: On Fri, Aug 28, 2009 at 1:06 PM, Oliver Bandeloli...@first.in-berlin.de wrote: [...] The goal was to produce a picture in a web-environment. At the moment rpy2 will be used maybe there are way to achieve something like that in this way, but I'm also new to rpy2. When the graphic could be written to stdout, the calling environment could reead it from the forked process. But maybe rpy2 works different. Any ideas on that on-the-fly creation of pictures? If there would be no temporary files this would be fine. That's the reason why I looked for stdout as output channel. Oliver, I have a similar problem and had a similar question on the list about a week ago all I could find out that some devices of the Cairo package are supposed to support plotting to R connections (including stdout), but it does not work in practice: library(Cairo) tc- textConnection(foo, w) CairoPNG(file=tc) Error in Cairo(width, height, type = png, file = filename, pointsize = pointsize, : file must be a filename. to support writing to a connection, recompile R and Cairo with the R Connection Patch. Information on the R connection Patch is welcome. Recompiling R and Cairo is not a problem for me, I am putting together a special environment anyway. Best, Gabor [...] This is a patch that was offered by Jeff Horner some time ago ; http://tolstoy.newcastle.edu.au/R/e2/devel/06/10/0565.html http://wiki.r-project.org/rwiki/doku.php?id=developers:r_connections_api The patch allows packages to exploit the connection api from the C level, a privilege that still remains internal to R. Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/xkMc : Combine R CMD build and junit |- http://tr.im/w33B : Completion for java objects `- http://tr.im/vzip : Code Snippet : List of CRAN 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] Plotting to stdout
On Fri, Aug 28, 2009 at 7:16 AM, Gábor Csárdicsa...@rmki.kfki.hu wrote: On Fri, Aug 28, 2009 at 1:06 PM, Oliver Bandeloli...@first.in-berlin.de wrote: [...] The goal was to produce a picture in a web-environment. At the moment rpy2 will be used maybe there are way to achieve something like that in this way, but I'm also new to rpy2. When the graphic could be written to stdout, the calling environment could reead it from the forked process. But maybe rpy2 works different. Any ideas on that on-the-fly creation of pictures? If there would be no temporary files this would be fine. That's the reason why I looked for stdout as output channel. Oliver, I have a similar problem and had a similar question on the list about a week ago all I could find out that some devices of the Cairo package are supposed to support plotting to R connections (including stdout), but it does not work in practice: library(Cairo) tc - textConnection(foo, w) CairoPNG(file=tc) Error in Cairo(width, height, type = png, file = filename, pointsize = pointsize, : file must be a filename. to support writing to a connection, recompile R and Cairo with the R Connection Patch. Information on the R connection Patch is welcome. Recompiling R and Cairo is not a problem for me, I am putting together a special environment anyway. Best, Gabor [...] I could have used this functionality in a previous project as well; however, for Oliver's application just pass the filename to the python program use that in the img src=... tag (or have the python program pass the filename to the R program). If there is some aspect of this problem that has not been explained that truly does make passing the graphic file contents to the python program desirable then have R write out the graphic file and then have R read it back in. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] delete duplicated conditional
i get it. aposSorted - apos[order(apos[,620],decreasing=TRUE),] nodups - aposSorted[!duplicated(aposSorted[,1]),c(1,620)] Hi, have anybody a hint, how i could keep the duplicated with a condition in a second column, i.e. maximum in column 620. nodups - apos[!duplicated(apos[,1]),c(1,620)] many thanks Christian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] regexp help needed.
See this example: Str - c(345asd, 31qwe, 234tyu, 40kjhg) grep(^3, Str, value = TRUE) split(Str, substr(Str, 1, 1)) On Fri, Aug 28, 2009 at 7:29 AM, Carlos Gonzalo Merino Mendez carlosgmer...@yahoo.com wrote: Hi, I posted yesterday with a problem in a script. I still have the same problem, but I think I found a better way to explain my problem. I have a vector of character strings. Each string is unique, including numbers and letters. In the real world they represent a list of codes, so each position in the string has a meaning to me. I want to make a subset of the vector using wildcards. So for example, take all the strings that start with 3. Any ideas how to do that? Thanks for any help. [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] Plotting to stdout
On Fri, Aug 28, 2009 at 1:33 PM, Gabor Grothendieckggrothendi...@gmail.com wrote: [...] I could have used this functionality in a previous project as well; however, for Oliver's application just pass the filename to the python program use that in the img src=... tag (or have the python program pass the filename to the R program). If there is some aspect of this problem that has not been explained that truly does make passing the graphic file contents to the python program desirable then have R write out the graphic file and then have R read it back in. Unfortunately, this is not always a good solution. For example, I am running Rserve with connections from untrusted users. The Rserve process is not allowed to write to the disk at all, but then there is no easy way to create plots. The patch Romain mentioned above looks like a good solution. Gabor -- Gabor Csardi gabor.csa...@unil.ch UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Plotting to stdout
On 08/28/2009 01:47 PM, Gábor Csárdi wrote: On Fri, Aug 28, 2009 at 1:33 PM, Gabor Grothendieckggrothendi...@gmail.com wrote: [...] I could have used this functionality in a previous project as well; however, for Oliver's application just pass the filename to the python program use that in theimg src=... tag (or have the python program pass the filename to the R program). If there is some aspect of this problem that has not been explained that truly does make passing the graphic file contents to the python program desirable then have R write out the graphic file and then have R read it back in. Unfortunately, this is not always a good solution. For example, I am running Rserve with connections from untrusted users. The Rserve process is not allowed to write to the disk at all, but then there is no easy way to create plots. The patch Romain mentioned above looks like a good solution. Gabor There is also the xGD package: http://www.rforge.net/xGD/ Instead of writing to a file, R drawing commands are sent to a TCP/IP socket. There is an example of a java graphics server which you can use to render the graph. I would still like to have some connections API at the c level, for this and other things ... Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/xkMc : Combine R CMD build and junit |- http://tr.im/w33B : Completion for java objects `- http://tr.im/vzip : Code Snippet : List of CRAN 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.
[R] How to generate mean anova value row in anova table, instead of individual value for each predictor
Hi All , Can anybody tell me if there's any way to get the summarized anova values.Now i will explain what i mean , when i say *summarized*. Below you can see the anova table of recmeanC1 with rest* all* i.e from recmeanC2 to i15(predictors),as shown in table. Df Sum SquaresMean Square F valueSignificance [Pr(F)] recmeanC21 89.272 89.272 1.50E+34 2e-16 *** recmeanC31 9.965 9.965 1.68E+33 2e-16 *** recmeanC41 2.61 2.61 4.40E+32 2e-16 *** i1 1 25.341 25.341 4.27E+33 2e-16 *** i2 1 0.118 0.118 1.98E+31 2e-16 *** i3 1 0.022 0.022 3.65E+30 2e-16 *** i4 1 0.164 0.164 2.75E+31 2e-16 *** i5 1 15.639 15.639 2.63E+33 2e-16 *** i6 1 1.64E-34 1.64E-34 2.76E-02 0.86812 i7 1 1.72E-33 1.72E-33 2.89E-01 0.59112 i8 1 9.29E-34 9.29E-34 1.57E-01 0.69273 i9 1 6.38E-33 6.38E-33 1.07E+00 0.30092 i10 1 1.02E-32 1.02E-32 1.71E+00 0.19166 i12 1 2.25E-33 2.25E-33 3.80E-01 0.53831 i13 1 2.13E-32 2.13E-32 3.5885e+00 0.53831 0.53831 Regression 15 1.43E+02 9.54E+00 1.61E+33 2.2e-16 Residuals 276 1.64E-30 5.94E-33 Total 291 1.43E+02 Instead of the values in the rows from reacmeanC1 to i15...what i want is a summarized value ,what the row named *Regression* shows.I do not get anything like the row Regression.I copied that to show that SPSS has way to generate that.though Residuals row is generated in R just like SPSS. I know the how to calculate a single summarized Df,Sum Sq,Mean Sq,F value,Pr(F) with these formulae:--- *That is instead of all the 15 rows from reacmeanC1 to i15 i want row Regresssion* Df Sum Sq Mean SqF value Regression Calculations sum of all the above dfs sum of all the above Sum of Squares Sum of Squares/df Mean Square due to Regression/Mean Square due to Residuals But isn't there any function in R to get what i explained above in a much easier way? -- Thanks in advance Moumita [[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 with glmer {lme4} function: how to return F or t statistics instead of z statistics?
Hi, I'm new to R and GLMMs, and I've been unable to find the answers to my questions by trawling through the R help archives. I'm hoping someone here can help me. I'm running an analysis on Seedling survival (count data=Poisson distribution) on restoration sites, and my main interest is in determining whether the Nutrients (N) and water absorbing polymer Gel (G) additions to the soil substrate contribute positively to the survival of the seedlings, over a 3 year time period (for simplicity I'm just using 3 time periods, each in the same season for the 3 successive years). Fixed factors: Nutrients (0 and 1), Gel (0 and 1) Random factors: Site (4 non replicate sites), Year (3 time periods) Response variable: Seedling numbers (counts) / 0.25m2 plot According to the decision tree on page 131 in Bolker et al. (2008, in TREE; thanks, very useful paper!), most of my data sets should be analysed with Laplace or GHQ model with Wald t or F statistic (since it is non-normal, can’t be transformed to normality, has a mean 5, has less than 3 random effects, and is overdispersed). I’m using the glmer {lme4} function, since it allows for Laplace or GHQ, as well as more than one random factor (glmmML {glmmML) and glmPQL {MASS} apparently does not), as follows: m1-glmer(Seedlings~N*G*(1|Year)*(1|Site), data=ex5m, family=poisson(link=log)) My questions are: 1) The model returns Z values, and I’m unable to find an argument in the function where this can be changed to return a t or F value (as Bolker et al. suggests I should use for my data). 2) I’m unsure what the AIC or QAIC value means, other than knowing that it should be as low as possible. Is there a rule of thumb of what is a good AIC value? Mine are in the region of 2230. 3) The default in glmer {lme4) for the argument nAGQ = 1, which uses the Laplace approximation. When nAGQ 1, it uses the GHQ method, but I’m unsure how to determine the correct number of Gauss-Hermite points to enter in the argument when using this method. How is this determined? 4) Some of my data sets have means 5, and are also overdispersed, and according to Bolker et al. should be analysed using a GLMM with PQL and a Wald t or F. However, the glmmPQL {glmmPQL} does not accept more than one random factor, and I have two, so how do I deal with that? 5) Lastly, what does the 1 imply in the random factor term, e.g. (1|Site), and how does this affect the analysis? Many thanks, Raldo Kruger MSc student University of Cape Town South Africa -- Raldo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] setting par(srt) according to plot aspect ratio
On Fri, Aug 28, 2009 at 1:48 AM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote: Note that the aspect ratio changes when you resize the plot but the angle of the plotted text will not. So the only safe route is to set 'asp' and use that setting to select the angle. That is true with screen output, although I can run the code block again after re-sizing to correct the text angle along with the aspect ratio. And for my purpose which is writing to file, it isn't an issue, for example the following plots which need different aspect ratios all work correctly: png(example%d.png) makeplot() #as per example code par(mfrow=c(2,1)) makeplot() makeplot() par(mfrow=c(1,2)) makeplot() makeplot() dev.off() -- Levi Waldron post-doctoral fellow Jurisica Lab, Ontario Cancer Institute Division of Signaling Biology TMDT 9-304D 101 College Street Toronto, Ontario M5G 1L7 (416)581-7453 [[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] Best R text editors?
I've only really used Tinn-R but so far I am very happy with it. --- On Thu, 8/27/09, Jonathan Greenberg greenb...@ucdavis.edu wrote: From: Jonathan Greenberg greenb...@ucdavis.edu Subject: [R] Best R text editors? To: r-help r-help@r-project.org Received: Thursday, August 27, 2009, 3:43 PM Quick informal poll: what is everyone's favorite text editor for working with R? I'd like to hear from people who are using editors that have some level of direct R interface (e.g. Tinn-R, Komodo+SciViews). Thanks! --j -- Jonathan A. Greenberg, PhD Postdoctoral Scholar Center for Spatial Technologies and Remote Sensing (CSTARS) University of California, Davis One Shields Avenue The Barn, Room 250N Davis, CA 95616 Cell: 415-794-5043 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Best R text editors?
Jonathan Greenberg wrote: Quick informal poll: what is everyone's favorite text editor for working with R? Emacs+ESS __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not that surprising since Python is also one of the main languages used by Google. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] regexp help needed.
Thanks, this what I was looking for. From: Henrique Dallazuanna www...@gmail.com Cc: r-help@r-project.org Sent: Friday, August 28, 2009 1:42:25 PM Subject: Re: [R] regexp help needed. See this example: Str - c(345asd, 31qwe, 234tyu, 40kjhg) grep(^3, Str, value = TRUE) split(Str, substr(Str, 1, 1)) On Fri, Aug 28, 2009 at 7:29 AM, Carlos Gonzalo Merino Mendez carlosgmerin Hi, I posted yesterday with a problem in a script. I still have the same problem, but I think I found a better way to explain my problem. I have a vector of character strings. Each string is unique, including numbers and letters. In the real world they represent a list of codes, so each position in the string has a meaning to me. I want to make a subset of the vector using wildcards. So for example, take all the strings that start with 3. Any ideas how to do that? Thanks for any help. [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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] Best R text editors?
Tinn-R Petr r-help-boun...@r-project.org napsal dne 28.08.2009 09:16:38: On Thu, 27 Aug 2009 12:43:41 -0700 Jonathan Greenberg greenb...@ucdavis.edu wrote: JG Quick informal poll: what is everyone's favorite text editor for JG working with R? I'd like to hear from people who are using editors JG that have some level of direct R interface (e.g. Tinn-R, JG Komodo+SciViews). Thanks! By my personal preference: Windows 1. Tinn-R 2. Notepad+ with npptor 3. JGR Linux 1. Rkward 2. Emacs+ESS (JGR useless here since it consumes 100% CPU at least with Fedora Linux) Cheers Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? The recommendation of variable.name over variable_name or variableName is contentious (to say the least) because of the clash with S3 method conventions. The ESS convention of single, double and triple # comments needs at least to be mentioned. Otherwise, unsuspecting programmers will be driven up the wall when coding or editing in Emacs. Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not that surprising since Python is also one of the main languages used by Google. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
On 8/28/2009 8:59 AM, Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? The rules are mostly reasonable, though they aren't the ones followed in the R source. One bad rule is the one on curly braces: An opening curly brace should never go on its own line; a closing curly brace should always go on its own line. The problem is the second part. If the closing brace is followed by an else clause, the else should go on the same line as the brace, or things will parse differently when pasted than they do in a function. For example, this follows their style to the letter: f - function() { if (TRUE) { cat(TRUE!!\n) } else { cat(FALSE!!\n) } } and it works as intended, but if you cut and paste the lines in the body (starting with if (TRUE)), the else clause will be a syntax error. If it had been formatted as f - function() { if (TRUE) { cat(TRUE!!\n) } else { cat(FALSE!!\n) } } it would work even when cut and pasted. Duncan Murdoch Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not that surprising since Python is also one of the main languages used by Google. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
On 28-Aug-09 12:59:24, Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not that surprising since Python is also one of the main languages used by Google. I think it is grossly over-prescriptive. For example: function names have initial capital letters and no dots is violated throughout R itself. Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 28-Aug-09 Time: 14:21:58 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] CHAID in R
Hi..I am trying to run CHAID in R..I have installed the sofyware Party and trying to use the function ctree() to carry out the analysis. but I am getting the following message Error in terms.default(formula, data = data) : no terms component . I am having some Likert scale variable where I have variables like Overall satisfaction(Dependent Variable),Product quality, Brand image,Warranty(Independent variable) etc.. Now can anyone tell me how to run CHAID in this case..what would be the formula? Thanks in Advance.. -- View this message in context: http://www.nabble.com/CHAID-in-R-tp25188573p25188573.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with glmer {lme4) function: how to return F or t statistics instead of z statistics.
Hi, I'm new to R and GLMMs, and I've been unable to find the answers to my questions by trawling through the R help archives. I'm hoping someone here can help me. I'm running an analysis on Seedling survival (count data=Poisson distribution) on restoration sites, and my main interest is in determining whether the Nutrients (N) and water absorbing polymer Gel (G) additions to the soil substrate contribute positively to the survival of the seedlings, over a 3 year time period (for simplicity I'm just using 3 time periods, each in the same season for the 3 successive years). Fixed factors: Nutrients (0 and 1), Gel (0 and 1) Random factors: Site (4 non replicate sites), Year (3 time periods) Response variable: Seedling numbers (counts) / 0.25m2 plot According to the decision tree on page 131 in Bolker et al. (2008, in TREE; thanks, very useful paper!), most of my data sets should be analysed with Laplace or GHQ model with Wald t or F statistic (since it is non-normal, can’t be transformed to normality, has a mean 5, has less than 3 random effects, and is overdispersed). I’m using the glmer {lme4} function, since it allows for Laplace or GHQ, as well as more than one random factor (glmmML {glmmML) and glmPQL {MASS} apparently does not), as follows: m1-glmer(Seedlings~N*G*(1|Year)*(1|Site), data=ex5m, family=poisson(link=log)) My questions are: 1) The model returns Z values, and I’m unable to find an argument in the function where this can be changed to return a t or F value (as Bolker et al. suggests I should use for my data). 2) I’m unsure what the AIC or QAIC value means, other than knowing that it should be as low as possible. Is there a rule of thumb of what is a good AIC value? Mine are in the region of 2230. 3) The default in glmer {lme4) for the argument nAGQ = 1, which uses the Laplace approximation. When nAGQ 1, it uses the GHQ method, but I’m unsure how to determine the correct number of Gauss-Hermite points to enter in the argument when using this method. How is this determined? 4) Some of my data sets have means 5, and are also overdispersed, and according to Bolker et al. should be analysed using a GLMM with PQL and a Wald t or F. However, the glmmPQL {glmmPQL} does not accept more than one random factor, and I have two, so how do I deal with that? 5) Lastly, what does the 1 imply in the random factor term, e.g. (1|Site), and how does this affect the analysis? Many thanks, Raldo Kruger MSc student University of Cape Town South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
On 8/28/2009 9:22 AM, (Ted Harding) wrote: On 28-Aug-09 12:59:24, Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not that surprising since Python is also one of the main languages used by Google. I think it is grossly over-prescriptive. For example: function names have initial capital letters and no dots is violated throughout R itself. That is a style guide for code written within Google, it's not a general rule for the rest of us. Internal style guides need to be prescriptive. R itself is very inconsistent, and would be easier to use if it were more consistent. (For example, I can never remember the function name system.time, because we also have Sys.time, sys.parent, various names with underscores and with no punctuation, etc.) Unfortunately, it's too late to change these now. Since R has very few function names starting with capital letters, Google's choice is probably good: it makes it easier when reading someone else's code to know whether the function is one they wrote, or one coming from R. (I use a similar rule when writing LaTeX macros: mine usually begin with capital letters, because the standard ones almost never do.) 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.
[R] RPostgreSQL libpq problem
Dear all, I am stuck trying to get RPostgreSQL running on my Mac. PostgreSQL itself does work fine as it is able to connect with various other apps. Unfortunately the RPostgreSQL package is not available as a binary for MAC OS. Thus I´ve been trying to compile the source for quite some time now - unfortunately without success (or at least very limited success). First, running ./configure respectively running the installation directly via R was not able to find the header file libpq-fe.h. after I changed PG_INCDIR to my local postgre dir the error message disappear and i got another one: ld: library not found for -lpq Thus I tried to set PG_LIBDIR to the directory where libpq is located, but still I received the same error message, despite a encouraging libpq-fe.h ...yes Does anybody know how to fix this? Thx in advance matt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 plotting with ggplot2
As far as I know, the packages are up to date. I have had identical problems on 2.9.1 as well as on 2.8.1. I did a fresh install of 2.9.1 to no avail. Here is my sessionInfo(): sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=Slovenian_Slovenia.1250;LC_CTYPE=Slovenian_Slovenia.1250;LC_MONETARY=Slovenian_Slovenia.1250;LC_NUMERIC=C;LC_TIME=Slovenian_Slovenia.1250 attached base packages: [1] stats graphics grDevices utils datasets grid methods [8] base other attached packages: [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9proto_0.3-8 loaded via a namespace (and not attached): [1] tools_2.9.1 Cheers, Roman On Fri, Aug 28, 2009 at 10:05 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Have you checked that you have the latest version of ggplot2 and plyr? Please post your sessionInfo() HTH, baptiste 2009/8/28 romunov romu...@gmail.com Dear R-Help subsribers, upon running into a wonderful ggplot2 package by accident, I abruptly encountered another problem. Almost every command run with ggplot2 results in some sort of error. The one below is far the most common one. Kind people from ggplot2 mailing list couldn't manage to solve the problem, so I'm re-posting it here to try my luck. I will recommend myself for any tips on how to solve this, as I would really benefit from using this package. head(cebelice) time c2 1 00:00 0 2 00:15 0 3 00:30 0 4 00:45 0 5 01:00 0 6 01:15 0 dim(cebelice) [1] 96 2 ggplot(cebelice, aes(x=time, y=c2)) + geom_histogram() Error in all.vars(as.formula(.$facets)) : could not find function as.formula This is straight from ggplot2 sample page for barplots: c - ggplot(mtcars, aes(factor(cyl))) c + geom_bar() Error in get(transform, env = ., inherits = TRUE)(., ...) : attempt to apply non-function Sincerely yours, Roman [[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. -- _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK http://newton.ex.ac.uk/research/emag __ [[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] Plotting to stdout
Gábor Csárdi wrote: On Fri, Aug 28, 2009 at 1:33 PM, Gabor Grothendieckggrothendi...@gmail.com wrote: [...] I could have used this functionality in a previous project as well; however, for Oliver's application just pass the filename to the python program use that in the img src=... tag (or have the python program pass the filename to the R program). If there is some aspect of this problem that has not been explained that truly does make passing the graphic file contents to the python program desirable then have R write out the graphic file and then have R read it back in. Unfortunately, this is not always a good solution. For example, I am running Rserve with connections from untrusted users. The Rserve process is not allowed to write to the disk at all, but then there is no easy way to create plots. The patch Romain mentioned above looks like a good solution. The R connections patch worked well on Unix at the time, but it was never tested on the other R supported platforms. I believe this was R core's complaint about not considering it as a patch. There's yet another option, although someone would need knowledge of converting raw image data to PNG (or other) format in memory: the Cairo package allows access to the raw image data from R itself, although it's undocumented and experimental. The functions are defined in R/imgtools.R within the Cairo source package. Jeff __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
Esmail, Very nice; thanks! Tom - Original Message - From: Esmail esmail...@gmail.com Date: Friday, August 28, 2009 8:59 am Subject: [R] Google's R Style Guide Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r- style.html Comments/Critiques? Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not that surprising since Python is also one of the main languages used by Google. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.htmland 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] Question: how to index (subset) a data frame without memory overhead
1. Suppose one has a big data frame (say, m such that dim(m)=c(8610, 3521) ) If only a subset of m, say m[1:8600, ] is now needed, how to select it without creating large memory overhead? A natural solution, m - m[1:8600,], seems to use in addition to memory needed to hold m roughly 2 times more memory - making the total memory required over 3 times object.size(m), as seen by using memory.size(max=T). This is understandable since the arguments are passed as value. However, is there a natural way around this memory overhead? 2. Similarly, if one has another data frame n such that dim(n)=c(10, 3521), doing m - rbind(m,n) also needs the same amount of memory overhead. Is there any way around that? I tried package ref, but could not solve the particular problems above. Any help would be appreciated. Piotr Piotr Chmielowski Chief Operating Officer/Group Risk Manager Kingsley House, Wimpole Street, London, W1G 0RE, United Kingdom http://www.reechaim.com/ DDI: +44 (0)20 7399 3662 Switchboard: +44 (0)20 7399 3650 Fax: +44 (0)20 7399 3698 Mobile: +44 (0)7825 711 957 Email: piotr.chmielow...@reechaim.com http://www.reechaim.com/ Reech AiM Partners LLP, Registered Office: 42-44 Portman Road, Reading, Berkshire, RG30 1EA. Registered in England and Wales No. OC321436. Authorised and regulated by the Financial Services Authority. Reech CBRE Alternative Real Estate LLP, Registered Office: 42-44 Portman Road, Reading, Berkshire, RG30 1EA. Registered in England and Wales No. OC322313. Authorised and regulated by the Financial Services Authority. This message and any attachments (the message) is intended solely for the addressees and is confidential. If you receive this message in error, please delete it and immediately notify the sender. Any use not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except by formal approval. The internet can not guarantee the integrity of this message. We shall not therefore be liable for the message if modified. __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
On Fri, Aug 28, 2009 at 8:22 AM, Ted Harding ted.hard...@manchester.ac.ukwrote: On 28-Aug-09 12:59:24, Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not that surprising since Python is also one of the main languages used by Google. I think it is grossly over-prescriptive. For example: function names have initial capital letters and no dots is violated throughout R itself. Ted. Certainly R's function names are an inconsistent mess: row.names, rownames browseURL, contrib.url, fixup.package.URLs package.contents, packageStatus mahalanobis, TukeyHSD getMethod, getS3method It's too late to fix the established functions, but it would be nice to have more reliable and sensible standards going forward into the future. Kevin [[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] Google's R Style Guide
Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem plotting with ggplot2
A few things to try. Try starting R using the --vanilla flag. From the Windows command line: rem change next line appropriately if needed cd \Program Files\R\R-2.9.1\bin Rgui --vanilla and see if it still happens.If that does not help try reinstalling R and all packages. On Fri, Aug 28, 2009 at 10:20 AM, romunovromu...@gmail.com wrote: As far as I know, the packages are up to date. I have had identical problems on 2.9.1 as well as on 2.8.1. I did a fresh install of 2.9.1 to no avail. Here is my sessionInfo(): sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=Slovenian_Slovenia.1250;LC_CTYPE=Slovenian_Slovenia.1250;LC_MONETARY=Slovenian_Slovenia.1250;LC_NUMERIC=C;LC_TIME=Slovenian_Slovenia.1250 attached base packages: [1] stats graphics grDevices utils datasets grid methods [8] base other attached packages: [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9 proto_0.3-8 loaded via a namespace (and not attached): [1] tools_2.9.1 Cheers, Roman On Fri, Aug 28, 2009 at 10:05 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Have you checked that you have the latest version of ggplot2 and plyr? Please post your sessionInfo() HTH, baptiste 2009/8/28 romunov romu...@gmail.com Dear R-Help subsribers, upon running into a wonderful ggplot2 package by accident, I abruptly encountered another problem. Almost every command run with ggplot2 results in some sort of error. The one below is far the most common one. Kind people from ggplot2 mailing list couldn't manage to solve the problem, so I'm re-posting it here to try my luck. I will recommend myself for any tips on how to solve this, as I would really benefit from using this package. head(cebelice) time c2 1 00:00 0 2 00:15 0 3 00:30 0 4 00:45 0 5 01:00 0 6 01:15 0 dim(cebelice) [1] 96 2 ggplot(cebelice, aes(x=time, y=c2)) + geom_histogram() Error in all.vars(as.formula(.$facets)) : could not find function as.formula This is straight from ggplot2 sample page for barplots: c - ggplot(mtcars, aes(factor(cyl))) c + geom_bar() Error in get(transform, env = ., inherits = TRUE)(., ...) : attempt to apply non-function Sincerely yours, Roman [[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. -- _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK http://newton.ex.ac.uk/research/emag __ [[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] How to generate mean anova value row in anova table, instead of individual value for each predictor
Hi Moumita, Could you send a minimum reproducible code as suggested on posting guide?! bests milton On Fri, Aug 28, 2009 at 8:08 AM, Moumita Das das.moumita.onl...@gmail.comwrote: Hi All , Can anybody tell me if there's any way to get the summarized anova values.Now i will explain what i mean , when i say *summarized*. Below you can see the anova table of recmeanC1 with rest* all* i.e from recmeanC2 to i15(predictors),as shown in table. Df Sum SquaresMean Square F valueSignificance [Pr(F)] recmeanC21 89.272 89.272 1.50E+34 2e-16 *** recmeanC31 9.965 9.965 1.68E+33 2e-16 *** recmeanC41 2.61 2.61 4.40E+32 2e-16 *** i1 1 25.341 25.341 4.27E+33 2e-16 *** i2 1 0.118 0.118 1.98E+31 2e-16 *** i3 1 0.022 0.022 3.65E+30 2e-16 *** i4 1 0.164 0.164 2.75E+31 2e-16 *** i5 1 15.639 15.639 2.63E+33 2e-16 *** i6 1 1.64E-34 1.64E-34 2.76E-02 0.86812 i7 1 1.72E-33 1.72E-33 2.89E-01 0.59112 i8 1 9.29E-34 9.29E-34 1.57E-01 0.69273 i9 1 6.38E-33 6.38E-33 1.07E+00 0.30092 i10 1 1.02E-32 1.02E-32 1.71E+00 0.19166 i12 1 2.25E-33 2.25E-33 3.80E-01 0.53831 i13 1 2.13E-32 2.13E-32 3.5885e+00 0.53831 0.53831 Regression 15 1.43E+02 9.54E+00 1.61E+33 2.2e-16 Residuals 276 1.64E-30 5.94E-33 Total 291 1.43E+02 Instead of the values in the rows from reacmeanC1 to i15...what i want is a summarized value ,what the row named *Regression* shows.I do not get anything like the row Regression.I copied that to show that SPSS has way to generate that.though Residuals row is generated in R just like SPSS. I know the how to calculate a single summarized Df,Sum Sq,Mean Sq,F value,Pr(F) with these formulae:--- *That is instead of all the 15 rows from reacmeanC1 to i15 i want row Regresssion* Df Sum Sq Mean SqF value Regression Calculations sum of all the above dfs sum of all the above Sum of Squares Sum of Squares/df Mean Square due to Regression/Mean Square due to Residuals But isn't there any function in R to get what i explained above in a much easier way? -- Thanks in advance Moumita [[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.htmlhttp://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] Google's R Style Guide
On 8/28/2009 10:41 AM, hadley wickham wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html I see you repeated (or independently invented?) the bad rule about closing braces. They should usually go on their own line, but not when followed by an else clause. 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] problem plotting with ggplot2
Hello Gabor, your suggestion running R in vanilla mode was fruitful. I can plot at least bars. How would you proceed. How can I root out bad package or whatever is causing this? Cheers, Roman On Fri, Aug 28, 2009 at 4:48 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: A few things to try. Try starting R using the --vanilla flag. From the Windows command line: rem change next line appropriately if needed cd \Program Files\R\R-2.9.1\bin Rgui --vanilla and see if it still happens.If that does not help try reinstalling R and all packages. On Fri, Aug 28, 2009 at 10:20 AM, romunovromu...@gmail.com wrote: As far as I know, the packages are up to date. I have had identical problems on 2.9.1 as well as on 2.8.1. I did a fresh install of 2.9.1 to no avail. Here is my sessionInfo(): sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=Slovenian_Slovenia.1250;LC_CTYPE=Slovenian_Slovenia.1250;LC_MONETARY=Slovenian_Slovenia.1250;LC_NUMERIC=C;LC_TIME=Slovenian_Slovenia.1250 attached base packages: [1] stats graphics grDevices utils datasets grid methods [8] base other attached packages: [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9proto_0.3-8 loaded via a namespace (and not attached): [1] tools_2.9.1 Cheers, Roman On Fri, Aug 28, 2009 at 10:05 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Have you checked that you have the latest version of ggplot2 and plyr? Please post your sessionInfo() HTH, baptiste 2009/8/28 romunov romu...@gmail.com Dear R-Help subsribers, upon running into a wonderful ggplot2 package by accident, I abruptly encountered another problem. Almost every command run with ggplot2 results in some sort of error. The one below is far the most common one. Kind people from ggplot2 mailing list couldn't manage to solve the problem, so I'm re-posting it here to try my luck. I will recommend myself for any tips on how to solve this, as I would really benefit from using this package. head(cebelice) time c2 1 00:00 0 2 00:15 0 3 00:30 0 4 00:45 0 5 01:00 0 6 01:15 0 dim(cebelice) [1] 96 2 ggplot(cebelice, aes(x=time, y=c2)) + geom_histogram() Error in all.vars(as.formula(.$facets)) : could not find function as.formula This is straight from ggplot2 sample page for barplots: c - ggplot(mtcars, aes(factor(cyl))) c + geom_bar() Error in get(transform, env = ., inherits = TRUE)(., ...) : attempt to apply non-function Sincerely yours, Roman [[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. -- _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK http://newton.ex.ac.uk/research/emag __ [[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] Google's R Style Guide
On Fri, Aug 28, 2009 at 3:53 PM, Duncan Murdochmurd...@stats.uwo.ca wrote: On 8/28/2009 10:41 AM, hadley wickham wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html I see you repeated (or independently invented?) the bad rule about closing braces. They should usually go on their own line, but not when followed by an else clause. I notice neither Google nor Hadley give examples with 'else' or 'else if' clauses! Talking of closing braces, I discovered this closing brace in the colorRamp function: x - seq.int(0, 1, length.out = nrow(colors))^{ bias } Yes, it's on a line on its own, but why is it even there in the first place? Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to source a script with command line option?
Hi, Suppose that I have the following script. $ cat commandArgs.R args=commandArgs(trailingOnly=TRUE) args[1] I can supply command line options $ Rscript commandArgs.R a args=commandArgs(trailingOnly=TRUE) args[1] [1] a I am wondering how to supply the command line arguments when I source the code. The following way is of course not working. source(commandArgs.R a) Regards, Peng [[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] Google's R Style Guide
I am troubled by the curly brace rule: An opening curly brace should never go on its own line and should always be followed by a new line; a closing curly brace should always go on its own line. It seems to me that the opening an dosing curly brace should go on their own lines to allow the reader to immediately know what is encompassed in the curly brace: Rather than: if (y 0 debug) { message(Y is negative) } How about (note use of separate line for braces and use of indentation): if (y 0 debug) { message(Y is negative) } Am I missing something regarding the R parser or syntax? John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) hadley wickham h.wick...@gmail.com 8/28/2009 10:41 AM Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html I see you repeated (or independently invented?) the bad rule about closing braces. They should usually go on their own line, but not when followed by an else clause. That was an oversight on my behalf and is now fixed. Thanks! Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to convert a string passed as an argument to a vector?
Hi, $ cat commandArgs.R args=commandArgs(trailingOnly=TRUE) args[1]+10 I have the above code. But the following command line gives me an error. I am wondering what is the correct way to convert a string to a vector? $ Rscript commandArgs.R 1:3 args=commandArgs(trailingOnly=TRUE) args[1]+10 Error in args[1] + 10 : non-numeric argument to binary operator Execution halted Regards, Peng [[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] Google's R Style Guide
On Fri, Aug 28, 2009 at 9:41 AM, hadley wickham h.wick...@gmail.com wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html Hadley In the spirit of less is more, I find the underscores to be distracting and unneeded typing. Just simplify to camel caps. I echo Duncan's idea that a line should never start with else. Duncan mentioned this in the context of cutting and pasting, but the other place that not having else start a line is when using the browser function and stepping through code line by line. Kevin [[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] RPostgreSQL libpq problem
Phil, thx a lot for your suggestions.. Luckily I was just able to find a solution. I just recompiled everything, deleting my manually set vars PG_INCDIR and PG_LIBDIR and setting PG_CONFIG=/opt/local/lib/postgresql83/bin/pg_config in line 2564 of the configure file then starting the installation directly via R. after that everything was straight forward, just using library(RPostgreSQL) . Maybe this helps some mac users on the list in future matt Am 28.08.2009 um 16:46 schrieb Phil Spector: Matt - If you include a -L/directory/with/the/library before the -lpq in your compile line, R should be able to find the library. If you've already compiled it, try typing export DYLD_LIBRARY_PATH=/directory/with/the/library before starting R, or from within R, try typing Sys.setenv(DYLD_LIBRARY_PATH='/directory/with/the/library') before loading the package. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Fri, 28 Aug 2009, Bunny, lautloscrew.com wrote: Dear all, I am stuck trying to get RPostgreSQL running on my Mac. PostgreSQL itself does work fine as it is able to connect with various other apps. Unfortunately the RPostgreSQL package is not available as a binary for MAC OS. Thus I´ve been trying to compile the source for quite some time now - unfortunately without success (or at least very limited success). First, running ./configure respectively running the installation directly via R was not able to find the header file libpq-fe.h. after I changed PG_INCDIR to my local postgre dir the error message disappear and i got another one: ld: library not found for -lpq Thus I tried to set PG_LIBDIR to the directory where libpq is located, but still I received the same error message, despite a encouraging libpq-fe.h ...yes Does anybody know how to fix this? Thx in advance matt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Transform data for repeated measures
Patrick; You got two helpful suggestions for where to start your learning how to reshape your data. I am going to admit that I have recurring difficulty using either reshape() or the functions in the reshape package. It undoubtedly reflects some sort of constricted abstraction capability on my part, but I have learned that sometimes I get what I need from a combination of rep() and the stack() function. The strategy is to rep() the recurring variables and stack() the repeated measures on the same subjects resp.df - read.table(textConnection(patient basefev1 fev11h fev12h fev13h fev14h fev15h fev16h fev17h fev18h drug 201 2.46 2.68 2.76 2.50 2.30 2.14 2.40 2.33 2.20a 202 3.50 3.95 3.65 2.93 2.53 3.04 3.37 3.14 2.62a 203 1.96 2.28 2.34 2.29 2.43 2.06 2.18 2.28 2.29a 204 3.44 4.08 3.87 3.79 3.30 3.80 3.24 2.98 2.91a), header=TRUE) closeAllConnections() stk.resp - data.frame(pt.id.=rep(resp.df$patient, 9), FEV1 =stack(resp.df[,2:10]), drug=rep(resp.df$drug, 9)) stk.resp pt.id. FEV1.values FEV1.ind drug 1 2012.46 basefev1a 2 2023.50 basefev1a 3 2031.96 basefev1a 4 2043.44 basefev1a 5 2012.68 fev11ha 6 2023.95 fev11ha 7 2032.28 fev11ha 8 2044.08 fev11ha snipped further unneeded output HTH; David. On Aug 27, 2009, at 7:37 PM, Richardson, Patrick wrote: I have a dataset that I'm trying to rearrange for a repeated measures analysis: It looks like: patient basefev1 fev11h fev12h fev13h fev14h fev15h fev16h fev17h fev18h drug 201 2.46 2.68 2.76 2.50 2.30 2.14 2.40 2.33 2.20a 202 3.50 3.95 3.65 2.93 2.53 3.04 3.37 3.14 2.62a 203 1.96 2.28 2.34 2.29 2.43 2.06 2.18 2.28 2.29a 204 3.44 4.08 3.87 3.79 3.30 3.80 3.24 2.98 2.91a And I want to make it look like: Patient FEV time drug 201 2.460 a 201 2.681 a 201 2.762 a 201 2.503 a And so on . . . . . There would be 9 time and drug is a factor variable. I know there is a way to do this in R but I cannot remember the function. I've looked at the transpose function in (base) but that doesn't seem to be what I want. Can something like this be done easily from within package functions or would it require writing something custom? Another program would use something like the transpose procedure, but I'm trying to stay away from that program. Thanks, Patrick David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem plotting with ggplot2
Try removing various lines from your Rprofile.site file found in \Program Files\R\R-2.9.1\etc.Rprofile.site or other startup file; see ?Startup from within R. On Fri, Aug 28, 2009 at 10:57 AM, romunovromu...@gmail.com wrote: Hello Gabor, your suggestion running R in vanilla mode was fruitful. I can plot at least bars. How would you proceed. How can I root out bad package or whatever is causing this? Cheers, Roman On Fri, Aug 28, 2009 at 4:48 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: A few things to try. Try starting R using the --vanilla flag. From the Windows command line: rem change next line appropriately if needed cd \Program Files\R\R-2.9.1\bin Rgui --vanilla and see if it still happens. If that does not help try reinstalling R and all packages. On Fri, Aug 28, 2009 at 10:20 AM, romunovromu...@gmail.com wrote: As far as I know, the packages are up to date. I have had identical problems on 2.9.1 as well as on 2.8.1. I did a fresh install of 2.9.1 to no avail. Here is my sessionInfo(): sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=Slovenian_Slovenia.1250;LC_CTYPE=Slovenian_Slovenia.1250;LC_MONETARY=Slovenian_Slovenia.1250;LC_NUMERIC=C;LC_TIME=Slovenian_Slovenia.1250 attached base packages: [1] stats graphics grDevices utils datasets grid methods [8] base other attached packages: [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9 proto_0.3-8 loaded via a namespace (and not attached): [1] tools_2.9.1 Cheers, Roman On Fri, Aug 28, 2009 at 10:05 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Have you checked that you have the latest version of ggplot2 and plyr? Please post your sessionInfo() HTH, baptiste 2009/8/28 romunov romu...@gmail.com Dear R-Help subsribers, upon running into a wonderful ggplot2 package by accident, I abruptly encountered another problem. Almost every command run with ggplot2 results in some sort of error. The one below is far the most common one. Kind people from ggplot2 mailing list couldn't manage to solve the problem, so I'm re-posting it here to try my luck. I will recommend myself for any tips on how to solve this, as I would really benefit from using this package. head(cebelice) time c2 1 00:00 0 2 00:15 0 3 00:30 0 4 00:45 0 5 01:00 0 6 01:15 0 dim(cebelice) [1] 96 2 ggplot(cebelice, aes(x=time, y=c2)) + geom_histogram() Error in all.vars(as.formula(.$facets)) : could not find function as.formula This is straight from ggplot2 sample page for barplots: c - ggplot(mtcars, aes(factor(cyl))) c + geom_bar() Error in get(transform, env = ., inherits = TRUE)(., ...) : attempt to apply non-function Sincerely yours, Roman [[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. -- _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK http://newton.ex.ac.uk/research/emag __ [[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] RODBC: how to set the data-source?
Hello, I want to try to connect R to PostgreSQL. I have found that there are three ways: DBI or RODBC or RPostgreSQL. I tried around with DBI and RODBC but didn't get it running. In both cases I'm not clear about how to set the driver/data source. I get this error: x channel - odbcConnect(rtest, uid=oliver) x Warning messages: x 1: In odbcDriverConnect(st, ...) : x[RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data x source name not found, and no default driver specified x 2: In odbcDriverConnect(st, ...) : ODBC connection failed x So I somehow have to set the Driver. But how? I didn't find it out. Ciao, Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with glmer {lme4) function: how to return F or tstatistics instead of z statistics.
R-help is for help on the use of R, not primarily for statistics advice (although this does sometimes occur). Most of your questions are about statistics, so you should probably consult a local statistician for help or post on a more suitable list, perhaps R-sig-mixed-models: https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models Cheers, Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Raldo Kruger Sent: Friday, August 28, 2009 3:46 AM To: r-help@r-project.org Subject: [R] Help with glmer {lme4) function: how to return F or tstatistics instead of z statistics. Hi, I'm new to R and GLMMs, and I've been unable to find the answers to my questions by trawling through the R help archives. I'm hoping someone here can help me. I'm running an analysis on Seedling survival (count data=Poisson distribution) on restoration sites, and my main interest is in determining whether the Nutrients (N) and water absorbing polymer Gel (G) additions to the soil substrate contribute positively to the survival of the seedlings, over a 3 year time period (for simplicity I'm just using 3 time periods, each in the same season for the 3 successive years). Fixed factors: Nutrients (0 and 1), Gel (0 and 1) Random factors: Site (4 non replicate sites), Year (3 time periods) Response variable: Seedling numbers (counts) / 0.25m2 plot According to the decision tree on page 131 in Bolker et al. (2008, in TREE; thanks, very useful paper!), most of my data sets should be analysed with Laplace or GHQ model with Wald t or F statistic (since it is non-normal, can't be transformed to normality, has a mean 5, has less than 3 random effects, and is overdispersed). I'm using the glmer {lme4} function, since it allows for Laplace or GHQ, as well as more than one random factor (glmmML {glmmML) and glmPQL {MASS} apparently does not), as follows: m1-glmer(Seedlings~N*G*(1|Year)*(1|Site), data=ex5m, family=poisson(link=log)) My questions are: 1) The model returns Z values, and I'm unable to find an argument in the function where this can be changed to return a t or F value (as Bolker et al. suggests I should use for my data). 2) I'm unsure what the AIC or QAIC value means, other than knowing that it should be as low as possible. Is there a rule of thumb of what is a good AIC value? Mine are in the region of 2230. 3) The default in glmer {lme4) for the argument nAGQ = 1, which uses the Laplace approximation. When nAGQ 1, it uses the GHQ method, but I'm unsure how to determine the correct number of Gauss-Hermite points to enter in the argument when using this method. How is this determined? 4) Some of my data sets have means 5, and are also overdispersed, and according to Bolker et al. should be analysed using a GLMM with PQL and a Wald t or F. However, the glmmPQL {glmmPQL} does not accept more than one random factor, and I have two, so how do I deal with that? 5) Lastly, what does the 1 imply in the random factor term, e.g. (1|Site), and how does this affect the analysis? Many thanks, Raldo Kruger MSc student University of Cape Town South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RODBC: how to set the data-source?
Oliver Bandel oliver at first.in-berlin.de writes: odbcDataSources() named character(0) This looks like nothing is available via RODBC interface. Any idea what's missing? How can I get all names of available drivers? Ciao, Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at: http://docs.google.com/View?id=dddzqd53_2646dcw759cb It's useful for beginners and those coding randomly. Like it or not. It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into arguing over if-else or bracketing - we all have our own favorite. /Henrik On Fri, Aug 28, 2009 at 8:02 AM, Kevin Wrightkw.s...@gmail.com wrote: On Fri, Aug 28, 2009 at 9:41 AM, hadley wickham h.wick...@gmail.com wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html Hadley In the spirit of less is more, I find the underscores to be distracting and unneeded typing. Just simplify to camel caps. I echo Duncan's idea that a line should never start with else. Duncan mentioned this in the context of cutting and pasting, but the other place that not having else start a line is when using the browser function and stepping through code line by line. Kevin [[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] Google's R Style Guide
It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into arguing over if-else or bracketing - we all have our own favorite. I totally agree. The main purpose of my style guide is so that my students write code that I can easily read, understand and grade. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Google's R Style Guide
An opening curly brace should never go on its own line and should always be followed by a new line; a closing curly brace should always go on its own line. It seems to me that the opening an dosing curly brace should go on their own lines to allow the reader to immediately know what is encompassed in the curly brace: In my view, that's the purpose of indenting - you see scope from indenting. Again, that's just my personal preference, and while I can make my students follow it, I don't expect the rest of the world to fall in line (although it would be nice ;) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Transform data for repeated measures
Using reshape you can try this: reshape(resp.df, direction = long, idvar=patient, varying = list(grep(fev, names(resp.df On Thu, Aug 27, 2009 at 8:37 PM, Richardson, Patrick patrick.richard...@vai.org wrote: I have a dataset that I'm trying to rearrange for a repeated measures analysis: It looks like: patient basefev1 fev11h fev12h fev13h fev14h fev15h fev16h fev17h fev18h drug 201 2.46 2.68 2.76 2.50 2.30 2.14 2.40 2.33 2.20a 202 3.50 3.95 3.65 2.93 2.53 3.04 3.37 3.14 2.62a 203 1.96 2.28 2.34 2.29 2.43 2.06 2.18 2.28 2.29a 204 3.44 4.08 3.87 3.79 3.30 3.80 3.24 2.98 2.91a And I want to make it look like: Patient FEV time drug 201 2.460 a 201 2.681 a 201 2.762 a 201 2.503 a And so on . . . . . There would be 9 time and drug is a factor variable. I know there is a way to do this in R but I cannot remember the function. I've looked at the transpose function in (base) but that doesn't seem to be what I want. Can something like this be done easily from within package functions or would it require writing something custom? Another program would use something like the transpose procedure, but I'm trying to stay away from that program. Thanks, Patrick R version 2.9.2 (2009-08-24) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] grDevices datasets tcltk splines graphics stats utils methods base other attached packages: [1] svSocket_0.9-43 svMisc_0.9.48 TinnR_1.0.3 R2HTML_1.59-1 Hmisc_3.6-1 survival_2.35-4 loaded via a namespace (and not attached): [1] cluster_1.12.0 grid_2.9.2 lattice_0.17-25 tools_2.9.2 This email message, including any attachments, is for ...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
On Fri, Aug 28, 2009 at 11:10 AM, Henrik Bengtsson h...@stat.berkeley.eduwrote: Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at: http://docs.google.com/View?id=dddzqd53_2646dcw759cb It's useful for beginners and those coding randomly. Like it or not. It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into arguing over if-else or bracketing - we all have our own favorite. /Henrik No, it IS not a waste of time. I have wasted considerable time due the lack of a standard. Yesterday I was debugging panel.levelplot and found this code: if (x.is.factor) { ux - sort(unique(x[!is.na(x)])) lx - rep(1, length(ux)) cx - ux } else { ux - sort(unique(x[!is.na(x)])) bx - if (length(ux) 1) c(3 * ux[1] - ux[2], ux[-length(ux)] + ux[-1], 3 * ux[length(ux)] - ux[length(ux) - 1])/2 else ux + c(-0.5, 0.5) * minXwid lx - diff(bx) cx - (bx[-1] + bx[-length(bx)])/2 } You can't step through this because the else block starts on a new line. So you have to manually evaluate the value of x.is.factor to determine if it is TRUE or FALSE, scroll down to the line below else and continue stepping through the code. Try not to forget to accidentally evaluate the last brace or do something else that kicks you out of the browser and forces you to start all over again. Forbidding the use of else without a leading curly bracket would have saved me MUCH time over the years... (Sorry Deepayan. I love lattice. Please forgive me.) Kevin Wright On Fri, Aug 28, 2009 at 8:02 AM, Kevin Wrightkw.s...@gmail.com wrote: On Fri, Aug 28, 2009 at 9:41 AM, hadley wickham h.wick...@gmail.com wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html Hadley In the spirit of less is more, I find the underscores to be distracting and unneeded typing. Just simplify to camel caps. I echo Duncan's idea that a line should never start with else. Duncan mentioned this in the context of cutting and pasting, but the other place that not having else start a line is when using the browser function and stepping through code line by line. Kevin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] new data.frame summed by date
Hi, I wonder if someone can suggest how to create a new data.frame Y from X where X$PL_Pos is summed by each unique X$MyDate. Y should end up with two (or more) columns Y$MyDate and Y$PL_Sum with its value being the cumsum of all the values in X for that date. - a 'daily cumsum'. Thanks, Mark TStoDate = function (TSDate) { X = strptime(TSDate + 19e6L, %Y%m%d) return(as.Date(X)) } X = structure(list(EnDate = c(1090803, 1090804, 1090805, 1090806, 1090806, 1090810, 1090811, 1090812, 1090813, 1090817, 1090819, 1090820, 1090820, 1090824, 1090825, 1090825, 1090826, 1090826, 1090827, 1090827, 1090827), PL_Pos = c(174, -26, 614, 344, -26, 414, -626, 544, -106, -146, 1004, 344, 224, -716, -176, 44, 354, -346, -296, 564, 354)), .Names = c(EnDate, PL_Pos), class = data.frame, row.names = c(733, 734, 3631, 3641, 736, 2403, 2413, 3651, 3661, 3671, 3681, 3691, 1303, 3701, 1304, 1305, 2432, 1306, 3712, 1307, 4214)) X$MyDate = TStoDate(X$EnDate) X __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
But if the closing curly brace marks the end of the if part of an if else statement, the else keyword has to be on the same line as the closing brace. The code will not work if the else is on the next line AFAIK. On Aug 28, 2009, at 6:11 PM, hadley wickham wrote: An opening curly brace should never go on its own line and should always be followed by a new line; a closing curly brace should always go on its own line. It seems to me that the opening an dosing curly brace should go on their own lines to allow the reader to immediately know what is encompassed in the curly brace: In my view, that's the purpose of indenting - you see scope from indenting. Again, that's just my personal preference, and while I can make my students follow it, I don't expect the rest of the world to fall in line (although it would be nice ;) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RODBC: how to set the data-source?
Looks like Unix If so, make sure your script has the proper paths set Here is my set up for an oracle DB export LD_LIBRARY_PATH=/../../instantclient_11_1:/../../unixODBC64_1/lib export ODBCINI=/../..//unixODBC64_1 export ODBCSYSINI=/../..//unixODBC64_1 And of course you need your db defined in ODBC.ini and this will link to your driver code... hth -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Oliver Bandel Sent: Friday, August 28, 2009 10:22 AM To: r-h...@stat.math.ethz.ch Subject: [R] RODBC: how to set the data-source? Hello, I want to try to connect R to PostgreSQL. I have found that there are three ways: DBI or RODBC or RPostgreSQL. I tried around with DBI and RODBC but didn't get it running. In both cases I'm not clear about how to set the driver/data source. I get this error: x channel - odbcConnect(rtest, uid=oliver) x Warning messages: x 1: In odbcDriverConnect(st, ...) : x[RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data x source name not found, and no default driver specified x 2: In odbcDriverConnect(st, ...) : ODBC connection failed x So I somehow have to set the Driver. But how? I didn't find it out. Ciao, Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. === Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.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] Google's R Style Guide
On 8/28/2009 12:33 PM, Kevin Wright wrote: On Fri, Aug 28, 2009 at 11:10 AM, Henrik Bengtsson h...@stat.berkeley.eduwrote: Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at: http://docs.google.com/View?id=dddzqd53_2646dcw759cb It's useful for beginners and those coding randomly. Like it or not. It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into arguing over if-else or bracketing - we all have our own favorite. /Henrik No, it IS not a waste of time. I have wasted considerable time due the lack of a standard. Yesterday I was debugging panel.levelplot and found this code: if (x.is.factor) { ux - sort(unique(x[!is.na(x)])) lx - rep(1, length(ux)) cx - ux } else { ux - sort(unique(x[!is.na(x)])) bx - if (length(ux) 1) c(3 * ux[1] - ux[2], ux[-length(ux)] + ux[-1], 3 * ux[length(ux)] - ux[length(ux) - 1])/2 else ux + c(-0.5, 0.5) * minXwid lx - diff(bx) cx - (bx[-1] + bx[-length(bx)])/2 } You can't step through this because the else block starts on a new line. In your other message you were talking about the browser. Does it really have a problem with this (which would be a bug), or are you basically just cutting and pasting? So you have to manually evaluate the value of x.is.factor to determine if it is TRUE or FALSE, scroll down to the line below else and continue stepping through the code. Try not to forget to accidentally evaluate the last brace or do something else that kicks you out of the browser and forces you to start all over again. Now that doesn't sound like the browser. Whatever debugger you are using has a bug. Duncan Murdoch Forbidding the use of else without a leading curly bracket would have saved me MUCH time over the years... (Sorry Deepayan. I love lattice. Please forgive me.) Kevin Wright On Fri, Aug 28, 2009 at 8:02 AM, Kevin Wrightkw.s...@gmail.com wrote: On Fri, Aug 28, 2009 at 9:41 AM, hadley wickham h.wick...@gmail.com wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html Hadley In the spirit of less is more, I find the underscores to be distracting and unneeded typing. Just simplify to camel caps. I echo Duncan's idea that a line should never start with else. Duncan mentioned this in the context of cutting and pasting, but the other place that not having else start a line is when using the browser function and stepping through code line by line. Kevin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to convert a string passed as an argument to a vector?
If you have it as a character string, then you have to evaluate it: x - '1:3' x + 10 Error in x + 10 : non-numeric argument to binary operator No suitable frames for recover() eval(parse(text=x))+10 [1] 11 12 13 On Fri, Aug 28, 2009 at 11:04 AM, Peng Yupengyu...@gmail.com wrote: Hi, $ cat commandArgs.R args=commandArgs(trailingOnly=TRUE) args[1]+10 I have the above code. But the following command line gives me an error. I am wondering what is the correct way to convert a string to a vector? $ Rscript commandArgs.R 1:3 args=commandArgs(trailingOnly=TRUE) args[1]+10 Error in args[1] + 10 : non-numeric argument to binary operator Execution halted Regards, Peng [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Google's R Style Guide
On Fri, Aug 28, 2009 at 11:49 AM, Duncan Murdoch murd...@stats.uwo.cawrote: On 8/28/2009 12:33 PM, Kevin Wright wrote: On Fri, Aug 28, 2009 at 11:10 AM, Henrik Bengtsson h...@stat.berkeley.edu wrote: Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at: http://docs.google.com/View?id=dddzqd53_2646dcw759cb It's useful for beginners and those coding randomly. Like it or not. It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into arguing over if-else or bracketing - we all have our own favorite. /Henrik No, it IS not a waste of time. I have wasted considerable time due the lack of a standard. Yesterday I was debugging panel.levelplot and found this code: if (x.is.factor) { ux - sort(unique(x[!is.na(x)])) lx - rep(1, length(ux)) cx - ux } else { ux - sort(unique(x[!is.na(x)])) bx - if (length(ux) 1) c(3 * ux[1] - ux[2], ux[-length(ux)] + ux[-1], 3 * ux[length(ux)] - ux[length(ux) - 1])/2 else ux + c(-0.5, 0.5) * minXwid lx - diff(bx) cx - (bx[-1] + bx[-length(bx)])/2 } You can't step through this because the else block starts on a new line. In your other message you were talking about the browser. Does it really have a problem with this (which would be a bug), or are you basically just cutting and pasting? So you have to manually evaluate the value of x.is.factor to determine if it is TRUE or FALSE, scroll down to the line below else and continue stepping through the code. Try not to forget to accidentally evaluate the last brace or do something else that kicks you out of the browser and forces you to start all over again. Now that doesn't sound like the browser. Whatever debugger you are using has a bug. Duncan Murdoch Ah, right you are. Thanks for the clarification. This is not a browser phenomenon, but due to using ess-eval-line-and-step (which is a kind of cut and paste, I guess) to go through the code in emacs. (Maybe there's a better way?) In any case, using } else eliminates the problem. Kevin [[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] new data.frame summed by date
Is this what you want: aggregate(X$PL_Pos, list(X$MyDate), sum) Group.1x 1 2009-08-03 174 2 2009-08-04 -26 3 2009-08-05 614 4 2009-08-06 318 5 2009-08-10 414 6 2009-08-11 -626 7 2009-08-12 544 8 2009-08-13 -106 9 2009-08-17 -146 10 2009-08-19 1004 11 2009-08-20 568 12 2009-08-24 -716 13 2009-08-25 -132 14 2009-08-268 15 2009-08-27 622 You can fix up the column names. On Fri, Aug 28, 2009 at 12:37 PM, Mark Knechtmarkkne...@gmail.com wrote: Hi, I wonder if someone can suggest how to create a new data.frame Y from X where X$PL_Pos is summed by each unique X$MyDate. Y should end up with two (or more) columns Y$MyDate and Y$PL_Sum with its value being the cumsum of all the values in X for that date. - a 'daily cumsum'. Thanks, Mark TStoDate = function (TSDate) { X = strptime(TSDate + 19e6L, %Y%m%d) return(as.Date(X)) } X = structure(list(EnDate = c(1090803, 1090804, 1090805, 1090806, 1090806, 1090810, 1090811, 1090812, 1090813, 1090817, 1090819, 1090820, 1090820, 1090824, 1090825, 1090825, 1090826, 1090826, 1090827, 1090827, 1090827), PL_Pos = c(174, -26, 614, 344, -26, 414, -626, 544, -106, -146, 1004, 344, 224, -716, -176, 44, 354, -346, -296, 564, 354)), .Names = c(EnDate, PL_Pos), class = data.frame, row.names = c(733, 734, 3631, 3641, 736, 2403, 2413, 3651, 3661, 3671, 3681, 3691, 1303, 3701, 1304, 1305, 2432, 1306, 3712, 1307, 4214)) X$MyDate = TStoDate(X$EnDate) X __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] new data.frame summed by date
Jim, It looks exactly like what I wanted. Thanks! - Mark On Fri, Aug 28, 2009 at 10:03 AM, jim holtmanjholt...@gmail.com wrote: Is this what you want: aggregate(X$PL_Pos, list(X$MyDate), sum) Group.1 x 1 2009-08-03 174 2 2009-08-04 -26 3 2009-08-05 614 4 2009-08-06 318 5 2009-08-10 414 6 2009-08-11 -626 7 2009-08-12 544 8 2009-08-13 -106 9 2009-08-17 -146 10 2009-08-19 1004 11 2009-08-20 568 12 2009-08-24 -716 13 2009-08-25 -132 14 2009-08-26 8 15 2009-08-27 622 You can fix up the column names. On Fri, Aug 28, 2009 at 12:37 PM, Mark Knechtmarkkne...@gmail.com wrote: Hi, I wonder if someone can suggest how to create a new data.frame Y from X where X$PL_Pos is summed by each unique X$MyDate. Y should end up with two (or more) columns Y$MyDate and Y$PL_Sum with its value being the cumsum of all the values in X for that date. - a 'daily cumsum'. Thanks, Mark TStoDate = function (TSDate) { X = strptime(TSDate + 19e6L, %Y%m%d) return(as.Date(X)) } X = structure(list(EnDate = c(1090803, 1090804, 1090805, 1090806, 1090806, 1090810, 1090811, 1090812, 1090813, 1090817, 1090819, 1090820, 1090820, 1090824, 1090825, 1090825, 1090826, 1090826, 1090827, 1090827, 1090827), PL_Pos = c(174, -26, 614, 344, -26, 414, -626, 544, -106, -146, 1004, 344, 224, -716, -176, 44, 354, -346, -296, 564, 354)), .Names = c(EnDate, PL_Pos), class = data.frame, row.names = c(733, 734, 3631, 3641, 736, 2403, 2413, 3651, 3661, 3671, 3681, 3691, 1303, 3701, 1304, 1305, 2432, 1306, 3712, 1307, 4214)) X$MyDate = TStoDate(X$EnDate) X __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plotmath, sweave and lattice graphics interaction problem
Dear List, I have hit this problem with using a plotmath expression in an axis label on a lattice plot I'm including in a Sweave document. The actual document is far too long and boring (unless you are interested in the hydrochemistry of upland lakes) to include here, but the following minimal example reproduces the problem; basically, the PDF produced by Sweave has missing characters in the plotmath label whilst the eps file doesn't. Here is the minimal Rnw document: \documentclass[a4paper,12pt]{article} \usepackage{graphicx,xspace} \usepackage[utf8]{inputenc} \usepackage[left=1.5cm,top=2cm,bottom=2cm,right=1.5cm]{geometry} \usepackage{/home/gavin/R/2.9-patched/build/share/texmf/Sweave} \setkeys{Gin}{width=1\textwidth} \begin{document} \title{FOO} \author{Gavin Simpson} \maketitle fig=true= require(lattice) dat - data.frame(A = runif(10), B = runif(10)) print(xyplot(A ~ B, data = dat, ylab = expression(H^+ ~ (mu*eq ~ L^-1 @ \end{document} Note the ylab expression: ylab = expression(H^+ ~ (mu*eq ~ L^-1)) this produces a ylab like H+ (mueq L-1) when run interactively and on the eps file, but the pdf file is missing the parentheses and the mu (micro) symbol. R session info: sessionInfo() R version 2.9.1 Patched (2009-08-07 r49104) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] tools stats graphics grDevices utils datasets methods [8] base other attached packages: [1] lattice_0.17-25 loaded via a namespace (and not attached): [1] grid_2.9.1 So I'm running this in a UTF-8 locale. Is it this that is causing the problem? Any suggestions as to how to proceed? Thanks in advance, G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
On Fri, Aug 28, 2009 at 9:10 AM, Henrik Bengtssonh...@stat.berkeley.edu wrote: Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at: http://docs.google.com/View?id=dddzqd53_2646dcw759cb Google Docs seems to have a hiccup when it comes to publishing/sharing docs; here is a PDF until they've fixed that: http://www.stat.berkeley.edu/share/hb/papers/BengtssonH_20090827-RCC_v0.9.pdf /Henrik It's useful for beginners and those coding randomly. Like it or not. It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into arguing over if-else or bracketing - we all have our own favorite. /Henrik On Fri, Aug 28, 2009 at 8:02 AM, Kevin Wrightkw.s...@gmail.com wrote: On Fri, Aug 28, 2009 at 9:41 AM, hadley wickham h.wick...@gmail.com wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html Hadley In the spirit of less is more, I find the underscores to be distracting and unneeded typing. Just simplify to camel caps. I echo Duncan's idea that a line should never start with else. Duncan mentioned this in the context of cutting and pasting, but the other place that not having else start a line is when using the browser function and stepping through code line by line. Kevin [[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] new data.frame summed by date
Puting my 2cents: newDF-data.frame(aggregate(X$PL_Pos, list(X$MyDate), sum)) colnames(newDF)-c(MyDate,PL_Pos_SUM) good luck milton On Fri, Aug 28, 2009 at 1:03 PM, jim holtman jholt...@gmail.com wrote: Is this what you want: aggregate(X$PL_Pos, list(X$MyDate), sum) Group.1x 1 2009-08-03 174 2 2009-08-04 -26 3 2009-08-05 614 4 2009-08-06 318 5 2009-08-10 414 6 2009-08-11 -626 7 2009-08-12 544 8 2009-08-13 -106 9 2009-08-17 -146 10 2009-08-19 1004 11 2009-08-20 568 12 2009-08-24 -716 13 2009-08-25 -132 14 2009-08-268 15 2009-08-27 622 You can fix up the column names. On Fri, Aug 28, 2009 at 12:37 PM, Mark Knechtmarkkne...@gmail.com wrote: Hi, I wonder if someone can suggest how to create a new data.frame Y from X where X$PL_Pos is summed by each unique X$MyDate. Y should end up with two (or more) columns Y$MyDate and Y$PL_Sum with its value being the cumsum of all the values in X for that date. - a 'daily cumsum'. Thanks, Mark TStoDate = function (TSDate) { X = strptime(TSDate + 19e6L, %Y%m%d) return(as.Date(X)) } X = structure(list(EnDate = c(1090803, 1090804, 1090805, 1090806, 1090806, 1090810, 1090811, 1090812, 1090813, 1090817, 1090819, 1090820, 1090820, 1090824, 1090825, 1090825, 1090826, 1090826, 1090827, 1090827, 1090827), PL_Pos = c(174, -26, 614, 344, -26, 414, -626, 544, -106, -146, 1004, 344, 224, -716, -176, 44, 354, -346, -296, 564, 354)), .Names = c(EnDate, PL_Pos), class = data.frame, row.names = c(733, 734, 3631, 3641, 736, 2403, 2413, 3651, 3661, 3671, 3681, 3691, 1303, 3701, 1304, 1305, 2432, 1306, 3712, 1307, 4214)) X$MyDate = TStoDate(X$EnDate) X __ R-help@r-project.org mailing 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://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] new data.frame summed by date
The request for a date column results in a bit of redundancy beyond what tapply would have produced, but here it is as specified: data.frame(dnames=names(tapply(X$PL_Pos, X$MyDate, sum)), dsums = tapply(X$PL_Pos, X$MyDate, sum) ) dnames dsums 2009-08-03 2009-08-03 174 2009-08-04 2009-08-04 -26 2009-08-05 2009-08-05 614 2009-08-06 2009-08-06 318 2009-08-10 2009-08-10 414 2009-08-11 2009-08-11 -626 2009-08-12 2009-08-12 544 2009-08-13 2009-08-13 -106 2009-08-17 2009-08-17 -146 2009-08-19 2009-08-19 1004 2009-08-20 2009-08-20 568 2009-08-24 2009-08-24 -716 2009-08-25 2009-08-25 -132 2009-08-26 2009-08-26 8 2009-08-27 2009-08-27 622 On Aug 28, 2009, at 12:37 PM, Mark Knecht wrote: Hi, I wonder if someone can suggest how to create a new data.frame Y from X where X$PL_Pos is summed by each unique X$MyDate. Y should end up with two (or more) columns Y$MyDate and Y$PL_Sum with its value being the cumsum of all the values in X for that date. - a 'daily cumsum'. Thanks, Mark TStoDate = function (TSDate) { X = strptime(TSDate + 19e6L, %Y%m%d) return(as.Date(X)) } X = structure(list(EnDate = c(1090803, 1090804, 1090805, 1090806, 1090806, 1090810, 1090811, 1090812, 1090813, 1090817, 1090819, 1090820, 1090820, 1090824, 1090825, 1090825, 1090826, 1090826, 1090827, 1090827, 1090827), PL_Pos = c(174, -26, 614, 344, -26, 414, -626, 544, -106, -146, 1004, 344, 224, -716, -176, 44, 354, -346, -296, 564, 354)), .Names = c(EnDate, PL_Pos), class = data.frame, row.names = c(733, 734, 3631, 3641, 736, 2403, 2413, 3651, 3661, 3671, 3681, 3691, 1303, 3701, 1304, 1305, 2432, 1306, 3712, 1307, 4214)) X$MyDate = TStoDate(X$EnDate) X __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Transform data for repeated measures
On Thu, Aug 27, 2009 at 6:37 PM, Richardson, Patrickpatrick.richard...@vai.org wrote: I have a dataset that I'm trying to rearrange for a repeated measures analysis: It looks like: patient basefev1 fev11h fev12h fev13h fev14h fev15h fev16h fev17h fev18h drug 201 2.46 2.68 2.76 2.50 2.30 2.14 2.40 2.33 2.20 a 202 3.50 3.95 3.65 2.93 2.53 3.04 3.37 3.14 2.62 a 203 1.96 2.28 2.34 2.29 2.43 2.06 2.18 2.28 2.29 a 204 3.44 4.08 3.87 3.79 3.30 3.80 3.24 2.98 2.91 a And I want to make it look like: Patient FEV time drug 201 2.46 0 a 201 2.68 1 a 201 2.76 2 a 201 2.50 3 a And so on . . . . . There would be 9 time and drug is a factor variable. I know there is a way to do this in R but I cannot remember the function. I've looked at the transpose function in (base) but that doesn't seem to be what I want. Can something like this be done easily from within package functions or would it require writing something custom? Another program would use something like the transpose procedure, but I'm trying to stay away from that program. To give a concrete example of what using the reshape package would look like: (thanks to David for making your example easily reproducible) resp.df - read.table(textConnection(patient basefev1 fev11h fev12h fev13h fev14h fev15h fev16h fev17h fev18h drug 201 2.46 2.68 2.76 2.50 2.30 2.14 2.40 2.33 2.20a 202 3.50 3.95 3.65 2.93 2.53 3.04 3.37 3.14 2.62a 203 1.96 2.28 2.34 2.29 2.43 2.06 2.18 2.28 2.29a 204 3.44 4.08 3.87 3.79 3.30 3.80 3.24 2.98 2.91 a), header=TRUE) closeAllConnections() library(reshape) # Identify the variables controlled by your experimental design: stk.resp - melt(resp.df, id = c(patient, drug)) stk.resp$time - as.numeric(gsub([^0-9], , stk.resp$variable)) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Google's R Style Guide
On Fri, Aug 28, 2009 at 5:11 PM, hadley wickhamh.wick...@gmail.com wrote: In my view, that's the purpose of indenting - you see scope from indenting. *cough* python *cough* Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Google's R Style Guide
On Fri, Aug 28, 2009 at 10:02 AM, Kevin Wrightkw.s...@gmail.com wrote: On Fri, Aug 28, 2009 at 11:49 AM, Duncan Murdoch murd...@stats.uwo.cawrote: On 8/28/2009 12:33 PM, Kevin Wright wrote: [...] Now that doesn't sound like the browser. Whatever debugger you are using has a bug. Duncan Murdoch Ah, right you are. Thanks for the clarification. This is not a browser phenomenon, but due to using ess-eval-line-and-step (which is a kind of cut and paste, I guess) to go through the code in emacs. (Maybe there's a better way?) In any case, using } else eliminates the problem. It might, but I tend to write my code with all curly braces (both open and close) on their own line, and will keep doing so because I get to choose my own style. The important question is what the parser thinks. Here's a simplified example: bar - function(x) { if (x) { TRUE } else { FALSE } } print(bar, useSource=FALSE) function (x) { if (x) { TRUE } else { FALSE } } So, R itself thinks that it's OK to have the else starting on it's own line. This means that if you tried to edit 'bar' in ESS (using C-c C-d, for example), you would end up in the same situation (at least for functions for which source is not retained, which include package functions). -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Google's R Style Guide
On 8/28/2009 1:02 PM, Kevin Wright wrote: On Fri, Aug 28, 2009 at 11:49 AM, Duncan Murdoch murd...@stats.uwo.ca mailto:murd...@stats.uwo.ca wrote: On 8/28/2009 12:33 PM, Kevin Wright wrote: On Fri, Aug 28, 2009 at 11:10 AM, Henrik Bengtsson h...@stat.berkeley.edu mailto:h...@stat.berkeley.eduwrote: Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at: http://docs.google.com/View?id=dddzqd53_2646dcw759cb It's useful for beginners and those coding randomly. Like it or not. It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into arguing over if-else or bracketing - we all have our own favorite. /Henrik No, it IS not a waste of time. I have wasted considerable time due the lack of a standard. Yesterday I was debugging panel.levelplot and found this code: if (x.is.factor) { ux - sort(unique(x[!is.na http://is.na(x)])) lx - rep(1, length(ux)) cx - ux } else { ux - sort(unique(x[!is.na http://is.na(x)])) bx - if (length(ux) 1) c(3 * ux[1] - ux[2], ux[-length(ux)] + ux[-1], 3 * ux[length(ux)] - ux[length(ux) - 1])/2 else ux + c(-0.5, 0.5) * minXwid lx - diff(bx) cx - (bx[-1] + bx[-length(bx)])/2 } You can't step through this because the else block starts on a new line. In your other message you were talking about the browser. Does it really have a problem with this (which would be a bug), or are you basically just cutting and pasting? So you have to manually evaluate the value of x.is.factor to determine if it is TRUE or FALSE, scroll down to the line below else and continue stepping through the code. Try not to forget to accidentally evaluate the last brace or do something else that kicks you out of the browser and forces you to start all over again. Now that doesn't sound like the browser. Whatever debugger you are using has a bug. Duncan Murdoch Ah, right you are. Thanks for the clarification. This is not a browser phenomenon, but due to using ess-eval-line-and-step (which is a kind of cut and paste, I guess) to go through the code in emacs. (Maybe there's a better way?) There's a better way to write a debugger, but I don't know if anyone has done it. Rather than submitting a function one line at a time (which doesn't necessarily evaluate the same as submitting it all at once), the debugger could use the built in browser to single step through a complete version of the code, and then synchronize the cursor in the editor view according to the line number information reported by R. This needs line numbers to be recorded in the code, or some tricky pattern matching against the source. Line numbers are recorded by default when you use source() to submit code, but (again by default) this is turned off when packages are installed, so debugging a lattice function would be a little tricky. Revolution's IDE may use the proper method of debugging, I haven't seen it yet. 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.
[R] extracting pvalues from ttest
Hello list, I have a similar issue as this post http://tolstoy.newcastle.edu.au/R/e6/help/09/04/11438.html#options2 and I used the suggestion provided by Jorge with modifications to my data do.call(c,lapply(your_list_with_the_t_tests,function(x) x$p.value)) but I am getting the following error after excuting the code B-by(eo,eo$PlateID, function(.sub) t.test(mcp1~Self_T1D,data=.sub, na.rm=T)) #ttest platewise do.call(c,lapply(B, function(x) x$p.value)) Error in do.call(c, lapply(B, function(x) x$p.value)) : 'what' must be a character string or a function here B is equal to your_list_with_the_t_tests. is something i am doing wrong -- View this message in context: http://www.nabble.com/extracting-pvalues-from-ttest-tp25192381p25192381.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] RODBC: how to set the data-source?
Dumblauskas, Jerry jerry.dumblauskas at credit-suisse.com writes: Looks like Unix ...well, near by: Linux. If so, make sure your script has the proper paths set Here is my set up for an oracle DB export LD_LIBRARY_PATH=/../../instantclient_11_1:/../../unixODBC64_1/lib export ODBCINI=/../..//unixODBC64_1 export ODBCSYSINI=/../..//unixODBC64_1 And of course you need your db defined in ODBC.ini and this will link to your driver code... OK, this was a good hint. After looking around for that ODBC-configuration stuff I also found: /usr/share/doc/r-cran-rodbc/README.gz There is an example-config mentioned, which I changed to my needs. Now I get a result from odbcDataSources() but can't connect to the db: x library(RODBC) x odbcDataSources() x rtest xPostgreSQL x channel - odbcConnect(rtest) xWarning messages: x1: In odbcDriverConnect(st, ...) : x [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver xManager]Data source name not found, and no default driver specified x2: In odbcDriverConnect(st, ...) : ODBC connection failed x channel - odbcConnect(PostgreSQL, rtest) xWarning messages: x1: In odbcDriverConnect(st, ...) : x [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver xManager]Data source name not found, and no default driver specified x2: In odbcDriverConnect(st, ...) : ODBC connection failed x Any further ideas? Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RODBC: how to set the data-source?
So now R can see your odbc ini file -- but at runtime you are still having issues... So it should either be: 1) you have a path not set (for the oracle example below I use LD_LIBRARY_PATH -- not sure about PostGres) 2) your ODBC.ini file doesn't have a line like Driver = /some_random_path/instantclient_11_1/libsqora.so.11.1 Send over your odbc.ini entry -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Oliver Bandel Sent: Friday, August 28, 2009 1:22 PM To: r-h...@stat.math.ethz.ch Subject: Re: [R] RODBC: how to set the data-source? Dumblauskas, Jerry jerry.dumblauskas at credit-suisse.com writes: Looks like Unix ...well, near by: Linux. If so, make sure your script has the proper paths set Here is my set up for an oracle DB export LD_LIBRARY_PATH=/../../instantclient_11_1:/../../unixODBC64_1/lib export ODBCINI=/../..//unixODBC64_1 export ODBCSYSINI=/../..//unixODBC64_1 And of course you need your db defined in ODBC.ini and this will link to your driver code... OK, this was a good hint. After looking around for that ODBC-configuration stuff I also found: /usr/share/doc/r-cran-rodbc/README.gz There is an example-config mentioned, which I changed to my needs. Now I get a result from odbcDataSources() but can't connect to the db: x library(RODBC) x odbcDataSources() x rtest xPostgreSQL x channel - odbcConnect(rtest) xWarning messages: x1: In odbcDriverConnect(st, ...) : x [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver xManager]Data source name not found, and no default driver specified x2: In odbcDriverConnect(st, ...) : ODBC connection failed x channel - odbcConnect(PostgreSQL, rtest) xWarning messages: x1: In odbcDriverConnect(st, ...) : x [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver xManager]Data source name not found, and no default driver specified x2: In odbcDriverConnect(st, ...) : ODBC connection failed x Any further ideas? Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. === Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.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] RODBC: how to set the data-source?
Hi, in /usr/share/doc/r-cran-rodbc/README.gz I found this example: == [testpg] Description = testpg Driver = PostgreSQL Trace = No TraceFile = ServerName = localhost UserName= ripley Port= 5432 Socket = Database= testdb ReadOnly= 0 == I changed it for me to: == [rtest] Description = rtest Driver = PostgreSQL Trace = No TraceFile = ServerName = localhost UserName= oliver Port= 5432 Socket = Database= rtest ReadOnly= 0 == With your hint on the Driver-value: == [rtest] Description = rtest Driver = /usr/lib/odbc/libodbcpsqlS.so Trace = No TraceFile = ServerName = localhost UserName= oliver Port= 5432 Socket = Database= rtest ReadOnly= 0 == Maybe I should give different names for the section and the database?! == [rtestdb] Description = rtest Driver = /usr/lib/odbc/libodbcpsqlS.so Trace = No TraceFile = ServerName = localhost UserName= oliver Port= 5432 Socket = Database= rtest ReadOnly= 0 == xchannel - odbcConnect(rtestdb, rtest) x Warning messages: x 1: In odbcDriverConnect(st, ...) : x [RODBC] ERROR: state IM004, code 0, message [unixODBC][Driver x xManager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed x 2: In odbcDriverConnect(st, ...) : ODBC connection failed So this is not working correctly. Here my settings for the ENV-vars: oli...@siouxsie:~$ echo $ODBCINI /etc/odbc.ini oli...@siouxsie:~$ echo $ODBCSYSINI /etc/ oli...@siouxsie:~$ echo $LD_LIBRARY_PATH /usr/lib/odbc/libodbcpsqlS.so oli...@siouxsie:~$ I have no clue what's the problem now. Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Pls package
Hi, I have managed to format my data into a single datframe consisting of two AsIs response and predictor dataframes in order to supply the plsr command of the pls package for principal components analysis. When I execute the command, however, I get this error: fiber1 - plsr(respmat ~ predmat, ncomp=1, data=inputmat,validation=LOO) Error in model.frame.default(formula = respmat ~ predmat, data = inputmat) : invalid type (list) for variable 'respmat' I happen to have a lot of NAs in some of the columns. Is that the problem? Any input will be greatly appreciated. Thank you very much, in advance. Payam -- Payam Minoofar, Ph.D. Scientist Meissner Filtration Products 4181 Calle Tesoro Camarillo, CA 93012 USA +1 805 388 9911 +1 805 388 5948 fax payam.minoo...@meissner.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] RODBC: how to set the data-source?
... I also tried this one: r...@siouxsie:~# odbcinst -q -d odbcinst: SQLGetPrivateProfileString failed with . r...@siouxsie:~# failed with . ... what a verbose and detailed error message :-( Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RODBC: how to set the data-source?
OK Is your PostGres server on the same Linux box you are running R on? Sample values Server = 169.49.30.69 (localhost host means you are on the same box) Port= 2700 (make sure your port is correct) Also, I am not seeing your id and password I use the signature CONNREAD - odbcConnect(READDBID, uid = READDBUSER, pwd = READDBPWD, believeNRows=FALSE) So for you this would be channel - odbcConnect(rtestdb, uid=rtest, pwd=???, believeNRows=FALSE) The alloc error means you are close... Make sure you can connect to your DB outside of R as well hth -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Oliver Bandel Sent: Friday, August 28, 2009 2:22 PM To: r-h...@stat.math.ethz.ch Subject: Re: [R] RODBC: how to set the data-source? Hi, in /usr/share/doc/r-cran-rodbc/README.gz I found this example: == [testpg] Description = testpg Driver = PostgreSQL Trace = No TraceFile = ServerName = localhost UserName= ripley Port= 5432 Socket = Database= testdb ReadOnly= 0 == I changed it for me to: == [rtest] Description = rtest Driver = PostgreSQL Trace = No TraceFile = ServerName = localhost UserName= oliver Port= 5432 Socket = Database= rtest ReadOnly= 0 == With your hint on the Driver-value: == [rtest] Description = rtest Driver = /usr/lib/odbc/libodbcpsqlS.so Trace = No TraceFile = ServerName = localhost UserName= oliver Port= 5432 Socket = Database= rtest ReadOnly= 0 == Maybe I should give different names for the section and the database?! == [rtestdb] Description = rtest Driver = /usr/lib/odbc/libodbcpsqlS.so Trace = No TraceFile = ServerName = localhost UserName= oliver Port= 5432 Socket = Database= rtest ReadOnly= 0 == xchannel - odbcConnect(rtestdb, rtest) x Warning messages: x 1: In odbcDriverConnect(st, ...) : x [RODBC] ERROR: state IM004, code 0, message [unixODBC][Driver x xManager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed x 2: In odbcDriverConnect(st, ...) : ODBC connection failed So this is not working correctly. Here my settings for the ENV-vars: oli...@siouxsie:~$ echo $ODBCINI /etc/odbc.ini oli...@siouxsie:~$ echo $ODBCSYSINI /etc/ oli...@siouxsie:~$ echo $LD_LIBRARY_PATH /usr/lib/odbc/libodbcpsqlS.so oli...@siouxsie:~$ I have no clue what's the problem now. Oliver __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. === Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.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] extracting pvalues from ttest
I never used by. Is B a list? If not, I am not sure if lapply can take it. Try aggregate(). On Fri, Aug 28, 2009 at 10:53 AM, 1Rnwb sbpuro...@gmail.com wrote: Hello list, I have a similar issue as this post http://tolstoy.newcastle.edu.au/R/e6/help/09/04/11438.html#options2 and I used the suggestion provided by Jorge with modifications to my data do.call(c,lapply(your_list_with_the_t_tests,function(x) x$p.value)) but I am getting the following error after excuting the code B-by(eo,eo$PlateID, function(.sub) t.test(mcp1~Self_T1D,data=.sub, na.rm=T)) #ttest platewise do.call(c,lapply(B, function(x) x$p.value)) Error in do.call(c, lapply(B, function(x) x$p.value)) : 'what' must be a character string or a function here B is equal to your_list_with_the_t_tests. is something i am doing wrong -- View this message in context: http://www.nabble.com/extracting-pvalues-from-ttest-tp25192381p25192381.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sub using info from pattern in 2nd col into part of pattern in 1st column?
I have two data.frame columns and I want to replace part of the first column with the second column : temp-data.frame(matrix(c(54E5,7,56D7,E3,56F12,14,56F3,10,57C5,NA,59A1,3), ncol = 2)) if the 2nd column consists entirely of digits (1 or 2 digits) I want to replace the last digit(s) in the first column with the digits in the second column so ... 54E57 56D7E3 56F12 14 56F310 57C5NA 59A13 generates a new column where some values are replaced : 54E7 56D7 56F14 56F10 57C5 59A3 I can pick out the digits in the 2nd column just fine. But instead of 'xxx' below: sub(^([0-9]{1,2})$,xxx\\1,temp$X2, perl = TRUE) ? How can I sub with what I want from the first column ? Thanks for your help! -chuck (Actually, I also want to do a similar thing where E3 in the second row replaces D7 so 56D7 becomes 56E3, pattern of first column is always [0-9]{1,2}[A-F][0-9]{1,2} , but I'd be happy to just deal with the original stated problem for now as it handles most of my cases) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Calling C funtion from R help Needed
Hello Forum, I'm calling C function from R.It is a small sample trial program. The C function will accept a character and a integer and print them. It is printing some special character instead of input character. Below are the C function, Wrapper code ,R code and R output. Please help me in this issue Thank you in advance C function (Name : checkstr.c) #includestdio.h int n_char(char n,int m) { int result; result = 3; //result = strlen(n); printf(the string is %c\n,n); printf(the silly number is %d\n,m); return result; } Wrapper Code (wrapcheckstr.c) #include stdio.h #includestring.h int n_char(char ,int ); void checkstr_R_wrapper(char *n,int *m, int *result) { *result = n_char(*n,*m); } R code (checkstr.c) checkstr - function(n,m) { if (!is.loaded(symbol.C('checkstr_R_wrapper'))) { dyn.load('checkstr.so') } returned_data = .C('checkstr_R_wrapper', n=as.character(n),m=as.integer(m), result=integer(1)) return(returned_data$result) } result in R source('checkstr.R') checkstr('a',3) Warning in symbol.C(checkstr_R_wrapper) : 'symbol.C' is not needed: please remove it the string is Ð the silly number is 3 [1] 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] std.error
dear sir, i am trying to calculate the standard error of my data (x), i have tried se(x, na.rm=TRUE) and std.error(x) neither have worked and i cannot find an alternative sorry to bother with such a basic problem __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Google's R Style Guide
A few thoughts: -- As for naming preferences, in an interactive R session or answering an R-help question I'm glad I can type lm(log(y) ~ atan(x)) rather than FitLinearModel(CalculateNaturalLogarithm(y) ~ CalculateInverseTangent(x)) -- For consistency, their function makeColName(...) should be MakeColName(...) -- I was happy to see promotion of -. Reading code using '=' for both object assignment and argument setting is a little like fingernails on a blackboard...again and again and... -- It's nice that people have made these guides available Kingsford Jones On Fri, Aug 28, 2009 at 6:59 AM, Esmailesmail...@gmail.com wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not that surprising since Python is also one of the main languages used by Google. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] CHAID in R
well, are you sure if party() can implement chaid? i doubt if chaid is being implemented in any R package. On Fri, Aug 28, 2009 at 7:50 AM, Arup arup.pramani...@gmail.com wrote: Hi..I am trying to run CHAID in R..I have installed the sofyware Party and trying to use the function ctree() to carry out the analysis. but I am getting the following message Error in terms.default(formula, data = data) : no terms component . I am having some Likert scale variable where I have variables like Overall satisfaction(Dependent Variable),Product quality, Brand image,Warranty(Independent variable) etc.. Now can anyone tell me how to run CHAID in this case..what would be the formula? Thanks in Advance.. -- View this message in context: http://www.nabble.com/CHAID-in-R-tp25188573p25188573.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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- == WenSui Liu Blog : statcompute.spaces.live.com Tough Times Never Last. But Tough People Do. - Robert Schuller == [[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.