Re: [R] Optimization failed in fitdistr (Weibull distribution)
On 28 Oct 2013, at 13:07 , kmmoon100 k.m...@student.unimelb.edu.au wrote: Hello everyone, This is Kangmin. I am trying to produce shape and scale of my wind data. My data is based on wind speed frequency with 1km/hr increment. data is described below. Windspeed (km/h)Frequency 1 351 2 147 3 317 4 378 5 527 6 667 7 865 8 970 9 987 10907 11905 12642 131000 14983 15847 16842 17757 18698 19632 20626 21599 22529 23325 24391 25356 26267 27230 28223 29190 30142 31124 32104 3397 3437 3562 3646 3742 3824 399 4013 419 425 432 R codes to calculate shape and scale are described below: Pine.windfrequency.4weeks-read.table(C:/Users/kmoon/Documents/Pine_frequency_4weeks.csv,header=TRUE,sep=,) fitdistr(Pine.windfrequency.4weeks$Frequency, densfun=weibull) I have got an error message when I was using 'fitdistr' function Error in fitdistr(Pine.windfrequency.4weeks$Frequency, densfun = weibull) : optimization failed Please help me calculating shape and scale of weibull distribution. And please understand that I am not an user familiar with R program but I am really trying to make my analysis work on R! There really is no substitute for knowledge and understanding! Did it not occur to you that the Windspeed column needs to enter into your analysis? I suppose you wanted the following: tt-read.delim(/tmp/foo) summary(tt) Windspeed..km.h. Frequency Min. : 1.0 Min. : 2.0 1st Qu.:11.5 1st Qu.: 100.5 Median :22.0 Median : 351.0 Mean :22.0 Mean : 415.7 3rd Qu.:32.5 3rd Qu.: 682.5 Max. :43.0 Max. :1000.0 x - rep(tt$Windspeed..km.h., tt$Frequency) library(MASS) fitdistr(x, densfun=weibull) shape scale 1.99900495 16.43640142 ( 0.01174133) ( 0.06468371) Warning messages: 1: In densfun(x, parm[1], parm[2], ...) : NaNs produced 2: In densfun(x, parm[1], parm[2], ...) : NaNs produced 3: In densfun(x, parm[1], parm[2], ...) : NaNs produced 4: In densfun(x, parm[1], parm[2], ...) Thank you!!! Kangmin. -- View this message in context: http://r.789695.n4.nabble.com/Optimization-failed-in-fitdistr-Weibull-distribution-tp4679167.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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Showing a reduced Time series in a plot
Hi experts, I have a Time serie like this T=(12,13,14,20,65,78,85,35) I do a Transformation on this series and then I have: T ' =(17.22009 27.96722 111.16376 71.33732) I want to show T ' on the plot, but on X-Axis I want to have 8 values, for the first two value on x-axis -17.22009 and... how can I do that? thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] coxph: how to define interaction terms?
Any ideas would be much appreciated; I suspect that this problem of constructing the dummies applies not only to function coxph but to other regression models in R as well. Effectively, my question is how to better control for which dummies and interactions to include in the model and which not. The following code shows a workaround. It works here reasonably well since x has only two levels, but if x has more levels, constructing the dummies manually for each level and keeping track of each of them becomes very difficult. A weird thing is that if onle replace line 4 with the problem reappears. Any idea why? A numeric (0 or 1) variable produces different interactions than a logical variable (FALSE or TRUE). -- View this message in context: http://r.789695.n4.nabble.com/coxph-how-to-define-interaction-terms-tp4679162p4679249.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] TelosB external modules, guide
Hi all, I would like to ask your help regarding connecting external modules to telosb. I have found that tiny os offers many possibilities for that as ADC, GPIOs, SPI, UART, I2C I have never learned anything regarding those. Can someone please let me know if there is any simple guide on these interfaces to show with a primitive example how to start with? I would like to thank you in advance for your help Regards Alex [[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] TelosB external modules, guide
On 29-10-2013, at 12:57, Alaios ala...@yahoo.com wrote: Hi all, I would like to ask your help regarding connecting external modules to telosb. I have found that tiny os offers many possibilities for that as ADC, GPIOs, SPI, UART, I2C I have never learned anything regarding those. Can someone please let me know if there is any simple guide on these interfaces to show with a primitive example how to start with? I would like to thank you in advance for your help What does this have to do with R? Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] speed of makeCluster (package parallel)
Thanks Brian, I thought that forking clusters was better ... but as you mentioned, it is not available on windows. Unfortunately, you do not always choose the OS used by your company ! Arnaud Date: Mon, 28 Oct 2013 17:59:10 + From: Prof Brian Ripley rip...@stats.ox.ac.uk To: r-help@r-project.org Subject: Re: [R] speed of makeCluster (package parallel) Message-ID: 526ea5ee.9060...@stats.ox.ac.uk Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 28/10/2013 16:19, Arnaud Mosnier wrote: Hi all, I am quite new in the world of parallelization and I wonder if there is a way to increase the speed of creation of a parallel socket cluster. The time spend to include threads increase exponentially with the number of It increases linearly in my tests (or a decent OS). But really if parallel computing is worthwhile you will be doing minutes of work on each worker process and the startup time will not be signifcant. thread considered and I use of computer with two 8 cores CPU and thus showing a total of 32 threads in windows 7. The first way to speed things up: use a decent OS: forking clusters is much faster. Currently, I use the default parameters (type = PSOCK), but is there any fine tuning parameters that I can use to take advantage of this system ? Thanks in advance for your help ! Arnaud R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) [[alternative HTML version deleted]] -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[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] maximum value replacement
Dear Users, I have two matrices, one with 12 rows and 124 columns(A) and the other with 1 row and 124 column(B). i want to replace the maximum value in all columns of A with each (single) column value of B. How can i do it?? Thanks indeed in advance, Eliza [[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] maximum value replacement
Hi, Try: sapply(seq_len(ncol(A)),function(i) {indx - which(A[,i]%in% max(A[,i])); A[,i][indx] - B[,i]; A[,i]}) A.K. On Tuesday, October 29, 2013 10:16 AM, eliza botto eliza_bo...@hotmail.com wrote: Dear Users, I have two matrices, one with 12 rows and 124 columns(A) and the other with 1 row and 124 column(B). i want to replace the maximum value in all columns of A with each (single) column value of B. How can i do it?? Thanks indeed in advance, Eliza [[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] How to set default font for lattice graphics?
I tried to change fonts for lattice graphics: trellis.par.set(list(axis.text=list(fontfamily=Monaco), par.strip.text=list(fontfamily=Monaco))) It works for axis.text but not for par.strip.text. trellis.par.set() does not set par.strip.text neither strip.text while I can change font for strip text using: xyplot(0 ~ 0 | Strip Text, par.strip.text=list(fontfamily=Monaco)) How do you change font for strip text globally at once? Or can you change default font globally for all graphical elements? thanks, honza. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R CMD check Error: package MASS was built before R 3.0.0 - not true!?
Hi there, I just updated my R to 3.0.2 and ran R CMD check --as-cran on the just produced new version of fpc. I got an error Error: package MASS was built before R 3.0.0: please re-install it - but I actually *did* re-install MASS without error just before that and within R library(MASS) works just fine. What can I do about this? Best wishes, Christian *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 c.hen...@ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R CMD check Error: package MASS was built before R 3.0.0 - not true!?
Perhaps check your R_LIBS* variables? http://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Christian Hennig ucak...@ucl.ac.uk wrote: Hi there, I just updated my R to 3.0.2 and ran R CMD check --as-cran on the just produced new version of fpc. I got an error Error: package MASS was built before R 3.0.0: please re-install it - but I actually *did* re-install MASS without error just before that and within R library(MASS) works just fine. What can I do about this? Best wishes, Christian *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 c.hen...@ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] maximum value replacement
To Eliza: What if the max in a column is not unique? Given the small size of A, the solution given by Arun seems completely adequate. However, I was wondering if it could be done without the R-level loop in sapply by taking advantage of pmax() . Of course it can. Here's code to illustrate how: A- matrix(sample(15),nr=3) A B - matrix(0,nr=1,nc=5) m - do.call(pmax,data.frame(t(A))) d - dim(A) A[which(A==matrix(m,nr=d[1],nc=d[2],byrow=TRUE))] - B A Note that: 1. This does not generalize to functions other than max or min, afaik. 2. I don't even know if it would be faster for large data, because the data.frame call may slow things down. But it is fully vectorized (I think). So for illustration only, maybe... Cheers, Bert On Tue, Oct 29, 2013 at 7:27 AM, arun smartpink...@yahoo.com wrote: Hi, Try: sapply(seq_len(ncol(A)),function(i) {indx - which(A[,i]%in% max(A[,i])); A[,i][indx] - B[,i]; A[,i]}) A.K. On Tuesday, October 29, 2013 10:16 AM, eliza botto eliza_bo...@hotmail.com wrote: Dear Users, I have two matrices, one with 12 rows and 124 columns(A) and the other with 1 row and 124 column(B). i want to replace the maximum value in all columns of A with each (single) column value of B. How can i do it?? Thanks indeed in advance, Eliza [[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. -- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] maximum value replacement
Thanks bert!!!it worked out perfectly well.thankyou onceagain, Eliza Date: Tue, 29 Oct 2013 08:30:13 -0700 Subject: Re: [R] maximum value replacement From: gunter.ber...@gene.com To: smartpink...@yahoo.com; eliza_bo...@hotmail.com CC: r-help@r-project.org To Eliza: What if the max in a column is not unique? Given the small size of A, the solution given by Arun seems completely adequate. However, I was wondering if it could be done without the R-level loop in sapply by taking advantage of pmax() . Of course it can. Here's code to illustrate how: A- matrix(sample(15),nr=3) A B - matrix(0,nr=1,nc=5) m - do.call(pmax,data.frame(t(A))) d - dim(A) A[which(A==matrix(m,nr=d[1],nc=d[2],byrow=TRUE))] - B A Note that: 1. This does not generalize to functions other than max or min, afaik. 2. I don't even know if it would be faster for large data, because the data.frame call may slow things down. But it is fully vectorized (I think). So for illustration only, maybe... Cheers, Bert On Tue, Oct 29, 2013 at 7:27 AM, arun smartpink...@yahoo.com wrote: Hi, Try: sapply(seq_len(ncol(A)),function(i) {indx - which(A[,i]%in% max(A[,i])); A[,i][indx] - B[,i]; A[,i]}) A.K. On Tuesday, October 29, 2013 10:16 AM, eliza botto eliza_bo...@hotmail.com wrote: Dear Users, I have two matrices, one with 12 rows and 124 columns(A) and the other with 1 row and 124 column(B). i want to replace the maximum value in all columns of A with each (single) column value of B. How can i do it?? Thanks indeed in advance, Eliza [[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. -- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 [[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] sh /bin/sh bad interpreter error when loading certain packages
Dear R People: I'm on a Centos 5 Red Hat system and I'm trying to install such packages as Cairo, Rserve, etc. However, I keep getting an error: sh:/bin/sh bad interpreter. I'm logged in as root, so it shouldn't be a permissions error. Has anyone else run into this, please? Any help would be much appreciated. I'm sure that it's something silly and small. Thanks, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] maximum value replacement
... and while I'm being OCD, note that the which() call in my code can and should be omitted. It's completely superfluous. :-( -- Bert On Tue, Oct 29, 2013 at 8:46 AM, eliza botto eliza_bo...@hotmail.com wrote: Thanks bert!!! it worked out perfectly well. thankyou onceagain, Eliza Date: Tue, 29 Oct 2013 08:30:13 -0700 Subject: Re: [R] maximum value replacement From: gunter.ber...@gene.com To: smartpink...@yahoo.com; eliza_bo...@hotmail.com CC: r-help@r-project.org To Eliza: What if the max in a column is not unique? Given the small size of A, the solution given by Arun seems completely adequate. However, I was wondering if it could be done without the R-level loop in sapply by taking advantage of pmax() . Of course it can. Here's code to illustrate how: A- matrix(sample(15),nr=3) A B - matrix(0,nr=1,nc=5) m - do.call(pmax,data.frame(t(A))) d - dim(A) A[which(A==matrix(m,nr=d[1],nc=d[2],byrow=TRUE))] - B A Note that: 1. This does not generalize to functions other than max or min, afaik. 2. I don't even know if it would be faster for large data, because the data.frame call may slow things down. But it is fully vectorized (I think). So for illustration only, maybe... Cheers, Bert On Tue, Oct 29, 2013 at 7:27 AM, arun smartpink...@yahoo.com wrote: Hi, Try: sapply(seq_len(ncol(A)),function(i) {indx - which(A[,i]%in% max(A[,i])); A[,i][indx] - B[,i]; A[,i]}) A.K. On Tuesday, October 29, 2013 10:16 AM, eliza botto eliza_bo...@hotmail.com wrote: Dear Users, I have two matrices, one with 12 rows and 124 columns(A) and the other with 1 row and 124 column(B). i want to replace the maximum value in all columns of A with each (single) column value of B. How can i do it?? Thanks indeed in advance, Eliza [[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. -- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 -- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sh /bin/sh bad interpreter error when loading certain packages
On Tue, 29 Oct 2013, Erin Hodgess wrote: I'm on a Centos 5 Red Hat system and I'm trying to install such packages as Cairo, Rserve, etc. However, I keep getting an error: sh:/bin/sh bad interpreter. Erin, A Web search shows several possible causes, including incorrect options in /etc/fstab for the partition you're using and working with a DOS-formatted file that uses CR/LF instead of \n (dos2unix cures that). I've not worked with any Red Hat flavor for the past decade but look at results for that search string and you may find a solution appropriate for you. HTH, Rich -- Richard B. Shepard, Ph.D. | Have knowledge, will travel. Applied Ecosystem Services, Inc. | http://www.appl-ecosys.com Voice: 503-667-4517 Fax: 503-667-8863 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R vs octave development strategy (and success)
Hi All, if memory serves me well I recall some paper comparing the relative success in getting mainstream acceptance (as mainstream as statistics can be) of both R and Octave. I remember vaguely that the fact the development strategies (core team vs one main developer) played a major role in the relative success of the two programs. I tried to find this paper, but my goggle skills are failing me. Would anyone know where to find it? Best F signature.asc Description: Message signed with OpenPGP using GPGMail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] coxph: how to define interaction terms?
On Oct 29, 2013, at 4:38 AM, rm wrote: Any ideas would be much appreciated; I suspect that this problem of constructing the dummies applies not only to function coxph but to other regression models in R as well. Effectively, my question is how to better control for which dummies and interactions to include in the model and which not. The following code shows a workaround. It works here reasonably well since x has only two levels, but if x has more levels, constructing the dummies manually for each level and keeping track of each of them becomes very difficult. A weird thing is that if onle replace line 4 with You should go to the R-help Archive to see what the vast majority of readers of this mailing list are seeing. https://stat.ethz.ch/pipermail/r-help/2013-October/362203.html the problem reappears. Any idea why? A numeric (0 or 1) variable produces different interactions than a logical variable (FALSE or TRUE). -- View this message in context: http://r.789695.n4.nabble.com/coxph-how-to-define-interaction-terms-tp4679162p4679249.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 you should read both the fine posting guide and the messages that Nabble suppresses in its effort to masquerade as Rhelp. and provide commented, minimal, self-contained, reproducible code. -- David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Regular Expression returning unexpected results
Hi, So I just took an intro to R programming class and one of the lectures was on Regular Expressions. I've been playing around with various R functions that use Regular Expressions. But this has me stumped. This was part of a quiz and I got it right through understanding the syntax. But when I try to run the thing it returns 'integer(0)'. Can you please tell me what I am doing wrong? #I copied and pasted this: going up and up and up night night at 8 bye bye from up high heading, heading by 9 #THEN lines-readLines(clipboard) #This is what it looks like in R lines [1] going up and up and up [2] night night at 8 [3] bye bye from up high [4] heading, heading by 9 #THIS IS WHAT IS NOT WORKING THE WAY I THOUGHT. I was expecting it to return 2. # night night at 8 follows the pattern: Begins with a word then has at least one space then the same word then has at least one space then a word then a space then a single digit number. grep(^([a-z]+) +\1 +[a-z]+ [0-9],lines) integer(0) #But simple examples DO work grep([Hh],lines) [1] 2 3 4 grep('[0-9]',lines) [1] 2 4 [[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] Inscrutable error message in mgcv: 1 prediction = predict(MI, se.fit=TRUE, newdata=rhc), Error in if (object$inter) X[[i]] - PredictMat(object$margin[[i]], dat, : , argument is of length zer
Sorry, this relates to ?mgcv-FAQ number 5, unfortunately. 'ti' terms were introduced as a much better and cleaner way of allowing smooth main effects and interactions where the interactions are based on 'te' terms: this required some re-engineering of the tensor product smooth objects (the offending 'iter' element of the smooth is how 'ti' terms are distinguished from normal 'te' terms internally). I'm afraid this won't work in the current mgcv without re-fitting the original model. Simon On 26/10/13 10:33, Andrew Crane-Droesch wrote: Dear List, I am trying to reproduce a figure that I made for an analysis that I did a few months ago. Between when I first made the figure and now, I've upgraded to R 3.0.2 and upgraded my operating system (ubuntu 13.04). My codebase, which once works, is throwing an error when I try to use predict.gam on a model object that I saved: 1 prediction = predict(MI,se.fit=TRUE,newdata=rhc) Error in if (object$inter) X[[i]] - PredictMat(object$margin[[i]], dat, : argument is of length zero traceback() gives me the following: 1 traceback() 6: Predict.matrix.tensor.smooth(object, dk$data) 5: Predict.matrix(object, dk$data) 4: Predict.matrix3(object, data) 3: PredictMat(object$smooth[[k]], data) 2: predict.gam(MI, se.fit = TRUE, newdata = rhc) 1: predict(MI, se.fit = TRUE, newdata = rhc) the final function being called looks like this: 1 Predict.matrix.tensor.smooth function (object, data) { m - length(object$margin) X - list() for (i in 1:m) { term - object$margin[[i]]$term dat - list() for (j in 1:length(term)) dat[[term[j]]] - data[[term[j]]] if (object$inter) X[[i]] - PredictMat(object$margin[[i]], dat, n = length(dat[[1]])) else X[[i]] - Predict.matrix(object$margin[[i]], dat) } mxp - length(object$XP) if (mxp 0) for (i in 1:mxp) if (!is.null(object$XP[[i]])) X[[i]] - X[[i]] %*% object$XP[[i]] T - tensor.prod.model.matrix(X) T } Unfortunately, I can't say that I understand how that function is working, beyond that it takes a fitted model object and makes a piece of the model matrix. Any ideas about what this could stem from? Where to start looking to fix it? I could probably do the entire analysis from scratch, but it is quite complex and I'd prefer to save the time. Apologies for non-reproducible code -- the data is big and the script is long. Thanks for any assistance, Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Simon Wood, Mathematical Science, University of Bath BA2 7AY UK +44 (0)1225 386603 http://people.bath.ac.uk/sw283 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sh /bin/sh bad interpreter error when loading certain packages
On Tue, 29 Oct 2013, Erin Hodgess wrote: I'm on a Centos 5 Red Hat system and I'm trying to install such packages as Cairo, Rserve, etc. However, I keep getting an error: sh:/bin/sh bad interpreter. Erin, just to add to what Rich wrote, this may be a disk related result as well. I get this error occasionally on my posix systems. Assuming that you are using install.packages I would check the disk permissions for the files and for the disk they reside on. If, for example, you are installing them on a disk partition that does not have the executable flag set in fstab you may get this error because the system is unwilling to run code resident on those partitions. Collin. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Heteroscedasticity and mgcv.
(1) Am I correct in understanding that Heteroscedasticity is a problem for Generalized Additive Models as it is for standard linear models? I am asking particularly about the GAMs as implemented in the mgcv package. Based upon my online search it seems that some forms of penalized splines can address heteroscedasticity while others cannot and I'm not sure what is true of the methods used in mgcv. - Yes, the mgcv implementation estimates the models via penalized likelihood maximisation, and will be as sensitive to violation of the assumed mean variance relationship as any GLM fitted by MLE. (2) Assuming that heteroscedasticity is a problem for the mgcv GAMs, can anyone recommend a good test implementation? I am familiar with the ncvTest method implemented in the car package but that applies only to lms. - I tend to check for heteroscedasticity graphically using the usual plots of residuals vs fitted values, predictors (and possibly combinations of predictors). I like the way that plots often point towards a solution to any problem they show. best, Simon Thank you, Collin Lynch. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Simon Wood, Mathematical Science, University of Bath BA2 7AY UK +44 (0)1225 386603 http://people.bath.ac.uk/sw283 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Heteroscedasticity and mgcv.
Thank you Simon that's quite helpful! I'll compare that with the GLMSS models. Best, Collin. (1) Am I correct in understanding that Heteroscedasticity is a problem for Generalized Additive Models as it is for standard linear models? I am asking particularly about the GAMs as implemented in the mgcv package. Based upon my online search it seems that some forms of penalized splines can address heteroscedasticity while others cannot and I'm not sure what is true of the methods used in mgcv. - Yes, the mgcv implementation estimates the models via penalized likelihood maximisation, and will be as sensitive to violation of the assumed mean variance relationship as any GLM fitted by MLE. (2) Assuming that heteroscedasticity is a problem for the mgcv GAMs, can anyone recommend a good test implementation? I am familiar with the ncvTest method implemented in the car package but that applies only to lms. - I tend to check for heteroscedasticity graphically using the usual plots of residuals vs fitted values, predictors (and possibly combinations of predictors). I like the way that plots often point towards a solution to any problem they show. best, Simon Thank you, Collin Lynch. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Simon Wood, Mathematical Science, University of Bath BA2 7AY UK +44 (0)1225 386603 http://people.bath.ac.uk/sw283 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R vs octave development strategy (and success)
This covers the topic you mention, but from the perspective of the role of the R Core team. The point about Octave is a single sentence/footnote: Fox, John. 2009. Aspects of the Social Organization and Trajectory of the R Project. The R Journal 1/2: 5-13. http://rjournal.github.io/archive/2009-2/RJournal_2009-2_Fox.pdf - David L Carlson Department of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Federico Calboli Sent: Tuesday, October 29, 2013 11:22 AM To: r-help Subject: [R] R vs octave development strategy (and success) Hi All, if memory serves me well I recall some paper comparing the relative success in getting mainstream acceptance (as mainstream as statistics can be) of both R and Octave. I remember vaguely that the fact the development strategies (core team vs one main developer) played a major role in the relative success of the two programs. I tried to find this paper, but my goggle skills are failing me. Would anyone know where to find it? Best F __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Regular Expression returning unexpected results
On Tue, Oct 29, 2013 at 1:13 PM, Lopez, Dan lopez...@llnl.gov wrote: grep(^([a-z]+) +\1 +[a-z]+ [0-9],lines) Your expression has a typo: R grep(^([a-z]+) +\\1 +[a-z]+ [0-9],lines) [1] 2 -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Regular Expression returning unexpected results
Please read and follow the Posting Guide, in particular re plain text email. You need to keep in mind that the characters in literal strings in R source have to make it into RAM before the regex code can parse it. Since regex needs a single backslash to escape normal parsing and interpret 1 as a back reference, but the R parser also recognizes and removes backslashes in string literals as escape characters, you need to escape the backslash with a backslash in your R string literal. nchar tells you how many characters are in the string. print renders the string as it would need to be entered as R source code. cat sends the string directly to the output (console). Study the output of the following commands at the R prompt. ?Quotes nchar(^([a-z]+) +\1 +[a-z]+ [0-9]) print(^([a-z]+) +\1 +[a-z]+ [0-9]) cat(^([a-z]+) +\1 +[a-z]+ [0-9]) On most systems, a raw character code 1 is also known as Control-A, but the effect it has on the terminal used as the console may vary according to your setup, and it's effect on my system is not clear to me. nchar(^([a-z]+) +\\1 +[a-z]+ [0-9]) print(^([a-z]+) +\\1 +[a-z]+ [0-9]) cat(^([a-z]+) +\\1 +[a-z]+ [0-9]) grep(^([a-z]+) +\\1 +[a-z]+ [0-9],lines) --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Lopez, Dan lopez...@llnl.gov wrote: Hi, So I just took an intro to R programming class and one of the lectures was on Regular Expressions. I've been playing around with various R functions that use Regular Expressions. But this has me stumped. This was part of a quiz and I got it right through understanding the syntax. But when I try to run the thing it returns 'integer(0)'. Can you please tell me what I am doing wrong? #I copied and pasted this: going up and up and up night night at 8 bye bye from up high heading, heading by 9 #THEN lines-readLines(clipboard) #This is what it looks like in R lines [1] going up and up and up [2] night night at 8 [3] bye bye from up high [4] heading, heading by 9 #THIS IS WHAT IS NOT WORKING THE WAY I THOUGHT. I was expecting it to return 2. # night night at 8 follows the pattern: Begins with a word then has at least one space then the same word then has at least one space then a word then a space then a single digit number. grep(^([a-z]+) +\1 +[a-z]+ [0-9],lines) integer(0) #But simple examples DO work grep([Hh],lines) [1] 2 3 4 grep('[0-9]',lines) [1] 2 4 [[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] sh /bin/sh bad interpreter error when loading certain packages
Thanks for the good suggestions! This is how I solved it (with lots of internet help): Create a tempdir. Do a chmod 777 on it. Within R Sys.setenv(TMPDIR=/home/erin/tempdir) install.packages(Cairo,depen=TRUE) and all was well. Thanks, Erin On Tue, Oct 29, 2013 at 12:24 PM, coll...@pitt.edu wrote: On Tue, 29 Oct 2013, Erin Hodgess wrote: I'm on a Centos 5 Red Hat system and I'm trying to install such packages as Cairo, Rserve, etc. However, I keep getting an error: sh:/bin/sh bad interpreter. Erin, just to add to what Rich wrote, this may be a disk related result as well. I get this error occasionally on my posix systems. Assuming that you are using install.packages I would check the disk permissions for the files and for the disk they reside on. If, for example, you are installing them on a disk partition that does not have the executable flag set in fstab you may get this error because the system is unwilling to run code resident on those partitions. Collin. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R vs octave development strategy (and success)
This is from the other perspective http://www.r-project.org/conferences/DSC-2001/Proceedings/Eaton.pdf I can’t spot any direct comparison (and there is no mention of R in the references), but I recall the ideas contrasting the two projects being bandied about at the time. That discussion is likely what is echoed in the Fox paper. John Eaton was running out of steam at the time and the paper is not making a secret of it. -pd On 29 Oct 2013, at 18:32 , David Carlson dcarl...@tamu.edu wrote: This covers the topic you mention, but from the perspective of the role of the R Core team. The point about Octave is a single sentence/footnote: Fox, John. 2009. Aspects of the Social Organization and Trajectory of the R Project. The R Journal 1/2: 5-13. http://rjournal.github.io/archive/2009-2/RJournal_2009-2_Fox.pdf - David L Carlson Department of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Federico Calboli Sent: Tuesday, October 29, 2013 11:22 AM To: r-help Subject: [R] R vs octave development strategy (and success) Hi All, if memory serves me well I recall some paper comparing the relative success in getting mainstream acceptance (as mainstream as statistics can be) of both R and Octave. I remember vaguely that the fact the development strategies (core team vs one main developer) played a major role in the relative success of the two programs. I tried to find this paper, but my goggle skills are failing me. Would anyone know where to find it? Best F __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Regular Expression returning unexpected results
From ?regex (do remember that backslashes need to be doubled when entering R character strings, e.g. from the keyboard). lines[grep(^([a-z]+) +\\1 +[a-z]+ [0-9],lines)] [1] night night at 8 - David L Carlson Department of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Lopez, Dan Sent: Tuesday, October 29, 2013 12:13 PM To: R help (r-help@r-project.org) Subject: [R] Regular Expression returning unexpected results Hi, So I just took an intro to R programming class and one of the lectures was on Regular Expressions. I've been playing around with various R functions that use Regular Expressions. But this has me stumped. This was part of a quiz and I got it right through understanding the syntax. But when I try to run the thing it returns 'integer(0)'. Can you please tell me what I am doing wrong? #I copied and pasted this: going up and up and up night night at 8 bye bye from up high heading, heading by 9 #THEN lines-readLines(clipboard) #This is what it looks like in R lines [1] going up and up and up [2] night night at 8 [3] bye bye from up high [4] heading, heading by 9 #THIS IS WHAT IS NOT WORKING THE WAY I THOUGHT. I was expecting it to return 2. # night night at 8 follows the pattern: Begins with a word then has at least one space then the same word then has at least one space then a word then a space then a single digit number. grep(^([a-z]+) +\1 +[a-z]+ [0-9],lines) integer(0) #But simple examples DO work grep([Hh],lines) [1] 2 3 4 grep('[0-9]',lines) [1] 2 4 [[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] Regular Expression returning unexpected results
Hi Jeff, I was reviewing my old lecture notes and see that the professor did use \1 so I think he was talking about regex in a non-platform specific context. But obviously \\1 is the way to do it in R. The examples you gave me to study really helped. I was also going to ask how to identify empty strings AND blank character strings but you will be happy to know that I figured it out on my own: grep(^ *$,x) Thank you. Thank you Sarah, Bert and David too Dan -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Tuesday, October 29, 2013 11:08 AM To: Lopez, Dan; R help (r-help@r-project.org) Subject: Re: [R] Regular Expression returning unexpected results Please read and follow the Posting Guide, in particular re plain text email. You need to keep in mind that the characters in literal strings in R source have to make it into RAM before the regex code can parse it. Since regex needs a single backslash to escape normal parsing and interpret 1 as a back reference, but the R parser also recognizes and removes backslashes in string literals as escape characters, you need to escape the backslash with a backslash in your R string literal. nchar tells you how many characters are in the string. print renders the string as it would need to be entered as R source code. cat sends the string directly to the output (console). Study the output of the following commands at the R prompt. ?Quotes nchar(^([a-z]+) +\1 +[a-z]+ [0-9]) print(^([a-z]+) +\1 +[a-z]+ [0-9]) cat(^([a-z]+) +\1 +[a-z]+ [0-9]) On most systems, a raw character code 1 is also known as Control-A, but the effect it has on the terminal used as the console may vary according to your setup, and it's effect on my system is not clear to me. nchar(^([a-z]+) +\\1 +[a-z]+ [0-9]) print(^([a-z]+) +\\1 +[a-z]+ [0-9]) cat(^([a-z]+) +\\1 +[a-z]+ [0-9]) grep(^([a-z]+) +\\1 +[a-z]+ [0-9],lines) --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Lopez, Dan lopez...@llnl.gov wrote: Hi, So I just took an intro to R programming class and one of the lectures was on Regular Expressions. I've been playing around with various R functions that use Regular Expressions. But this has me stumped. This was part of a quiz and I got it right through understanding the syntax. But when I try to run the thing it returns 'integer(0)'. Can you please tell me what I am doing wrong? #I copied and pasted this: going up and up and up night night at 8 bye bye from up high heading, heading by 9 #THEN lines-readLines(clipboard) #This is what it looks like in R lines [1] going up and up and up [2] night night at 8 [3] bye bye from up high [4] heading, heading by 9 #THIS IS WHAT IS NOT WORKING THE WAY I THOUGHT. I was expecting it to return 2. # night night at 8 follows the pattern: Begins with a word then has at least one space then the same word then has at least one space then a word then a space then a single digit number. grep(^([a-z]+) +\1 +[a-z]+ [0-9],lines) integer(0) #But simple examples DO work grep([Hh],lines) [1] 2 3 4 grep('[0-9]',lines) [1] 2 4 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R CMD check Error: package MASS was built before R 3.0.0 - not true!?
Christian Hennig ucakche at ucl.ac.uk writes: I just updated my R to 3.0.2 and ran R CMD check --as-cran on the just produced new version of fpc. I got an error Error: package MASS was built before R 3.0.0: please re-install it - but I actually *did* re-install MASS without error just before that and within R library(MASS) works just fine. What can I do about this? Look at .libPaths() and check the directories it lists for a different copy of MASS. Dirk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] mapping data to a geographic map of Europe
Hello, I would like to draw a map of Europe. Each country should be colored depending on how it scores in an index called GPIndex. Say a dark red for real bad countries a light red for those which are not so bad, light blue for the fairly good ones and so on up to the really good ones in a dark blue. I never worked with geographic maps before so I tried library maps but I didn't get far,- especially because all examples I found only seem to work for the United states. So I'm a bit lost. I would be nice if somebody could help me. Thanking you in anticipation! Best regards Claudia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] calculating quantiles
Hi, I'm having the following loop: result - vector(list,100) for (i in 1:max(dat$simNumber)) { result[[i]]-survfit(Surv(dat[dat$simNumber==i,]$TAFD,dat[dat$simNumber==i,]$DV)~1) } In a next step, I would like to calculate the mean, 5% and 95% PI of the Kaplan-Meier estimates of the 100 simulated problems stored under result in the result[[i]]$surv. Can anyone help me with this? Tx! Notice: This e-mail message, together with any attachme...{{dropped:14}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R CMD check Error: package MASS was built before R 3.0.0 - not true!?
Dear Jeff, thanks. Somehow R didn't install MASS where it later looked for it. I still haven't understood properly what caused the problem but I managed to fix it now (by specifying lib when installing it). Best wishes, Christian *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 c.hen...@ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche From: Jeff Newmiller jdnew...@dcn.davis.ca.us Sent: 29 October 2013 15:12 To: Hennig, Christian; r-help-request Mailing List Subject: Re: [R] R CMD check Error: package MASS was built before R 3.0.0 - not true!? Perhaps check your R_LIBS* variables? http://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Christian Hennig ucak...@ucl.ac.uk wrote: Hi there, I just updated my R to 3.0.2 and ran R CMD check --as-cran on the just produced new version of fpc. I got an error Error: package MASS was built before R 3.0.0: please re-install it - but I actually *did* re-install MASS without error just before that and within R library(MASS) works just fine. What can I do about this? Best wishes, Christian *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 c.hen...@ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 'yum install R' failing with tcl/tk issue
Thanks everyone for the replies to my question. The issue turns out to be that I'm on a Rocks cluster head node, and the Rocks distribution disables alternate repos by defaut so it's using the Rocks-6.1 repo which has the old R. In the meantime I've built R 3.0.2 from source, which seems a better idea anyway, as I'll need multiple versions of R installed over time. -M On Fri, Oct 25, 2013 at 7:43 AM, Marc Schwartz marc_schwa...@me.com wrote: On Oct 25, 2013, at 1:29 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On 25/10/2013 02:33, Michael Stauffer wrote: Hi, I'm trying to install R on CentOS 6.4. This is not the right list. But - As the posting guide says, we only support current R here. R 2.10.0 is ancient, and other people seem to have found 3.0.1 RPMs for Centos 6.3. - It seems your RPM is linked against Tcl/Tk 8.4, also ancient. Tcl/Tk 8.6 is current. I suggest you install R 3.0.2 from the sources, in which case R-devel would be the right list. For binary installations on CentOS, R-sig-Fedora is. There are several inconsistencies in the output, as 3.0.1 is available as an RPM from the EPEL repos: http://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/R.html In addition, the output below shows that the R rpm being installed is from 'el5', rather than 'el6'. If this was CentOS 5, rather than 6, R 2.15.2 is available: http://dl.fedoraproject.org/pub/epel/5/x86_64/repoview/R.html Something seems to be amiss with the configuration not getting the right yum repo paths. A Google search came up with this link: http://lancegatlin.org/tech/centos-6-clear-the-yum-cache which might be helpful, as it suggests a similar issue of yum picking up incorrect versions. You may need to reinstall the EPEL repo RPM after these steps. Regards, Marc Schwartz Following some instructions online, I've done this: rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm yum install R But yum fails, with this (full output below): Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtcl8.4.so()(64bit) Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtk8.4.so()(64bit) I have tcl/tk 8.5 already installed. Does anyone have any suggestion? Thanks! Full output: [root@picsl-cluster ~]# yum install R Repository base is listed more than once in the configuration Rocks-6.1 | 1.9 kB 00:00 base | 3.7 kB 00:00 Setting up Install Process Resolving Dependencies -- Running transaction check --- Package R.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libRmath-devel = 2.10.0-2.el5 for package: R-2.10.0-2.el5.x86_64 -- Processing Dependency: R-devel = 2.10.0-2.el5 for package: R-2.10.0-2.el5.x86_64 -- Running transaction check --- Package R-devel.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: R-core = 2.10.0-2.el5 for package: R-devel-2.10.0-2.el5.x86_64 --- Package libRmath-devel.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libRmath = 2.10.0-2.el5 for package: libRmath-devel-2.10.0-2.el5.x86_64 -- Running transaction check --- Package R-core.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libtk8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 -- Processing Dependency: libtcl8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 -- Processing Dependency: libgfortran.so.1()(64bit) for package: R-core-2.10.0-2.el5.x86_64 --- Package libRmath.x86_64 0:2.10.0-2.el5 will be installed -- Running transaction check --- Package R-core.x86_64 0:2.10.0-2.el5 will be installed -- Processing Dependency: libtk8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 -- Processing Dependency: libtcl8.4.so()(64bit) for package: R-core-2.10.0-2.el5.x86_64 --- Package compat-libgfortran-41.x86_64 0:4.1.2-39.el6 will be installed -- Finished Dependency Resolution Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtcl8.4.so()(64bit) Error: Package: R-core-2.10.0-2.el5.x86_64 (Rocks-6.1) Requires: libtk8.4.so()(64bit) You could try using --skip-broken to work around the problem ** Found 57 pre-existing rpmdb problem(s), 'yum check' output follows: foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Client) foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Core) foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Delta) foundation-git-1.7.11.4-0.x86_64 has missing requires of perl(SVN::Ra) 1:guestfish-1.7.17-26.el6.x86_64 has missing requires of libguestfs = ('1', '1.7.17', '26.el6') opt-perl-AcePerl-1.92-0.el6.x86_64 has missing requires of perl(Ace::Browser::LocalSiteDefs) opt-perl-BioPerl-1.6.901-0.el6.noarch has missing
[R] How to save very large matrix?
Hello! I have a very large matrix of results: 5x10. I saved it as RDS, but I would also need to save it as txt or csv. Is there a way to do it? Now, with write.table I am receiving an error: Error in .External2(C_writetable, x, file, nrow(x), p, rnames, sep, eol, : long vectors not supported yet: io.c:1116 Please, help! Many thanks! PM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] (gam) formula: Why different results for terms being factor vs. numeric?
Dear expeRts, If I specify group = as.factor(rep(1:2, each=n)) in the below definition of dat, I get the expected behavior I am looking for. I wonder why I don't get it if group is *not* a factor... My guess was that, internally, factors are treated as natural numbers (and this indeed seems to be true if you convert the latter to factors [essentially meaning changing the levels]), but replacing factors by numeric values (as below) does not provide the same answer. Cheers, Marius require(mgcv) n - 10 yrs - 2000+seq_len(n) set.seed(271) dat - data.frame(year = rep(yrs, 2), group = rep(1:2, each=n), # *not* a factor (as.factor() provides the expected behavior) resp = c(seq_len(n)+runif(n), 5+seq_len(n)+runif(n))) fit3 - gam(resp ~ year + group - 1, data=dat) plot(yrs, fit3$fitted.values[seq_len(n)], type=l, ylim=range(dat$resp), xlab=Year, ylab=Response) # fit group A; mean over all responses in this group lines (yrs, fit3$fitted.values[n+seq_len(n)], col=blue) # fit group B; mean over all responses in this group points(yrs, dat$resp[seq_len(n)]) # actual response group A points(yrs, dat$resp[n+seq_len(n)], col=blue) # actual response group B ## = hmmm... because it is not a factor (?), this does not give an expected answer, ##but gam() still correctly figures out that there are two groups __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R function to locate Excel sheet?
Hi, I am looking for some R function which will tell me, whether a particular sheet in an Excel file (.xlsx/.xls) exists or not. I just need to get some TRUE/FALSE type of answer. Can somebody give me any pointer if such function exists or not? Thanks and regards, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] mapping data to a geographic map of Europe
Check out this link for some examples http://www.r-bloggers.com/maps-in-r-choropleth-maps/ Jean On Tue, Oct 29, 2013 at 12:02 PM, palad...@trustindata.de wrote: Hello, I would like to draw a map of Europe. Each country should be colored depending on how it scores in an index called GPIndex. Say a dark red for real bad countries a light red for those which are not so bad, light blue for the fairly good ones and so on up to the really good ones in a dark blue. I never worked with geographic maps before so I tried library maps but I didn't get far,- especially because all examples I found only seem to work for the United states. So I'm a bit lost. I would be nice if somebody could help me. Thanking you in anticipation! Best regards Claudia __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (gam) formula: Why different results for terms being factor vs. numeric?
Think about it. How can one define a smooth term with a factor??? Further discussion is probably offtopic. Post on stats.stackexchange.com if it still isn't obvious. Cheers, Bert On Tue, Oct 29, 2013 at 1:16 PM, Marius Hofert marius.hof...@math.ethz.ch wrote: Dear expeRts, If I specify group = as.factor(rep(1:2, each=n)) in the below definition of dat, I get the expected behavior I am looking for. I wonder why I don't get it if group is *not* a factor... My guess was that, internally, factors are treated as natural numbers (and this indeed seems to be true if you convert the latter to factors [essentially meaning changing the levels]), but replacing factors by numeric values (as below) does not provide the same answer. Cheers, Marius require(mgcv) n - 10 yrs - 2000+seq_len(n) set.seed(271) dat - data.frame(year = rep(yrs, 2), group = rep(1:2, each=n), # *not* a factor (as.factor() provides the expected behavior) resp = c(seq_len(n)+runif(n), 5+seq_len(n)+runif(n))) fit3 - gam(resp ~ year + group - 1, data=dat) plot(yrs, fit3$fitted.values[seq_len(n)], type=l, ylim=range(dat$resp), xlab=Year, ylab=Response) # fit group A; mean over all responses in this group lines (yrs, fit3$fitted.values[n+seq_len(n)], col=blue) # fit group B; mean over all responses in this group points(yrs, dat$resp[seq_len(n)]) # actual response group A points(yrs, dat$resp[n+seq_len(n)], col=blue) # actual response group B ## = hmmm... because it is not a factor (?), this does not give an expected answer, ##but gam() still correctly figures out that there are two groups __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 save very large matrix?
Have you tried write.csv() or write.matrix()? I really don't know, but they may be more efficient than write.table() with large matrices. Jean On Tue, Oct 29, 2013 at 2:27 PM, Petar Milin pmi...@gmail.com wrote: Hello! I have a very large matrix of results: 5x10. I saved it as RDS, but I would also need to save it as txt or csv. Is there a way to do it? Now, with write.table I am receiving an error: Error in .External2(C_writetable, x, file, nrow(x), p, rnames, sep, eol, : long vectors not supported yet: io.c:1116 Please, help! Many thanks! PM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] mapping data to a geographic map of Europe
On 10/30/2013 04:02 AM, palad...@trustindata.de wrote: Hello, I would like to draw a map of Europe. Each country should be colored depending on how it scores in an index called GPIndex. Say a dark red for real bad countries a light red for those which are not so bad, light blue for the fairly good ones and so on up to the really good ones in a dark blue. I never worked with geographic maps before so I tried library maps but I didn't get far,- especially because all examples I found only seem to work for the United states. So I'm a bit lost. I would be nice if somebody could help me. Hi Claudia, If you draw a map of Europe something like this: world.map-map('world', fill = TRUE, col = 1:10,xlim=c(-15,40),ylim=c(37,70)) you have a col argument that you can pass the colors you want. What you must do is look at the names component of world.map: $names [1] Denmark [2] USSR [3] Italy [4] Netherlands [5] Iraq ... to get the indices of the countries. Say Denmark was fairly good, USSR was fairly bad, and so on. You could then pass colors like this: col=c(lightblue,lightred,...) in the call to map for as many countries as you wanted. Pass NA for those countries that you don't want to color. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Optimization failed in fitdistr (Weibull distribution)
On 10/29/13 19:44, peter dalgaard wrote: SNIP There really is no substitute for knowledge and understanding! Did it not occur to you that the Windspeed column needs to enter into your analysis? SNIP Fortune! cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Conditional wald statistics in ASRemlR
Hi, I'm running a model in ASRemlR and the conditional wald statistics table is producing groupings for the marginality of some variables (A's B's and C's in the tables below) that we are struggling to understand. From our understanding of the model we are fitting and the reference manual, we were expecting main effects to be grouped together (e.g Maring A) and the two way interactions to be grouped together (e.g. Margin B) and to be marginal with respect to main effects and then the three-way interactions to be grouped together (e.g. Margin C) and to be marginal with respect to two-way interactions and main effects. However, this doesn't seem to be happening. For example, the main effect of yr (year - of which there are 2 and is a factor) appears to be given Margin C,which groups it with a number of 2-way interactions and the three-way interactions in terms of marginality. Does anyone have any suggestions as to why is this the case? I have been told that ASReml has a general algorithm for determining the groupings which is not fool proof. Stand-alone ASReml allows you to redefine the groupings. What we would like to know is whether those capabilities exist for the R version, and if not, are there other ways we can set up the model to get the terms in the appropriate grouping. Thanks so much for any suggestions, Sue W1-wald.asreml(m1.asreml, ssType=conditional) asreml 3.0 (15 April 2013), Library: 3.0hj (15 November 2011), X86_64 LogLik S2 DF wall cpu -50111.3907 0.0010 51482 09:02:0315.9 W1$Wald$p-round(1-pf(W1$Wald[,2], W1$Wald[,1], 90),3) W1 $Wald Df F.inc F.con Marginp (Intercept) 1 1772.585100.0 0.000 yr 1 7.6790 9030.0 C 0.007 months5 9.1350 10790.0 A0.000 dayc 1 21.9900 19780.0 B 0.000 haschicks 1 38.0200 50740.0 B 0.000 chickagec 1 6.5720 14020.0 B 0.012 bsc 1 191.3000 192600.0 B 0.000 sex 1 0.7405 742.4 A 0.392 winspc 1 45.7700 44840.0 A 0.000 sinwinc 1 3.4120 2586.0 A 0.068 rainc 1 16.4300 15910.0 A 0.000 months:dayc 5 15.2400 14320.0 C 0.000 months:sex 55.3200 669.1 B 0.000 haschicks:sex 1 7.7330 8906.0 C 0.007 chickagec:sex 1 0.2351 288.6 C 0.629 bsc:sex 1 1.9470 1726.0 C 0.166 sex:winspc 1 23.1700 19900.0 B 0.000 sex:sinwinc 1 12.4700 5766.0 B 0.001 sex:rainc 1 0.7769 625.3 B 0.380 months:sex:winspc 102.7480 2258.0 C 0.005 months:sex:sinwinc 102.6850 1834.0 C 0.006 months:sex:rainc 101.7060 1706.0 C 0.091 ~ Sue Lewis NERC fellow Institute of Evolutionary Biology School of Biological Sciences University of Edinburgh Edinburgh, EH9 3JT, UK Email: sue.le...@ed.ac.uk Tel: +44 (0)131 6505444 http://lewis.bio.ed.ac.uk http://lewis.bio.ed.ac.uk/ ~ The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R function to locate Excel sheet?
Hi here is the solutions using XLConnect package: library(XLConnect) wb - loadWorkbook(path to your Excel file) c(particular sheet name)%in%getSheets(wb) Andrija On Tue, Oct 29, 2013 at 9:26 PM, Ron Michael ron_michae...@yahoo.comwrote: Hi, I am looking for some R function which will tell me, whether a particular sheet in an Excel file (.xlsx/.xls) exists or not. I just need to get some TRUE/FALSE type of answer. Can somebody give me any pointer if such function exists or not? Thanks and regards, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] R function to locate Excel sheet?
You could use the XLConnect package to do this. For example, something like this might do the trick ... library(XLConnect) mysheet - Sheet4 wb - loadWorkbook(C:/temp/MyData.xlsx) wbsheets - getSheets(wb) mysheet %in% wbsheets Jean On Tue, Oct 29, 2013 at 3:26 PM, Ron Michael ron_michae...@yahoo.comwrote: Hi, I am looking for some R function which will tell me, whether a particular sheet in an Excel file (.xlsx/.xls) exists or not. I just need to get some TRUE/FALSE type of answer. Can somebody give me any pointer if such function exists or not? Thanks and regards, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] How to save very large matrix?
Hello, You can use the argument to write.csv or write.table append = TRUE to write the matrix in chunks. Something like the following. bigwrite - function(x, file, rows = 1000L, ...){ passes - NROW(x) %/% rows remaining - NROW(x) %% rows k - 1L write.table(x[k:rows, ], file, row.names = FALSE, ...) k - k + rows for(i in seq_len(passes)[-1]){ write.table(x[k:(rows*i), ], file, append = TRUE, row.names = FALSE, col.names = FALSE, ...) k - k + rows } if(remaining 0) write.table(x[k:NROW(x), ], file, append = TRUE, row.names = FALSE, col.names = FALSE, ...) } f - temp m - matrix(0, 50012, 10) bigwrite(m, f, sep = ,) # Use 'sep' to get a csv file Hope this helps, Rui Barradas Em 29-10-2013 19:27, Petar Milin escreveu: Hello! I have a very large matrix of results: 5x10. I saved it as RDS, but I would also need to save it as txt or csv. Is there a way to do it? Now, with write.table I am receiving an error: Error in .External2(C_writetable, x, file, nrow(x), p, rnames, sep, eol, : long vectors not supported yet: io.c:1116 Please, help! Many thanks! PM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Automatically Remove Aliased Terms from a Model
Hi Thorn, it is not entirely clear (at least for me) what you want to accomplish. an easy and fail safe way of extracting used terms in a (g)lm-object is names(model.frame(l)) if you want to extract terms to finally select a model, have a look at drop1 and/or MASS::dropterm Hth Am 28.10.2013 17:19, schrieb Thaler,Thorn,LAUSANNE,Applied Mathematics: Dear all, I am trying to implement a function which removes aliased terms from a model. The challenge I am facing is that with alias I get the aliased coefficients of the model, which I have to translate into the terms from the model formula. What I have tried so far: --8-- d - expand.grid(a = 0:1, b=0:1) d$c - (d$a + d$b) %% 2 d$y - rnorm(4) d - within(d, {a - factor(a); b - factor(b); c - factor(c)}) l - lm(y ~ a * b + c, d) removeAliased - function(mod) { ## Retrieve all terms in the model X - attr(mod$terms, term.label) ## Get the aliased coefficients rn - rownames(alias(mod)$Complete) ## remove factor levels from coefficient names to retrieve the terms regex.base - unique(unlist(lapply(mod$model[, sapply(mod$model, is.factor)], levels))) aliased - gsub(paste(regex.base, $, sep = , collapse = |), , gsub(paste(regex.base, :, sep = , collapse = |), :, rn)) uF - formula(paste(. ~ ., paste(aliased, collapse = -), sep = -)) update(mod, uF) } removeAliased(l) --8-- This function works in principle, but this workaround with removing the factor levels is just, well, a workaround which could cause problems in some circumstances (when the name of a level matches the end of another variable, when I use a different contrast and R names the coefficients differently etc. - and I am not sure which other cases I am overlooking). So my question is whether there are some more intelligent ways of doing what I want to achieve? Is there a function to translate a coefficient of a LM back to the term, something like: termFromCoef(a1) ## a1 termFromCoef(a1:b1) ## a:b With this I could simply translate the rownames from alias into the terms needed for the model update. Thanks for your help. Kind Regards, Thorn Thaler NRC Lausanne Applied Mathematics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Besuchen Sie uns auf: www.uke.de _ Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Prölß, Rainer Schoppik _ SAVE PAPER - THINK BEFORE PRINTING __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Mean error
Hi, Try either: res1 - apply(mydata[,1:2],2,mean) res2 - colMeans(mydata[,1:2]) identical(res1,res2) #[1] TRUE # Also if you need to find means for each group (Ungrazed vs. Grazed) by(mydata[,-3],mydata[,3],colMeans) #or if column names are V1, V2, V3 aggregate(.~V3,mydata,mean) #or library(plyr) ddply(mydata,.(V3),numcolwise(mean)) A.K. I have a data set with two columns of data that I want to find the mean of. 1 6.225 59.77 Ungrazed 2 6.487 60.98 Ungrazed 3 4.919 14.73 Ungrazed 4 5.130 19.28 Ungrazed 5 5.417 34.25 Ungrazed 6 5.359 35.53 Ungrazed 7 7.614 87.73 Ungrazed 8 6.352 63.21 Ungrazed 9 4.975 24.25 Ungrazed 10 6.930 64.34 Ungrazed 11 6.248 52.92 Ungrazed 12 5.451 32.35 Ungrazed 13 6.013 53.61 Ungrazed 14 5.928 54.86 Ungrazed 15 6.264 64.81 Ungrazed 16 7.181 73.24 Ungrazed 17 7.001 80.64 Ungrazed 18 4.426 18.89 Ungrazed 19 7.302 75.49 Ungrazed 20 5.836 46.73 Ungrazed 21 10.253 116.05 Ungrazed 22 6.958 38.94 Grazed 23 8.001 60.77 Grazed 24 9.039 84.37 Grazed 25 8.910 70.11 Grazed 26 6.106 14.95 Grazed 27 7.691 70.70 Grazed 28 8.988 80.31 Grazed 29 8.975 82.35 Grazed 30 9.844 105.07 Grazed 31 8.508 73.79 Grazed 32 7.354 50.08 Grazed 33 8.643 78.28 Grazed 34 7.916 41.48 Grazed 35 9.351 98.47 Grazed 36 7.066 40.15 Grazed 37 8.158 52.26 Grazed 38 7.382 46.64 Grazed 39 8.515 71.01 Grazed 40 8.530 83.03 Grazed This is from an introduction handout that instructs me to enter the command mean(mydata[,1:2]) but when I enter it, I get an error message Warning message: In mean.default(mydata[, 1:2]) : argument is not numeric or logical: returning NA I've tried tacking on na.rm=T to the end of it, but I get the same message. Can someone tell me what I'm doing wrong, or how to fix it? I've tried searching the forum, but can't find a post relevant to this 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] How to save very large matrix?
On 29/10/2013 20:42, Rui Barradas wrote: Hello, You can use the argument to write.csv or write.table append = TRUE to write the matrix in chunks. Something like the following. That was going to be my suggestion. But the reason long vectors have not been implemented is that is rather implausible to be useful. A text file with the values of such a numeric matrix is likely to be 100GB. What are you going to do with such a file? For transfer to another program I would seriously consider a binary format (e.g. use writeBin), as it is the conversion to and from text that is time consuming. Some experiments suggest that it would take hours to write and at least an hour to read such a file[*], on a very fast machine with a start-of-the-art SSD. [*] a file with reasonable-precision real numbers, not zeroes. bigwrite - function(x, file, rows = 1000L, ...){ passes - NROW(x) %/% rows remaining - NROW(x) %% rows k - 1L write.table(x[k:rows, ], file, row.names = FALSE, ...) k - k + rows for(i in seq_len(passes)[-1]){ write.table(x[k:(rows*i), ], file, append = TRUE, row.names = FALSE, col.names = FALSE, ...) k - k + rows } if(remaining 0) write.table(x[k:NROW(x), ], file, append = TRUE, row.names = FALSE, col.names = FALSE, ...) } f - temp m - matrix(0, 50012, 10) bigwrite(m, f, sep = ,) # Use 'sep' to get a csv file Hope this helps, Rui Barradas Em 29-10-2013 19:27, Petar Milin escreveu: Hello! I have a very large matrix of results: 5x10. I saved it as RDS, but I would also need to save it as txt or csv. Is there a way to do it? Now, with write.table I am receiving an error: Error in .External2(C_writetable, x, file, nrow(x), p, rnames, sep, eol, : long vectors not supported yet: io.c:1116 Please, help! Many thanks! PM -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to save very large matrix?
Hello, On Oct 29, 2013, at 10:16 PM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On 29/10/2013 20:42, Rui Barradas wrote: Hello, You can use the argument to write.csv or write.table append = TRUE to write the matrix in chunks. Something like the following. That was going to be my suggestion. But the reason long vectors have not been implemented is that is rather implausible to be useful. A text file with the values of such a numeric matrix is likely to be 100GB. What are you going to do with such a file? For transfer to another program I would seriously consider a binary format (e.g. use writeBin), as it is the conversion to and from text that is time consuming. I need to submit it to a cluster analysis (k-means). From an independent source I have been advised to use means algorithm written in C which is very fast and efficient. It asks for a txt file as an input. I tried few options in R, where I am more comfortable, but solution never came, even after too many hours. Thanks! Best, PM [[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] Can not read Excel file correctly
Hi, I need to read an Excel file which can be available in following link: http://www45.zippyshare.com/v/43626889/file.html Now I wanted to read the 1st sheet of this Excel file. Below are my code so far (I saved that file in 'F:' drive): library(XLConnect) Loading required package: rJava XLConnect 0.2-5 by Mirai Solutions GmbH http://www.mirai-solutions.com , http://miraisolutions.wordpress.com readWorksheetFromFile(f:/Dat1.xlsx, sheet = 1) Col1 Col2 Col3 Col4 1 NA NA 2013-05-01 NA 2 NA NA NA NA 3 1930-01-01 NA NA NA 4 NA 3127312736128730 NA NA 5 NA NA NA NA 6 NA NA NA SAsSag What I saw that, the element in A1 cell is missing. Also the data in C1 A4 are read in different format. In Excel file, it is Month-Year format, however what I see is Year-Month-Day format. I have many such files, therefore I do not want to convert them to csv (or any other). Doing so will be cumbersome. Can somebody here help me how to read that file in proper format? Thanks for your time. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 save very large matrix?
Hi Petar, If you're going to share this matrix across R sessions, save()/load() is probably one of your best options. Otherwise, you could try the rhdf5 package from Bioconductor: 1. Install the package with: source(http://bioconductor.org/biocLite.R;) biocLite(rhdf5) 2. Then: library(rhdf5) h5createFile(my_big_matrix.h5) # write a matrix my_big_matrix - matrix(runif(5000*1), nrow=5000) attr(my_big_matrix, scale) - liter h5write(my_big_matrix, my_big_matrix.h5, my_big_matrix) # takes 1 min. # file size on disk is 248M # read a matrix my_big_matrix - h5read(my_big_matrix.h5, my_big_matrix) # takes 7.4 sec. Multiply the above numbers (obtained on a laptop with a traditional hard drive) by 100 for your monster matrix, or less if you have super fast I/O. 2 advantages of using the HDF5 format: (1) should not be too hard to use the HDF5 C library in the C code you're going to use to read the matrix, and (2) my understanding is that HDF5 is good at letting you access arbitrary slices of the data so chunk-processing should be easy and efficient: http://www.hdfgroup.org/HDF5/ Cheers, H. On 10/29/2013 02:34 PM, Petar Milin wrote: Hello, On Oct 29, 2013, at 10:16 PM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On 29/10/2013 20:42, Rui Barradas wrote: Hello, You can use the argument to write.csv or write.table append = TRUE to write the matrix in chunks. Something like the following. That was going to be my suggestion. But the reason long vectors have not been implemented is that is rather implausible to be useful. A text file with the values of such a numeric matrix is likely to be 100GB. What are you going to do with such a file? For transfer to another program I would seriously consider a binary format (e.g. use writeBin), as it is the conversion to and from text that is time consuming. I need to submit it to a cluster analysis (k-means). From an independent source I have been advised to use means algorithm written in C which is very fast and efficient. It asks for a txt file as an input. I tried few options in R, where I am more comfortable, but solution never came, even after too many hours. Thanks! Best, PM [[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. -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpa...@fhcrc.org Phone: (206) 667-5791 Fax:(206) 667-1319 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] deparse: replacing all by \
Dear list, I need to use the function deparse in a specific situation. But, it always replace any occurence of by \. For example: arg - deparse(args(cov), width.cutoff = 100L)[1] arg [1] function (x, y = NULL, use = \everything\, method = c(\pearson\, \kendall\, \spearman\)) Some characters added by deparse are not desirable: \ before all and final space. How is the best way to get the result (using deparse) clean like below? [1] function (x, y = NULL, use = everything, method = c(pearson, kendall, spearman)) Any help is welcome! Best, -- ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ Jose Claudio Faria Estatistica UESC/DCET/Brasil joseclaudio.faria at gmail.com Telefones: 55(73)3680.5545 - UESC 55(73)9100.7351 - TIM 55(73)8817.6159 - OI ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] deparse: replacing all by \
On 13-10-29 7:42 PM, Jose Claudio Faria wrote: Dear list, I need to use the function deparse in a specific situation. But, it always replace any occurence of by \. No it doesn't. That's just how print() displays quotes. Use cat() and you can see what's really there. Duncan Murdoch For example: arg - deparse(args(cov), width.cutoff = 100L)[1] arg [1] function (x, y = NULL, use = \everything\, method = c(\pearson\, \kendall\, \spearman\)) Some characters added by deparse are not desirable: \ before all and final space. How is the best way to get the result (using deparse) clean like below? [1] function (x, y = NULL, use = everything, method = c(pearson, kendall, spearman)) Any help is welcome! Best, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] big speed difference in source btw. R 2.15.2 and R 3.0.2 ?
Dear All, is it known that source works much faster in R 2.15.2 than in R 3.0.2 ? In the example below I observe e.g. for a data.frame with 10^7 rows the following timings: R version 2.15.2 Patched (2012-11-29 r61184) length: 1e+07 user system elapsed 62.040.22 62.26 R version 3.0.2 Patched (2013-10-27 r64116) length: 1e+07 user system elapsed 388.63 176.42 566.41 Is there a way to speed R version 3.0.2 up to the performance of R version 2.15.2? best regards, Heinz Tüchler example: sessionInfo() sample.vec - c('source', 'causes', 'R', 'to', 'accept', 'its', 'input', 'from', 'the', 'named', 'file', 'or', 'URL', 'or', 'connection') dmp.size - c(10^(1:7)) set.seed(37) for(i in dmp.size) { df0 - data.frame(x=sample(sample.vec, i, replace=TRUE)) dump('df0', file='testdump') cat('length:', i, '\n') print(system.time(source('testdump', keep.source = FALSE, encoding=''))) } output for R version 2.15.2 Patched (2012-11-29 r61184): sessionInfo() R version 2.15.2 Patched (2012-11-29 r61184) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=German_Switzerland.1252 LC_CTYPE=German_Switzerland.1252 [3] LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C [5] LC_TIME=German_Switzerland.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base sample.vec - + c('source', 'causes', 'R', 'to', 'accept', 'its', 'input', 'from', 'the', + 'named', 'file', 'or', 'URL', 'or', 'connection') dmp.size - c(10^(1:7)) set.seed(37) for(i in dmp.size) { + df0 - data.frame(x=sample(sample.vec, i, replace=TRUE)) + dump('df0', file='testdump') + cat('length:', i, '\n') + print(system.time(source('testdump', keep.source = FALSE, +encoding=''))) + } length: 10 user system elapsed 0 0 0 length: 100 user system elapsed 0 0 0 length: 1000 user system elapsed 0 0 0 length: 1 user system elapsed 0.020.000.01 length: 1e+05 user system elapsed 0.210.000.20 length: 1e+06 user system elapsed 4.470.044.51 length: 1e+07 user system elapsed 62.040.22 62.26 output for R version 3.0.2 Patched (2013-10-27 r64116): sessionInfo() R version 3.0.2 Patched (2013-10-27 r64116) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=German_Switzerland.1252 LC_CTYPE=German_Switzerland.1252 [3] LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C [5] LC_TIME=German_Switzerland.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base sample.vec - + c('source', 'causes', 'R', 'to', 'accept', 'its', 'input', 'from', 'the', + 'named', 'file', 'or', 'URL', 'or', 'connection') dmp.size - c(10^(1:7)) set.seed(37) for(i in dmp.size) { + df0 - data.frame(x=sample(sample.vec, i, replace=TRUE)) + dump('df0', file='testdump') + cat('length:', i, '\n') + print(system.time(source('testdump', keep.source = FALSE, +encoding=''))) + } length: 10 user system elapsed 0 0 0 length: 100 user system elapsed 0 0 0 length: 1000 user system elapsed 0 0 0 length: 1 user system elapsed 0.010.000.01 length: 1e+05 user system elapsed 0.360.060.42 length: 1e+06 user system elapsed 6.021.867.88 length: 1e+07 user system elapsed 388.63 176.42 566.41 -- Heinz Tüchler +4317146261 / +436605653878 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Use correlation matrix to get values for a new data frame
I am not sure that I fully understand your question, but the mvrnorm function in the MASS package may do what you want. It will generate multivariate normal data with a specified correlation(covariance). If that is not what you want then try to explain a bit more about what you want your final result to be. On Sun, Oct 27, 2013 at 2:46 PM, tobias schlager tobebry...@me.com wrote: Dear all, i am a bit stuck with a problem right now. Specifically, I have a correlation matrix, and a dataframe on which I want to project the values. However, I am not sure how I can do this. Here the calculations I made, I wanted to get a matrix that shows the values for each of the combinations of the ten variables in „d, so the new data is „newdat“. How might this be possible? Thanks a lot, Tobi x1 - c(1,0,0,1,0,1,0,0,0,0) x2 - c(0,1,0,0,0,1,0,0,0,1) x3 - c(0,0,1,0,1,0,1,0,0,0) x4 - c(1,0,0,1,0,0,0,0,1,0) x5 - c(0,0,1,0,1,0,0,1,0,1) x6 - c(1,1,0,0,0,1,0,0,0,0) x7 - c(0,0,1,0,0,0,1,1,0,0) x8 - c(0,0,0,0,1,0,1,1,0,0) x9 - c(0,0,0,1,0,0,0,0,1,0) x10 - c(0,1,0,0,1,0,0,0,0,1) x1c - ifelse(x1==1, runif(4, -1, 1), 0); x2c - ifelse(x2==1, runif(4, -1, 1), 0); x3c - ifelse(x3==1, runif(4, -1, 1), 0); x4c - ifelse(x4==1, runif(4, -1, 1), 0); x5c - ifelse(x5==1, runif(4, -1, 1), 0); x6c - ifelse(x6==1, runif(4, -1, 1), 0); x7c - ifelse(x7==1, runif(4, -1, 1), 0); x8c - ifelse(x8==1, runif(4, -1, 1), 0); x9c - ifelse(x9==1, runif(4, -1, 1), 0); x10c - ifelse(x10==1, runif(4, -1, 1), 0); c - cbind(x1c,x2c,x3c,x4c,x5c,x6c,x7c,x8c,x9c,x10c); c c - data.frame(c) c[1,1] - 1; c[2,2] - 1; c[3,3] - 1; c[4,4] - 1; c[5,5] - 1; c[6,6] - 1; c[7,7] - 1; c[8,8] - 1; c[9,9] - 1; c[10,10] - 1; # get symmetry c[2,1] -c[1,2]; c[3,1] -c[1,3]; c[4,1] -c[1,4]; c[5,1] -c[1,5]; c[6,1] -c[1,6]; c[7,1] -c[1,7]; c[8,1] -c[1,8]; c[9,1] -c[1,9]; c[10,1] -c[1,10]; c[3,2] -c[2,3]; c[4,2] -c[2,4]; c[5,2] -c[2,5]; c[6,2] -c[2,6]; c[7,2] -c[2,7]; c[8,2] -c[2,8]; c[9,2] -c[2,9]; c[10,2] -c[2,10]; c[4,3] -c[3,4]; c[5,3] -c[3,5]; c[6,3] -c[3,6]; c[7,3] -c[3,7]; c[8,3] -c[3,8]; c[9,3] -c[3,9]; c[10,3] -c[3,10]; c[5,4] -c[4,5]; c[6,4] -c[4,6]; c[7,4] -c[4,7]; c[8,4] -c[4,8]; c[9,4] -c[4,9]; c[10,4] -c[4,10]; c[6,5] -c[5,6]; c[7,5] -c[5,7]; c[8,5] -c[5,8]; c[9,5] -c[5,9]; c[10,5] -c[5,10]; c[7,6] -c[6,7]; c[8,6] -c[6,8]; c[9,6] -c[6,9]; c[10,6] -c[6,10]; c[8,7] -c[7,8]; c[9,7] -c[7,9]; c[10,7] -c[7,10]; c[9,8] -c[8,9]; c[10,8] -c[8,10]; c[10,9] -c[9,10]; d - c (c[,1], c[,2], c[,3],c[,4],c[,5],c[,6],c[,7],c[,8],c[,9],c[,10]) newdat - expand.grid(x1c=c(1,0),x2c=c(1,0),x3c=c(1,0),x4c=c(1,0),x5c=c(1,0),x6c=c(1,0),x7c=c(1,0),x8c=c(1,0),x9c=c(1,0),x10c=c(1,0)) Dr. Tobias Schlager Projektleiter [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] add a color bar in a plot
Hi all, I am trying to add a color legend to my plot. As an example I am giving you a bit of code that you can run. I am sharing for everyone a small data snipset that you can load https://www.dropbox.com/s/fh8jhwujgunmtrb/DataToPlotAsImage.Rdata load(DataToPlotAsImage.Rdata) require(plotrix) browser() test-data # this transforms the values of test into red-yellow color2D.matplot(test,axes=F,xlab=,ylab=,main=color.scale, extremes=c(#FF,#00),show.legend=FALSE) axis(1,at=seq(1,ncol(test),length.out=10),labels=seq(201,300,length.out=10)) color.legend(104,30,112,70,seq(-110,-30,length=11), align=rb,rect.col=color.scale(1:30,1,c(0,1),0),gradient=y) as you can see I have problems where the legend appears. My par(usr returned me par(usr) # [1] 0 351 0 200 but I am not sure how to read that to place the legend at a useful place. second I am not sure why the image is so full with black rows.. What I want is to have the legend visible and later on customize the x axis to write custom string of different size... First I need though to fix the more severe problems as I have described RegardsAlex [[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] merging rows that share columns (but not all of them)
Hi, May be this helps. library(plyr) res - join_all(lapply(my.list,function(x) as.data.frame(t(unlist(x,type=full) res # AICc Intercept Burned StandAge TreeDensity RoadDensity Intercept.SE #1 108.2303 -1.3358063 1.351866 0.05606852 -0.1886327 -0.03904008 0.8392739 #2 207.4494 0.1749414 NA NA NA NA 0.1644731 # Burned.SE StandAge.SE TreeDensity.SE RoadDensity.SE #1 0.5440936 0.009632702 0.03885338 0.02995221 #2 NA NA NA NA A.K. Hi, I have a list where the columns are generally subsets of a full set of columns. Below is an example where the 1st vector in the list has the full set of columns and the 2nd has a very reduced set of those columns. What is a good way to merge these lists together so that the resulting data.frame has all of the columns and either blanks or NA's (whatever) in the empty elements for the reduced set? Hopefully that makes sense, and I thank you ahead of time for any suggestions. Chuck my.list - dput( list(out.j[[4]], out.j[[5]]) ) list(list(structure(c(108.230267668738, -1.33580630289532, 1.35186573380126, 0.0560685186378393, -0.188632664093942, -0.0390400817030916, 0.839273914449761, 0.544093628209087, 0.0096327018436, 0.038853380878141, 0.0299522140838543), .Names = c(AICc, Intercept, Burned, StandAge, TreeDensity, RoadDensity, Intercept.SE, Burned.SE, StandAge.SE, TreeDensity.SE, RoadDensity.SE))), structure(c(207.449399095215, 0.174941449287965, 0.164473092811635), .Names = c(AICc, Intercept, Intercept.SE))) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fitting multiple horizontal lines to data
Dear R-users, I am trying to fit my data using one or more horizontal lines. If my data is in y, I understand that lm(y~1) will fit a single horizontal line at mean(y). However, I want to try and fit the data with multiple horizontal lines if that reduces the error while still keeping the number of horizontal lines to be as small as possible. Concretely, assume: y=c(2,4,2,4,2,4,2,4,8,10,8,10,8,10,8,10) lm(y~1) fits a single horizontal line at y=6. A better fit using multiple horizontal lines would be 2 horizontal lines at y = 3 and y = 9. An even better (if the objective is to solely minimize error and not penalize the number of horizontal lines) would be 4 horizontal lines at y=2, y=4, y=8, y=10. kMeans works for the simple example I have shown, but I would like advice on whether there is a better method that will work when the data does not fit a horizontal line exactly. Thanks, -sashi. [[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] rpy2 and user defined functions from R
Hello again! I'm using python with a module rpy2 to call functions from R. It works fine on built in R functions like rnorm. However, I would like to access user-defined functions as well. For those of you who use this, I have: import rpy2.robjects as R x = R.r.buzz(3) R object as no attribute buzz (user defined function of buzz) This is on a Centos 5 machine with R-3.0.2 and python of 2.7.5. Thanks for any help. Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.