Re: [R] Zero inflated Models- pscl package
On Mon, 10 Sep 2012, Filipa J. wrote: Dear R users, I want to apply zero inflated models with continuous and categorical variables and I used pscl package from R and the zeroinf() function. My question are the follow: a) The value of fitted.values is mu or (1-p)*mu? where p is the probability of zero came form a zero point mass See vignette(countreg, package = pscl), especially Appendix C. The default predict(..., type = response) and fitted(...) both compute the expected value Equation (8). This corresponds to your (1-p)*mu but uses a different notation. b) If mu is zero, how do i know if it is a zero from the zero point mass or from the count process? You can inspect all component: Your mu (exp(x'b) in the notation of the paper) can be computed with predict(..., type = count) and p (pi in the paper) with predict(..., type = zero). Best, Z __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help in running r query in pre defined time intervals
On Sep 10, 2012, at 8:48 PM, Bhupendrasinh Thakre wrote: Hi Team, I am not sure how to run some r queries in continuos time interval for say in each 30 minutes. Will be very grateful if some one can give me some heads up in good direction. Unfortunately I dont have any query written or data which I can share and I know most of the respected people will not like it but it's kind of a thought which is perturbing me from some days. The cut.POSIXt may be worth examinatuion: table( cut( Sys.time() + rnorm(100, 0, 3600), 30 mins) ) 2012-09-10 21:31:00 2012-09-10 22:01:00 2012-09-10 22:31:00 2012-09-10 23:01:00 4 7 9 9 2012-09-10 23:31:00 2012-09-11 00:01:00 2012-09-11 00:31:00 2012-09-11 01:01:00 26 22 8 8 2012-09-11 01:31:00 2012-09-11 02:01:00 2012-09-11 02:31:00 5 1 1 -- David Winsemius, MD 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] CRAN, install packages problem on networked PC
Dear List, I have a problem connecting to a CRAN mirror through a networked computer running Vista Enterprise on a Dell PC. I added http_proxy=http://gannet/ http_proxy_user=ask to the Target in the R shortcut, completed the username and password in the Proxy Authentication window, but get the following warning: Warning message: In open.connection(con, r) : unable to resolve 'gannet' When I try to download a package I get the following messages: utils:::menuInstallPkgs() Warning: unable to access index for repository http://cran.csiro.au/bin/windows/contrib/2.15 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.15 Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified This approach worked for me on other networks but this is the first time I've encountered this issue. Any help is appreciated. Cheers, Neil Collier Edith Cowan University This e-mail is confidential. If you are not the intended recipient you must not disclose or use the information contained within. If you have received it in error please return it to the sender via reply e-mail and delete any record of it from your system. The information contained within is not the opinion of Edith Cowan University in general and the University accepts no liability for the accuracy of the information provided. CRICOS IPC 00279B [[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] Contrasts for 2x4 interaction in mixed effects model
On Sep 10, 2012, at 5:59 PM, semperparatus wrote: I want to change it because I don't want to compare in this instance between conditions, but I simply want to see the contrast t-statistic between patient and control at every level of condition (1, 2, and 3). From there I'd like to be able to plot the t-statistic for the contrast between patient and control at level 1 of conditon, level 2 of condition, and level 3 of condition, each with error bars. In the post I responded to the output gave fixed effect output for SecA:Fir1, SecB:Fir1, SecC:Fir1, and SecD:Fir1. I'm hoping to get the same sort of output but for mine it would be Cond1:Patient1, Cond2:Patient1, Cond3:Patient1. It does not appear that you have the same situation as was being discussed earlier: Yours was: ' *When I tried using the syntax you used with my model: lmer(H.y. ~ patient*stance*cond +(cond/patient) + (1|subj), data=H), I got this result, which seems to be using condition 1 as a part of the baseline. Any idea how to change that?*' The other was: test - lmer(Latency ~ (Nuisance1*Nuisance2) + (Sec/Fir) + (1|Subject) + (1|Item), datatotest) He had separated his nuisance parameters from the 2 variables (Sec and Fir) for which he was interested in examining contrasts. PLEASE learn to include context. -- David Winsemius, MD 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] Searching from Dataframe.
Hi, i have a dataframe containing some values. for eg:- MyDataFrame- Name Age Place -------- Aby 12USA Raj25UK Romi32ENG Amy 31IND My requirement what is, i have a search key word[it should search from all the columns], that i need to find out from this dataframe. If search keyword found , it should return that particular row and column number. For eg:- My search keyword is ENG. After searching, it should return particular row column number. Here it is MyDataFrame[3,3] Can anyone help me please ? - Antony. -- View this message in context: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Searching from Dataframe.
On Sep 11, 2012, at 12:11 AM, Rantony wrote: Hi, i have a dataframe containing some values. for eg:- MyDataFrame- Name Age Place -------- Aby 12USA Raj25UK Romi32ENG Amy 31IND My requirement what is, i have a search key word[it should search from all the columns], that i need to find out from this dataframe. If search keyword found , it should return that particular row and column number. For eg:- My search keyword is ENG. After searching, it should return particular row column number. Here it is MyDataFrame[3,3] which(MyDataFrame==ENG, arr.ind=TRUE) row col [1,] 3 3 You can certainly massage those values in any paste()y expression you choose. -- David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] predict arima
Hello everybody, can someone please help me with this, please? Kind regards,Fabian From: schrot...@hotmail.com To: r-help@r-project.org Date: Mon, 10 Sep 2012 14:51:01 + Subject: [R] predict arima Hello, I have a question regarding the predict command for ARIMA models. Why do I not have to give any input except the number of steps for the forecast? Which input value is used (in my case for y(t))? Will the last parameter of the estimate vector be used (in my example 6)? x - c(1,2,3,4,5,6) model - arima(x, order=c(1,0,0), method=ML) predict(model, n.ahead = 1) - Model: y(t+1) = 3.5 + 0.8925 * y(t) Which value is used for y(t) in the case of n.ahead = 1? Thank you,Fabian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] CRAN, install packages problem on networked PC
I see that you have set a proxy to a nonstandard DNS name, and your first warning is that your computer couldn't figure out where that proxy is. This is not an R question... please talk to your network administrator about whether you have a proxy and what it is called. --- 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. Neil COLLIER n.coll...@ecu.edu.au wrote: Dear List, I have a problem connecting to a CRAN mirror through a networked computer running Vista Enterprise on a Dell PC. I added http_proxy=http://gannet/ http_proxy_user=ask to the Target in the R shortcut, completed the username and password in the Proxy Authentication window, but get the following warning: Warning message: In open.connection(con, r) : unable to resolve 'gannet' When I try to download a package I get the following messages: utils:::menuInstallPkgs() Warning: unable to access index for repository http://cran.csiro.au/bin/windows/contrib/2.15 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.15 Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified This approach worked for me on other networks but this is the first time I've encountered this issue. Any help is appreciated. Cheers, Neil Collier Edith Cowan University This e-mail is confidential. If you are not the intended recipient you must not disclose or use the information contained within. If you have received it in error please return it to the sender via reply e-mail and delete any record of it from your system. The information contained within is not the opinion of Edith Cowan University in general and the University accepts no liability for the accuracy of the information provided. CRICOS IPC 00279B [[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] Integration between R and Microsoft SQL Server?
Oracle has its own R integration called Oracle R Enterprise: http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/index.html Is there a same kind of integration available for Microsoft SQL Server? If there is not, does MS have any plans to integrate R and SQL Server database engine? -J __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] predict arima
On Sep 11, 2012, at 12:26 AM, Peter Jackson wrote: Hello everybody, can someone please help me with this, please? Kind regards,Fabian From: schrot...@hotmail.com To: r-help@r-project.org Date: Mon, 10 Sep 2012 14:51:01 + Subject: [R] predict arima Hello, I have a question regarding the predict command for ARIMA models. Why do I not have to give any input except the number of steps for the forecast? Which input value is used (in my case for „y(t)‰)? Will the last parameter of the estimate vector be used (in my example „6‰)? x - c(1,2,3,4,5,6) model - arima(x, order=c(1,0,0), method=ML) predict(model, n.ahead = 1) - Model: y(t+1) = 3.5 + 0.8925 * y(t) Which value is used for y(t) in the case of n.ahead = 1? Thank you,Fabian I'm guessing that everyone who looked at this yesterday thought it had the aroma of homework. Posting a duplicate shows little interim effort on your part ,,, as well as not reading the Posting Guide where the no homework policy is described. -- David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Searching from Dataframe.
Thank you David. From: David Winsemius [via R] [mailto:ml-node+s789695n4642725...@n4.nabble.com] Sent: Tuesday, September 11, 2012 12:53 PM To: Akkara, Antony (GE Energy, Non-GE) Subject: Re: Searching from Dataframe. On Sep 11, 2012, at 12:11 AM, Rantony wrote: Hi, i have a dataframe containing some values. for eg:- MyDataFrame- Name Age Place -------- Aby 12USA Raj25UK Romi32ENG Amy 31IND My requirement what is, i have a search key word[it should search from all the columns], that i need to find out from this dataframe. If search keyword found , it should return that particular row and column number. For eg:- My search keyword is ENG. After searching, it should return particular row column number. Here it is MyDataFrame[3,3] which(MyDataFrame==ENG, arr.ind=TRUE) row col [1,] 3 3 You can certainly massage those values in any paste()y expression you choose. -- David Winsemius, MD Alameda, CA, USA __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642725 .html To unsubscribe from Searching from Dataframe., click here http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscrib e_by_codenode=4642722code=YW50b255LmFra2FyYUBnZS5jb218NDY0MjcyMnwxNTUx OTQzMDI5 . NAML http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_view erid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.Bas icNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.tem plate.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml -instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemai l.naml -- View this message in context: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642726.html Sent from the R help mailing list archive at Nabble.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] Contrasts for 2x4 interaction in mixed effects model
Thanks for your response. First time posting on any R forum, and apparently I didn't read carefully enough to see the difference in my model. I much appreciate the quick response. On Tue, Sep 11, 2012 at 2:16 AM, David Winsemius [via R] ml-node+s789695n4642723...@n4.nabble.com wrote: On Sep 10, 2012, at 5:59 PM, semperparatus wrote: I want to change it because I don't want to compare in this instance between conditions, but I simply want to see the contrast t-statistic between patient and control at every level of condition (1, 2, and 3). From there I'd like to be able to plot the t-statistic for the contrast between patient and control at level 1 of conditon, level 2 of condition, and level 3 of condition, each with error bars. In the post I responded to the output gave fixed effect output for SecA:Fir1, SecB:Fir1, SecC:Fir1, and SecD:Fir1. I'm hoping to get the same sort of output but for mine it would be Cond1:Patient1, Cond2:Patient1, Cond3:Patient1. It does not appear that you have the same situation as was being discussed earlier: Yours was: ' *When I tried using the syntax you used with my model: lmer(H.y. ~ patient*stance*cond +(cond/patient) + (1|subj), data=H), I got this result, which seems to be using condition 1 as a part of the baseline. Any idea how to change that?*' The other was: test - lmer(Latency ~ (Nuisance1*Nuisance2) + (Sec/Fir) + (1|Subject) + (1|Item), datatotest) He had separated his nuisance parameters from the 2 variables (Sec and Fir) for which he was interested in examining contrasts. PLEASE learn to include context. -- David Winsemius, MD Alameda, CA, USA __ [hidden email] http://user/SendEmail.jtp?type=nodenode=4642723i=0mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Contrasts-for-2x4-interaction-in-mixed-effects-model-tp4642536p4642723.html To unsubscribe from Contrasts for 2x4 interaction in mixed effects model, click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4642536code=cm9iZTA4OTlAdW1uLmVkdXw0NjQyNTM2fC0xMzAwMTcwNDQy . NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- View this message in context: http://r.789695.n4.nabble.com/Contrasts-for-2x4-interaction-in-mixed-effects-model-tp4642536p4642724.html Sent from the R help mailing list archive at Nabble.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] CRAN, install packages problem on networked PC
Thanks, Jeff. I found someone to help - all sorted. On Tue, Sep 11, 2012 at 3:29 PM, Jeff Newmiller jdnew...@dcn.davis.ca.uswrote: I see that you have set a proxy to a nonstandard DNS name, and your first warning is that your computer couldn't figure out where that proxy is. This is not an R question... please talk to your network administrator about whether you have a proxy and what it is called. --- 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. Neil COLLIER n.coll...@ecu.edu.au wrote: Dear List, I have a problem connecting to a CRAN mirror through a networked computer running Vista Enterprise on a Dell PC. I added http_proxy=http://gannet/ http_proxy_user=ask to the Target in the R shortcut, completed the username and password in the Proxy Authentication window, but get the following warning: Warning message: In open.connection(con, r) : unable to resolve 'gannet' When I try to download a package I get the following messages: utils:::menuInstallPkgs() Warning: unable to access index for repository http://cran.csiro.au/bin/windows/contrib/2.15 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.15 Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified This approach worked for me on other networks but this is the first time I've encountered this issue. Any help is appreciated. Cheers, Neil Collier Edith Cowan University This e-mail is confidential. If you are not the intended recipient you must not disclose or use the information contained within. If you have received it in error please return it to the sender via reply e-mail and delete any record of it from your system. The information contained within is not the opinion of Edith Cowan University in general and the University accepts no liability for the accuracy of the information provided. CRICOS IPC 00279B [[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. [[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] how to make a folder as package in R
Hi how to make a filder as R Package. for exampled c:\test folder having following files add.r test1.r sub.r i need to make package like this test_v1.zip. thanks B.Purushothaman -- View this message in context: http://r.789695.n4.nabble.com/how-to-make-a-folder-as-package-in-R-tp4642734.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to make a folder as package in R
Start with ?package.skeleton() Cheers, Michael On Tue, Sep 11, 2012 at 9:47 AM, purushothaman purushothama...@ge.com wrote: Hi how to make a filder as R Package. for exampled c:\test folder having following files add.r test1.r sub.r i need to make package like this test_v1.zip. thanks B.Purushothaman -- View this message in context: http://r.789695.n4.nabble.com/how-to-make-a-folder-as-package-in-R-tp4642734.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot: x and y chromosomes are missing
-Original Message- I have a list with gene names, fold changes (=expression level) and chromosomes. Names fold change chromosome hz 1.5 2 If I plot fold change versus chromosome (or vice versa): plot (ch, fc) I see only the chromosomes with numbers but not those with letter (x and y). What can I do? Make sure your chromosome column is a factor or character vector. From your description so far, I deduce that it is numeric (you can check by saying class(chromosome) ). I am guessing that R has been told to convert chromosome to numeric. If so, R would convert X and Y to NA (that is, missing) in the process - with a warning that ought to have been obvious - because they are not numbers. That would explain why you aren't seeing them in the plot. How you got that I don't know; the default would be to import as factor. Anyway, once you have chromosome properly imported as character or factor you can use barplot with chromosome used as labels, or plot(1:length(fc), axes=FALSE) and then add axes using axis(1, at=1:length(fc)), labels=chromosome) #or similar and axis(2) How can I add a single line in that plot at a certain y-level. see ?abline Thanks Hermann [[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. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] lowess regression
I am working on a biology-related project where I have a matrix of gene-to-gene interactions, ( interactions * distances ) and depending on the basic R functions, I do get vary different results ... Ermmm First, if I read the help pages correctly, the two base loess implementations have different defaults and use quite different calculations, so different results are very much to be expected. Second, the brief description of the poblem made me twitch. What are your coordinates? A matrix of gene interactions _sounds_ like something that one should not put a smoother through; gene ID is usually categorical. To be sensible you'd need some continuous quantitative x- and y- coordinates. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] metafor package: study level variation
At 16:08 10/09/2012, Jarrett Byrnes wrote: Thanks for this. A few things First, yes, my lmer syntax was indeed bad - I was writing this as an example of what my data code look like. Apologies. So, 1|studyID indeed. Also 1/variance. I've also been wondering - I often have more than 2 drugs - so, T1, T2, T3, etc. It depends on what slice of the data I'm looking at. As some of the data sets have, say, T1 and T2, and others have T1 and T3, while still others have just T1 - perhaps the way to go is to look at each effect size for each drug independently, rather than pool them in one analysis. That does not count for the non-independence, though, of different effect sizes being calculated sometimes using the same control - which you rightly identify. That looks more and more like network meta-analysis. As far as I know you have to write your own code for BUGS or JAGS and then use R to tidy up the consequences. I think you would benefit from following up the reference Wolfgang suggested. If you have a univariate meta-analysis and need to account for clustering you could look at Mike Cheung's metaSEM package. He has cast meta-analysis in the structural equation framework. You would need to install OpenMX first and then install his package from his webpage. OpenMX is not on CRAN and nor is metaSEM. http://openmx.psyc.virginia.edu/ http://courses.nus.edu.sg/course/psycwlm/Internet/ I'm curious, what other packages in R would be useful for this? I can also change these from log ratios to log odds ratios - or at least obtain # with desirable response v. # with negative response for all treatment - perhaps this would be another way to go about it using meta.bin in the meta package - again, looking at each metric separately. On Sep 10, 2012, at 4:52 AM, Viechtbauer Wolfgang (STAT) wrote: As usual, Michael was faster than I in responding. Let me add a few thoughts of my own. See comments below in text. Best, Wolfgang -- Wolfgang Viechtbauer, Ph.D., Statistician Department of Psychiatry and Psychology School for Mental Health and Neuroscience Faculty of Health, Medicine, and Life Sciences Maastricht University, P.O. Box 616 (VIJV1) 6200 MD Maastricht, The Netherlands +31 (43) 388-4170 | http://www.wvbauer.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jarrett Byrnes Sent: Friday, September 07, 2012 16:02 To: R help Subject: [R] metafor package: study level variation Hello. A quick question about incorporating variation due to study in the metafor package. I'm working with a particular data set for meta-analysis where some studies have multiple measurements. Others do not. So, let's say the effect I'm looking at is response to two different kinds of drug treatment - let's call their effect sizes T1 and T2. Some studies have multiple experiments measuring T1 and T2. Some have one of each. Some only have T1 or T2. I assume there is also a control group/condition in each of these studies, so in other words, you have a bunch of studies where some are two-arm studies comparing Trt1 *or* Trt2 to control and some are three-arm studies comparing both Trt1 *and* Trt2 to control. Now, in metafor, I've been using rma(yi = logRatio, vi=varLogRatio, mods=~ Drug.Type, data=mydata) So, drug.type is a dummy variable (either Trt1 or Trt2), so the code above will fit the model: yij = beta0 + beta1 Trt2 + uij + eij, where yij is the jth observed outcome in the ith study, beta0 then corresponds to the (average) outcome for Trt1, beta1 indicates how much higher or lower the (average) outcome is for Trt2 compared to Trt1, uij ~ N(0, tau^2), and eij ~ N(0, varLogRatio). This model will treat three-arm studies as if they were two (independent) two-arm studies. Probably not ideal. This works fine. Out of curiosity, I ran a quickie model in lme4 lmer(logRatio ~ Drug.Type + (1+studyID), data=mydata, weights=varLogRatio) and I noticed that the results are quite different, and this appears due to some variation due to study (after inspecting ranef - note, I included Drug.Type as a fixed effect as there were only two levels). 1) Did you use (1+studyID) or (1 | studyID)? The latter is probably what you meant/want to use. 2) You need to specify the *inverse* of the variances as weights. 3) This model assumes that the sampling variances are known up to a proportionality constant, not exactly known. You will therefore get what is sometimes called a multiplicative model for heterogeneity, with heterogeneity reflected in a residual variance estimate larger than 1. This model is different from the additive model (which is typically used), where the sampling variances are assumed to be known exactly and we *add* an additional random effect to reflect heterogeneity. So, with (1 | studyID) and inverse sampling variance weights, you
Re: [R] .NAME in .Fortran
On 12-09-10 9:21 PM, Peter Dunn wrote: Hi all I've been getting some emails from the R package maintainers that I need to update some code in a CRAN packge that uses FORTRAN, to comply with (not so recent) changes. I've been a little busy... I'm having trouble adjusting my code. I hope someone can help. The package was working fine, and a few R functions in my package had lines like this: tmp - .Fortran( name=pdf, other parameters here) and similar. The pdf is the name of the FORTRAN subroutine being called, of course. When I replace that line with tmp - .Fortran( .NAME=pdf, other parameters here) ...the package then does not pass the checks. The library package builds OK with no errors or warnings, and then during R CMD check the examples give this error: out - tweedie.profile( y~1, p.vec=seq(1.1, 1.9, length=9), do.plot=TRUE) 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 .Error in .Fortran(.NAME = pdfun, as.double(power), as.double(phi[i]/(y[i]^(2 - : supplied argument name '.NAME' does not match 'name' Calls: tweedie.profile - dtweedie.inversion - .Fortran Execution halted I've had a search--including a read of the Writing R Extensions manual on CRAN (I did read it, but interestingly a search of that document did not reveal any instance of .NAME)--and I cannot see the problem. It's probably obvious. Any help appreciated, even pointers to more info. I suspect you are doing your checks with an old version, not with the one listed below. The first argument was called name until R 2.13.0 was released; at that point it was changed to .NAME (to prevent conflicts with something or other). It seems someone forgot to note this in the NEWS file... You can find which version did the checks by looking at the header in the 00check.log file created during the check. You could also follow Rolf's advice and not name the first arg. Duncan Murdoch P. sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base The output from R CMD check: R CMD check tweedie * using log directory '/Users/pdunn2/Documents/SharedFiles/pkd/Research/Rlibraries/tweedie/tweedi e.Rcheck' * using R version 2.15.1 (2012-06-22) * using platform: x86_64-apple-darwin9.8.0 (64-bit) * using session charset: UTF-8 * checking for file 'tweedie/DESCRIPTION' ... OK * this is package 'tweedie' version '2.1.2' * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking whether package 'tweedie' can be installed ... OK * checking installed package size ... OK * checking package directory ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * loading checks for arch 'i386' ** checking whether the package can be loaded ... OK ** checking whether the package can be loaded with stated dependencies ... OK ** checking whether the package can be unloaded cleanly ... OK ** checking whether the namespace can be loaded with stated dependencies ... OK ** checking whether the namespace can be unloaded cleanly ... OK * loading checks for arch 'x86_64' ** checking whether the package can be loaded ... OK ** checking whether the package can be loaded with stated dependencies ... OK ** checking whether the package can be unloaded cleanly ... OK ** checking whether the namespace can be loaded with stated dependencies ... OK ** checking whether the namespace can be unloaded cleanly ... OK * checking for unstated dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... NOTE dtweedie.stable: no visible global function definition for 'dstable' * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... WARNING Codoc mismatches from documentation object 'tweedie.plot': tweedie.plot Code: function(y, xi = power, mu, phi, type = pdfun, power = NULL, add = FALSE, ...) Docs: function(y, xi, mu, phi, type = pdf, power = NULL, add = FALSE, ...) Mismatches in argument default values: Name: 'xi' Code: power Docs: Name: 'type' Code: pdfun Docs: pdf * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies
Re: [R] Integration between R and Microsoft SQL Server?
On 12-09-11 3:30 AM, johannes rara wrote: Oracle has its own R integration called Oracle R Enterprise: http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/index.html Is there a same kind of integration available for Microsoft SQL Server? If there is not, does MS have any plans to integrate R and SQL Server database engine? I think you need to ask the second question on the Microsoft-SQL-Server-help mailing list (or whatever support forum MS uses), not R-help. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to perform multiple comparisons with anova.glm significant interactions?
Dear R users I want to evaluate my significant interactions among 3 predictors in glm (one is a factor and 2 are numeric indices). I had a 3rd order interaction in my anova.glm and I'm wondering how to investigate them. I read multcomp package but I found it difficult for me. #Say e.g. (I'm not using real values and in this e.g. does not have the interactions I'm saying - but my data frame is huge) : Reserve - rep(c(In,Out), 100) fReserve - factor(Reserve) DivBoulders - rep (c(1.23,2.4,1.26,1.78,1.97,1.35,1.23,2.4,1.26,1.78), 20) Roughness - rep(c(3.45,2.56,1.32,5.67,3.73,3.57,2.66,1.52,7.67,2.73),20) Biomass - rep(c(8,5.3,3.5,12,25.4,10.1,9.8,2.4,5.6,5.3),20) myData - data.frame (fReserve ,DivBoulders ,Roughness ,Biomass ) glmTest - glm (sqrt(Biomass) ~ fReserve * DivBoulders * Roughness, family=gaussian, data=myData) plot (glmTest) anova (glmTest, test=F) # How could I hypothetically test multiple comparisons among the 3 predictors (when only one is a factor)? (or something that can help me to understrand what is happening with fish biomass in relation to reserve effect and habitat measurements at the same time). Many thanks in advance, Barbara Costa [[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] Contrasts for 2x4 interaction in mixed effects model
Hi Rachel, Do you get what you need with lmer(H.y.~(cond/patient)*stance + (1|subj), data=H) ? That should give you the comparison between patient groups at each level of Condition (the cond1:patient1, cond2:patient2, and cond2:patient3 that you were looking for). (And I guess it will also give interactions between those and Stance; I haven't ever run a model like that myself, though.) I'm new myself to mixed effects models and so I'm not sure if you need to do anything different from what I did to deal with the fact that your cond variable is between-subjects (in my data that started this thread, all the variables were within-subjects). So you may want to check about that as well. Best of luck, Steve Message: 73 Date: Tue, 11 Sep 2012 00:22:21 -0700 (PDT) From: semperparatus robe0...@umn.edu To: r-help@r-project.org Subject: Re: [R] Contrasts for 2x4 interaction in mixed effects model Message-ID: CAN_X31jAmDXurD2bMoQJQ8W=fenc8hw8at+evjsfabvahof...@mail.gmail.com Content-Type: text/plain Thanks for your response. First time posting on any R forum, and apparently I didn't read carefully enough to see the difference in my model. I much appreciate the quick response. On Tue, Sep 11, 2012 at 2:16 AM, David Winsemius [via R] ml-node+s789695n4642723...@n4.nabble.com wrote: On Sep 10, 2012, at 5:59 PM, semperparatus wrote: I want to change it because I don't want to compare in this instance between conditions, but I simply want to see the contrast t-statistic between patient and control at every level of condition (1, 2, and 3). From there I'd like to be able to plot the t-statistic for the contrast between patient and control at level 1 of conditon, level 2 of condition, and level 3 of condition, each with error bars. In the post I responded to the output gave fixed effect output for SecA:Fir1, SecB:Fir1, SecC:Fir1, and SecD:Fir1. I'm hoping to get the same sort of output but for mine it would be Cond1:Patient1, Cond2:Patient1, Cond3:Patient1. It does not appear that you have the same situation as was being discussed earlier: Yours was: ' *When I tried using the syntax you used with my model: lmer(H.y. ~ patient*stance*cond +(cond/patient) + (1|subj), data=H), I got this result, which seems to be using condition 1 as a part of the baseline. Any idea how to change that?*' The other was: test - lmer(Latency ~ (Nuisance1*Nuisance2) + (Sec/Fir) + (1|Subject) + (1|Item), datatotest) He had separated his nuisance parameters from the 2 variables (Sec and Fir) for which he was interested in examining contrasts. PLEASE learn to include context. -- David Winsemius, MD Alameda, CA, USA [[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] Position of y axis labels in plot graphic
Thanks a lot to everyone who gave my me advice. Btw, the most elegant solution came from a German R user who simply extended the plot.zoo function by the parameter line (ie the distance of the y labels from the y axis). Here the URL of his posting and the code, unfortunately his comments are written in German only: http://forum.r-statistik.de/viewtopic.php?f=9t=2819 Thanks again, Nico Am 11.09.2012 um 13:08 schrieb Jose Iparraguirre: Hi Nico, Far from the most elegant solution, at least it works and will give you plenty of freedom to choose where to place the labels: plot.zoo(x, type=l, main=, xlab=, ylab=,yaxt=n, xaxs=i); title(main=Title, xlab=index) mtext(names(x)[1],2,line=1,at=0.9) mtext(names(x)[2],2,line=1,at=0.6) mtext(names(x)[3],2,line=1,at=0.35) mtext(names(x)[4],2,line=1,at=0.1) Hope it helps, José José Iparraguirre Chief Economist Age UK T 020 303 31482 E jose.iparragui...@ageuk.org.uk Twitter @jose.iparraguirre@ageuk Tavis House, 1- 6 Tavistock Square London, WC1H 9NB www.ageuk.org.uk | ageukblog.org.uk | @ageukcampaigns For evidence and statistics on the older population, visit the Age UK Knowledge Hub http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Nicolai Schneider Sent: 10 September 2012 16:24 To: r-h...@stat.math.ethz.ch Subject: [R] Position of y axis labels in plot graphic Hello, I´m really sorry to bother you with this problem but it took me a whole day searching for a solution. I want the y axis labels positioned closer to the y axis, by default they are partly outside the window. Example: x - as.zoo(EuStockMarkets) par(las=1) plot.zoo(x, type=l, main=, xlab=, yaxt=n, xaxs=i) title(main=Title, xlab=index) par(las=0) Thanks in advance! Best, Nico __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Age UK and YouthNet are official charities for the Virgin London Marathon 2013 We need you to Run for it. Join the team and help raise vital funds to bring generations together to combat loneliness and isolation. Go to http://www.runforit.org.uk for more information or contact Helen Parson at helen.pars...@ageuk.org.uk or on 020 303 31369. Age UK and YouthNet. A lifeline, online. www.runforit.org.uk Age UK Improving later life www.ageuk.org.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Question about logistic regression with ordered factor variable using the rms package (prev.Design)
Dear R users, Hopefully someone can help me, Maybe I just misunderstand the function in the package? I am working with a logistic regression model. Until now I always worked with the basic glm function, where for the model was: ¡§ glm( disease ~ test.value + cnct , family=binomial(link=¡¦logit¡¦) ¡¨. This works fine when test .value and concentration (cnct) are continuous vairables. However, concentration is in fact a grouping variable over 5 experiments with 5 concentrations ( 25, 50, 100, 200 400). Therefore I believe concentration to be an ordered factor ( in model : cnct_o). To make this model I used the ¡§rms¡¨ library (previously known as Design) and functions lrm (or Glm). The lrm (or Glm) returns the odds for disease, the ¡§inv.logit (odds) ¡¨ gives the probability of disease, but I have to do this with the Predict function of the ¡§rms¡¨ package. # The resulting model (with lrm or Glm) would be : CoefS.E.Wald Z Pr(|Z|) Intercept 23.800 0.8891 2.680.0074 test.value 20.806 0.3409 6.100.0001 cnct_o -0.1127 0.0268 -4.21 0.0001 cnct_o=100 77.393 17.542 4.410.0001 cnct_o=200 204.291 45.080 4.530.0001 cnct_o=400 427.829 98.180 4.360.0001 # The results of the standard glm function are very different : # Standard glm Deviance Residuals: Min 1Q Median 3Q Max -2.7361 -0.2750 0.2177 0.5143 1.6897 Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept) -0.9022 0.3370 -2.677 0.007427 ** test.value2.0806 0.3409 6.103 1.04e-09 *** cnct_o.L 1.4363 0.4722 3.042 0.002352 ** cnct_o.Q 1.2208 0.4934 2.474 0.013359 * cnct_o.C -2.0649 0.5610 -3.681 0.000232 *** cnct_o^4 0.5599 0.4760 1.176 0.239485 --- Signif. codes: 0 ¡¥***¡¦ 0.001 ¡¥**¡¦ 0.01 ¡¥*¡¦ 0.05 ¡¥.¡¦ 0.1 ¡¥ ¡¦ 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 252.32 on 220 degrees of freedom Residual deviance: 167.68 on 215 degrees of freedom AIC: 179.68 Number of Fisher Scoring iterations: 6 # As I use the model parameters of the standard glm model to calculate the odds and probability manualy, I believe cnct_o = 25 to be the reference category and that cnct_o.L = 50, cnct_o.Q=100, cnct_o.C = 200 and cnct_o^4= 400. But I am not sure of this. The formulas used are : Odds - intercept + slope * test.value + cnct_o , where cnct_o is the corresponding value for the given concentration. Probability - inv.logit ( Odds ), the function inv.logit from package ¡§car¡¨. The results of the glm are in the table below, which are first the odds and then the probability¡¦s ( inv.logit (odds)). # glm oddscntc: test.value 25 cnct_o.Lcnct_o.Qcnct_o.C cnct_o^4 0 -0.902180.5341690.318649-2.96706 -0.34231 0.5 0.1381321.5744771.358957-1.92675 0.698001 1 1.17844 2.6147852.399265-0.88644 1.738309 1.5 2.2187473.6550933.4395720.153864 2.778616 2 3.2590554.6954 4.47988 1.194172 3.818924 # glm prob. cntc: test.value 25 cnct_o.Lcnct_o.Qcnct_o.C cnct_o^4 0 0.2886040.6304550.5789950.048936 0.415249 0.5 0.5344780.8284210.79559 0.127111 0.667744 1 0.7646670.9318070.9167710.291844 0.850472 1.5 0.90192 0.9747930.9689190.53839 0.941509 2 0.9629970.9909460.9887920.767486 0.97852 # If I compare this with the result of the Predict function in rms, the results seem very different, it can be because I misinterpret the glm model parameters for the ordered factor. How can I be sure which model parameter corresponds to which factor in the standard glm. # Results of lrm: Predict.lrm cntc: test.value 25 50 100 200 400 0 -0,43815-3,25628-1,153230,264036 0,072751 0,50580154 0,614227-2,2039 -0,100851,316414 1,125129 1,01160308 1,06-1,151530,9515262,368793 2,177508 1,5050682,693316-0,124821,9782363,395503 3,204218 2,01086954 3,7456950,9275633,0306154,447882 4,256597 # Prob. (inv.logit(odds)) cntc: test.value 25 50 100 200 400 0 0,3921820,0371020,2398990,565628 0,51818 0,50580154 0,6489040,0994 0,4748080,788585 0,754939 1,01160308 0,8411230,24021 0,7214220,914416 0,898211 1,505068
Re: [R] Searching from Dataframe.
From: Rantony [via R] [mailto:ml-node+s789695n464274...@n4.nabble.com] Sent: Tuesday, September 11, 2012 4:30 PM To: Akkara, Antony (GE Energy, Non-GE) Subject: Re: Searching from Dataframe. And how to get the vector from a list if the list item found inside ? for eg:- MyList- c(US,UK,UAE) Here i want to check a list item UAE which is in 3rd row. How i will get that row position ? - Thanks in advance Antony If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642744 .html To unsubscribe from Searching from Dataframe., click here http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscrib e_by_codenode=4642722code=YW50b255LmFra2FyYUBnZS5jb218NDY0MjcyMnwxNTUx OTQzMDI5 . NAML http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_view erid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.Bas icNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.tem plate.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml -instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemai l.naml -- View this message in context: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642745.html Sent from the R help mailing list archive at Nabble.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] cex.lab ignored in plot.zoo for multiple plots
Sep 05, 2012; 6:39pm — by David Winsemius David Winsemius a problem with the plot.zoo function. In the parameters of the function, cex.lab is ignored. I tried to reduce the size of the yaxis labels by at least 50%. Example: sample - as.zoo(EuStockMarkets) par(las=1) plot.zoo(sample, plot.type=multiple, main=Time Series, xlab=Date, yaxt=n, cex.lab=0.5, xaxs=i) # Try playing with different values for cex.lab I would have thought that the parameter to use would be 'cex.axis'. Testing seems to confirm theory in this case. I have the same issue (R 2.13.0 zoo_1.7-6). cex.lab, col.lab and font.lab are ignored, whether in the plot() or par() statement (and so is ann=FALSE by the way). Contrary to David's suggestion, cex.axis changes the size of axis tick labels (removed in the example above), not of the axis label. Thanks Arnaud. -- View this message in context: http://r.789695.n4.nabble.com/cex-lab-ignored-in-plot-zoo-for-multiple-plots-tp4642295p4642759.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to make a folder as package in R
Hi, i used this package.skeleton() function but i created using single R file. but i need to create package using more than one R file. Thanks B.Purushothaman -- View this message in context: http://r.789695.n4.nabble.com/how-to-make-a-folder-as-package-in-R-tp4642734p4642739.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] R on Android
Hello I tried to install R on my Transformer Prime without root. I downloaded the three files i found on: http://rwiki.sciviews.org/doku.php?id=getting-started:installation:android and i extract all the files, also without root my prime. But now i can't install R with the files i extractet. Is it possible to install R on my Prime without root and how can i do it? Or is root a must, for using R? Thanks for help Simon [[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 make a folder as package in R
Hello, See also http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf Hope this helps, Rui Barradas Em 11-09-2012 09:53, R. Michael Weylandt escreveu: Start with ?package.skeleton() Cheers, Michael On Tue, Sep 11, 2012 at 9:47 AM, purushothaman purushothama...@ge.com wrote: Hi how to make a filder as R Package. for exampled c:\test folder having following files add.r test1.r sub.r i need to make package like this test_v1.zip. thanks B.Purushothaman -- View this message in context: http://r.789695.n4.nabble.com/how-to-make-a-folder-as-package-in-R-tp4642734.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Searching from Dataframe.
How can I get index from a list if I know the listitem ? For eg:- Mylist-c(A,B,C) Acually,Here I need to get the index of B as 2. From: arun kirshna [via R] [mailto:ml-node+s789695n4642756...@n4.nabble.com] Sent: Tuesday, September 11, 2012 5:56 PM To: Akkara, Antony (GE Energy, Non-GE) Subject: Re: Searching from Dataframe. Hi, You can try this also: df1-read.table(text= Name Age Place Aby 12USA Raj25UK Romi32ENG Amy31IND ,sep=,header=TRUE,stringsAsFactor=FALSE) #row index unlist(apply(df1,1,function(x) which(grepl(ENG,x #[1] 3 #column index unlist(apply(df1,2,function(x) which(grepl(ENG,x #Place # 3 #or, you can use arrayInd(which(df1==ENG), dim(df1)) # [,1] [,2] #[1,]33 #or df2-as.matrix(df1) arrayInd(which(grepl(ENG,df2)), dim(df2)) # [,1] [,2] #[1,]33 A.K. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642756 .html To unsubscribe from Searching from Dataframe., click here http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscrib e_by_codenode=4642722code=YW50b255LmFra2FyYUBnZS5jb218NDY0MjcyMnwxNTUx OTQzMDI5 . NAML http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_view erid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.Bas icNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.tem plate.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml -instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemai l.naml -- View this message in context: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642758.html Sent from the R help mailing list archive at Nabble.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] Searching from Dataframe.
And how to get the vector from a list if the list item found inside ? for eg:- MyList- c(US,UK,UAE) Here i want to check a list item UAE which is in 3rd row. How i will get that row position ? - Thanks in advance Antony -- View this message in context: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642744.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem while installing packages in r
Dear R users, Hope someone can help me to solve the problem. I have a problem installing packages in to r . The following message was being displayed in the console when I was trying to install 'rgdal' package. install.packages(rgdal) Warning in install.packages : argument 'lib' is missing: using 'C:/Documents and Settings/mondreti/Mes documents/R/win-library/2.11' Warning in install.packages : Could not open: HTTP status was '404 Not Found' Warning in install.packages : Could not open: HTTP status was '404 Not Found' Warning in install.packages : unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.11 Warning in install.packages : package 'rgdal' is not available Thanks in advance, Ravi. [[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] Sort or Permutate
Dear all, I am having a struct that contains on the first column file names and on the second column a number which is a rating of the file on first column A small subset looks like that small [,1] [1,] /storage/storage0/59Off.Rtable [2,] /storage/storage0/5912On.Rtable [3,] /storage/storage0/5912314ff.Rtable [,2] [1,] 0.220386301811093 [2,] 0.405237035258638 [3,] 0.288659374128626 I want based on the values of column two to rearrange table elements by keeping though the row elements together. For example if I order those in ascending order should look like small [,1] [1,] /storage/storage0/59Off.Rtable [2,] /storage/storage0/5912314ff.Rtable [3,] /storage/storage0/5912On.Rtable [,2] [1,] 0.220386301811093 [2,] 0.288659374128626 [3,] 0.405237035258638 I have tried with sort, sort.list and order but I have failed . I do not quite undestand how one can complete this task in R. Could you please spend some time helping me? Regards A [[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] Setwd to a directory that requires authentication
I work at a company where we log on to windows using a username and password. There is a global server with files that I need to use R to do some analysis on. That server requires my windows credentials to logon. When I access the server from internet explorer it automatically uses my windows credentials to logon. When I use R it doesn't work. I have tried: setInternet2(TRUE) con = url(description=http://username:passw...@server.net;, open=r) open(con) which gave me a timeout error. I have also tried: setwd(server.net) which gives me the error: Error in setwd(server.net) : cannot change working directory [[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] plot dataframe with inconsistently relations
Hi @ all, I work with a dataframe like the attached one. I want to plot it, so that value is listed on the y-axis, year on the x-axis and states as lines in the coordinate system. I tried the following code: require(ggplot) plot1-ggplot(TEST, aes(year, value)) + geom_line(aes(colour = state)) The result could be very nice but the the lines are stacked. Maybe there is an easier way to do that? Thanks a lot for your help. Geo -- View this message in context: http://r.789695.n4.nabble.com/plot-dataframe-with-inconsistently-relations-tp4642766.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] Find correlation in Clmm?
Hi all, I am trying to fit a random effect model to categorical response variable using package ordinal /clmm. How can I find the correlation between random effects (random intercept and random slope) Thanks in advance Ana [[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] creating several different matrices
Dear people, I need to generate 100 different matrices, without particular characteristics but using only one command! Do you know some way? thank You -- View this message in context: http://r.789695.n4.nabble.com/creating-several-different-matrices-tp4642768.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] boot() with glm/gnm on a contingency table
Hi everyone! In a package I'm developing, I have created a custom function to get jackknife standard errors for the parameters of a gnm model (which is essentially the same as a glm model for this issue). I'd like to add support for bootstrap using package boot, but I couldn't find how to proceed. The problem is, my data is a table object. Thus, I don't have one individual per line: when the object is converted to a data frame, one row represents one cell, or one combination of factor levels. I cannot pass this to boot() as the data argument and use indices from my custom statistic() function, since I would drop cells, not individual observations. A very inefficient solution would be to create a data frame with one row per observation, by replicating each cell using its frequencies. That's really a brute force solution, though. ;-) The other way would be generate importance weights based on observed frequencies, and to multiply the original data by the weights at each iteration, but I'm not sure that's correct. Thoughts? Thanks for your help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R calculates small numbers, where the result should be zero
Hi all, my problem is that R does wrong calculations, when the result should be zero. I have the following code: RD_Var1 - ((0.1*(1-0.1))/100)+((0.2*(1-0.2))/100) RD_Var2 - ((0.1*(1-0.1))/100)+((0.2*(1-0.2))/100) RD_1 - 0.1-0.2 RD_1 RD_2 - 0.1-0.2 FEM_Eff_RD - ((1/RD_Var1)*RD_1+(1/RD_Var2)*RD_2)/(1/RD_Var1+1/RD_Var2) Q_RD- 1/RD_Var1*((RD_1-FEM_Eff_RD)^2)+1/RD_Var2*((RD_2-FEM_Eff_RD)^2) Q_RD My result is: 1.540744e-31 When I put the calculated numbers directly into the last formula, I get zero, which is the correct answer: Q_RD- 1/0.0025*((-0.1--0.1)^2)+1/0.0025*((-0.1--0.1)^2) Why does R calculate the other number instead of zero? Thank you very much for your help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loading Chess Data
On 9/2/2012 11:41 AM, David Arnold wrote: All, What would be the most efficient way to load the data at the following address into a dataframe? http://ratings.fide.com/top.phtml?list=men It depends. The most efficient for me was to highlight it, copy it to the windows clipboard and execute the following R command. chess - read.table(file='clipboard', header = TRUE, sep = '\t') If you want you can then set it to use in an R post or a script: chess2 - dput(chess) chess2 # You would include similar to the following in your script or email: chess3 - structure(list(Rank = 1:101, Name = structure(c(17L, 8L, 48L, 77L, 66L, 5L, 45L, 18L, 40L, 61L, 35L, 91L, 88L, 44L, 97L, 30L, 29L, 53L, 42L, 33L, 90L, 75L, 56L, 21L, 41L, 1L, 96L, 6L, 26L, 83L, 15L, 99L, 4L, 58L, 14L, 64L, 79L, 82L, 9L, 47L, 63L, 69L, 7L, 55L, 60L, 86L, 95L, 74L, 84L, 92L, 93L, 20L, 52L, 80L, 81L, 98L, 67L, 94L, 38L, 24L, 19L, 31L, 2L, 87L, 49L, 13L, 25L, 46L, 16L, 39L, 3L, 23L, 22L, 78L, 12L, 51L, 37L, 89L, 34L, 72L, 70L, 101L, 10L, 85L, 100L, 54L, 65L, 28L, 76L, 32L, 57L, 71L, 50L, 43L, 68L, 62L, 27L, 73L, 59L, 36L, 11L), .Label = c( Adams, Michael, Akopian, Vladimir, Alekseev, Evgeny, Almasi, Zoltan, Anand, Viswanathan, Andreikin, Dmitry, Areshchenko, Alexander, Aronian, Levon, Bacrot, Etienne, Balogh, Csaba, Bartel, Mateusz, Bauer, Christian, Berkes, Ferenc, Bologan, Viktor, Bruzon Batista, Lazaro, Bu, Xiangzhi, Carlsen, Magnus, Caruana, Fabiano, Cheparinov, Ivan, Ding, Liren, Dominguez Perez, Leinier, Dreev, Aleksey, Edouard, Romain, Efimenko, Zahar, Eljanov, Pavel, Fressinet, Laurent, Fridman, Daniel, Gareev, Timur, Gashimov, Vugar, Gelfand, Boris, Georgiev, Kiril, Gharamian, Tigran, Giri, Anish, Grachev, Boris, Grischuk, Alexander, Gupta, Abhijeet, Gyimesi, Zoltan, Harikrishna, P., Inarkiev, Ernesto, Ivanchuk, Vassily, Jakovenko, Dmitry, Jobava, Baadur, Jones, Gawain C B, Kamsky, Gata, Karjakin, Sergey, Kasimdzhanov, Rustam, Korobov, Anton, Kramnik, Vladimir, Kryvoruchko, Yuriy, Kurnosov, Igor, Laznicka, Viktor, Le, Quang Liem, Leko, Peter, Li, Chao b, Malakhov, Vladimir, Mamedyarov, Shakhriyar, Matlakov, Maxim, McShane, Luke J, Meier, Georg, Moiseenko, Alexander, Morozevich, Alexander, Motylev, Alexander, Movsesian, Sergei, Naiditsch, Arkadij, Najer, Evgeniy, Nakamura, Hikaru, Navara, David, Negi, Parimarjan, Nepomniachtchi, Ian, Ni, Hua, Nielsen, Peter Heine, Onischuk, Alexander, Petrosian, Tigran L., Polgar, Judit, Ponomariov, Ruslan, Potkin, Vladimir, Radjabov, Teimour, Ragger, Markus, Riazantsev, Alexander, Rublevsky, Sergei, Sargissian, Gabriel, Sasikiran, Krishnan, Shirov, Alexei, Short, Nigel D, So, Wesley, Sokolov, Ivan, Sutovsky, Emil, Svidler, Peter, Tiviakov, Sergei, Tomashevsky, Evgeny, Topalov, Veselin, Vachier-Lagrave, Maxime, Vallejo Pons, Francisco, Van Wely, Loek, Vitiugov, Nikita, Volokitin, Andrei, Wang, Hao, Wang, Yue, Wojtaszek, Radoslaw, Zhigalko, Sergei, Zvjaginsev, Vadim ), class = factor), Title = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ), .Label = g, class = factor), Country = structure(c(22L, 1L, 25L, 3L, 27L, 16L, 25L, 18L, 26L, 25L, 25L, 5L, 25L, 27L, 6L, 17L, 3L, 15L, 13L, 21L, 25L, 26L, 3L, 7L, 25L, 10L, 26L, 25L, 12L, 19L, 7L, 24L, 15L, 10L, 20L, 14L, 25L, 16L, 12L, 26L, 1L, 25L, 26L, 25L, 26L, 21L, 25L, 15L, 10L, 12L, 11L, 6L, 29L, 25L, 1L, 6L, 8L, 21L, 16L, 26L, 5L, 5L, 1L, 17L, 26L, 15L, 26L, 28L, 6L, 25L, 25L, 12L, 25L, 2L, 12L, 8L, 15L, 21L, 25L, 27L, 6L, 25L, 15L, 23L, 4L, 6L, 25L, 27L, 25L, 12L, 25L, 9L, 25L, 10L, 16L, 25L, 14L, 1L, 14L, 16L, 24L), .Label = c( ARM, AUT, AZE, BLR, BUL, CHN, CUB, CZE, DEN, ENG, ESP, FRA, GEO, GER, HUN, IND, ISR, ITA, LAT, MDA, NED, NOR, PHI, POL, RUS, UKR, USA, UZB, VIE), class = factor), Rating = c(2843L, 2816L, 2797L, 2788L, 2783L, 2780L, 2778L, 2773L, 2769L, 2758L, 2754L, 2752L, 2747L, 2746L, 2742L, 2738L, 2737L, 2737L, 2734L, 2730L, 2730L, 2729L, 2729L, 2725L, 2724L, 2722L, 2718L, 2718L, 2714L, 2714L, 2713L, 2713L, 2713L, 2713L, 2712L, 2712L, 2712L, 2707L, 2705L, 2705L, 2705L, 2704L, 2702L, 2700L, 2699L, 2699L, 2699L, 2698L, 2698L, 2697L, 2697L, 2694L, 2693L, 2693L, 2693L, 2691L, 2691L, 2691L, 2690L, 2689L, 2689L, 2687L, 2687L, 2687L, 2686L, 2685L, 2684L, 2684L, 2683L, 2683L, 2682L, 2678L, 2677L, 2677L, 2676L, 2675L, 2674L, 2674L, 2672L, 2672L, 2671L, 2671L, 2668L, 2667L, 2667L, 2665L, 2664L, 2663L, 2663L, 2663L, 2663L, 2662L, 2660L, 2658L, 2658L, 2658L, 2657L, 2657L, 2656L, 2654L, 2654L), Games = c(10L, 0L, 0L, 0L, 10L, 0L, 9L, 0L, 0L, 2L, 9L, 0L, 9L,
Re: [R] cex.lab ignored in plot.zoo for multiple plots
On Wed, Sep 5, 2012 at 11:06 AM, Nicolai Schneider rstatistics.u...@gmail.com wrote: Hello everyone, a problem with the plot.zoo function. In the parameters of the function, cex.lab is ignored. I tried to reduce the size of the yaxis labels by at least 50%. -- Example: sample - as.zoo(EuStockMarkets) par(las=1) plot.zoo(sample, plot.type=multiple, main=Time Series, xlab=Date, yaxt=n, cex.lab=0.5, xaxs=i) # Try playing with different values for cex.lab par(las=0) Internally it uses mtext to write that text and mtext uses cex which is already taken. Here is a workaround: library(proto) p - proto(plot.zoo = plot.zoo, mtext = function(...) graphics::mtext(..., cex = .5)) with(p, plot.zoo)(sample) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R calculates small numbers, where the result should be zero
See R Faq (http://cran.r-project.org/doc/FAQ/R-FAQ.html) with particular attention to FAQs 7.31 and 9.1 paragraph 3. Essentially, computational precision is finite. S Ellison -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Andrea Gonnermann Sent: 11 September 2012 15:24 To: r-help@r-project.org Subject: [R] R calculates small numbers, where the result should be zero Hi all, my problem is that R does wrong calculations, when the result should be zero. I have the following code: RD_Var1 - ((0.1*(1-0.1))/100)+((0.2*(1-0.2))/100) RD_Var2 - ((0.1*(1-0.1))/100)+((0.2*(1-0.2))/100) RD_1 - 0.1-0.2 RD_1 RD_2 - 0.1-0.2 FEM_Eff_RD - ((1/RD_Var1)*RD_1+(1/RD_Var2)*RD_2)/(1/RD_Var1+1/RD_Var2) Q_RD- 1/RD_Var1*((RD_1-FEM_Eff_RD)^2)+1/RD_Var2*((RD_2-FEM_Eff_RD)^2) Q_RD My result is: 1.540744e-31 When I put the calculated numbers directly into the last formula, I get zero, which is the correct answer: Q_RD- 1/0.0025*((-0.1--0.1)^2)+1/0.0025*((-0.1--0.1)^2) Why does R calculate the other number instead of zero? Thank you very much for your help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 calculates small numbers, where the result should be zero
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Andrea Gonnermann Sent: Tuesday, September 11, 2012 4:24 PM To: r-help@r-project.org Subject: [R] R calculates small numbers, where the result should be zero Hi all, my problem is that R does wrong calculations, when the result should be zero. I have the following code: RD_Var1 - ((0.1*(1-0.1))/100)+((0.2*(1-0.2))/100) RD_Var2 - ((0.1*(1-0.1))/100)+((0.2*(1-0.2))/100) RD_1 - 0.1-0.2 RD_1 RD_2 - 0.1-0.2 FEM_Eff_RD - ((1/RD_Var1)*RD_1+(1/RD_Var2)*RD_2)/(1/RD_Var1+1/RD_Var2) Q_RD- 1/RD_Var1*((RD_1-FEM_Eff_RD)^2)+1/RD_Var2*((RD_2- FEM_Eff_RD)^2) Q_RD My result is: 1.540744e-31 When I put the calculated numbers directly into the last formula, I get zero, which is the correct answer: Q_RD- 1/0.0025*((-0.1--0.1)^2)+1/0.0025*((-0.1--0.1)^2) Why does R calculate the other number instead of zero? Because you are probably using computer. Some fractional decimal numbers cannot be expressed as binary finite precision numbers. You can round your result to get 0. BTW it is covered in FAQ 7.31 (I believe) Regards Petr Thank you very much for your help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R calculates small numbers, where the result should be zero
This is the result of how any computer program stores numbers, it's not unique to R. A slightly different question is discussed in R FAQ 7.31 but it applies to your situation. You may also enjoy the R Inferno at www.burns-stat.com/pages/Tutor/R_inferno.pdf Bryan *** Bryan Hanson Professor of Chemistry Biochemistry DePauw University On Sep 11, 2012, at 10:23 AM, Andrea Gonnermann drel...@googlemail.com wrote: Hi all, my problem is that R does wrong calculations, when the result should be zero. I have the following code: RD_Var1 - ((0.1*(1-0.1))/100)+((0.2*(1-0.2))/100) RD_Var2 - ((0.1*(1-0.1))/100)+((0.2*(1-0.2))/100) RD_1 - 0.1-0.2 RD_1 RD_2 - 0.1-0.2 FEM_Eff_RD - ((1/RD_Var1)*RD_1+(1/RD_Var2)*RD_2)/(1/RD_Var1+1/RD_Var2) Q_RD- 1/RD_Var1*((RD_1-FEM_Eff_RD)^2)+1/RD_Var2*((RD_2-FEM_Eff_RD)^2) Q_RD My result is: 1.540744e-31 When I put the calculated numbers directly into the last formula, I get zero, which is the correct answer: Q_RD- 1/0.0025*((-0.1--0.1)^2)+1/0.0025*((-0.1--0.1)^2) Why does R calculate the other number instead of zero? Thank you very much for your help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Combine two variables
Hi: I have two variables in a data frame that are the results of a wording experiment in a survey. I'd like to create a third variable that combines the two variables. Recode doesn't seem to work, because it just recodes the first variable into the third, then recodes the second variable into the third, overwriting the first recode. I can do this with a rather elaborate indexing process, subsetting the first column and then copying the data into the second etc. But I'm looking for a cleaner way to do this. The data frame looks like this. df-data.frame(var1=sample(c('a','b','c',NA),replace=TRUE, size=100), var2=sample(c('a','b','c',NA),replace=TRUE,size=100)) df-subset(df, !is.na(var1) |!is.na(var2)) As you can see, if one variable has an NA, then the other variable has a valid value, so how do I just combine the two variables into one? Thank you for your assistance. Simon Kiss __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Sort or Permutate
On 11-09-2012, at 13:13, Alaios wrote: Dear all, I am having a struct that contains on the first column file names and on the second column a number which is a rating of the file on first column A small subset looks like that small [,1] [1,] /storage/storage0/59Off.Rtable [2,] /storage/storage0/5912On.Rtable [3,] /storage/storage0/5912314ff.Rtable [,2] [1,] 0.220386301811093 [2,] 0.405237035258638 [3,] 0.288659374128626 I want based on the values of column two to rearrange table elements by keeping though the row elements together. For example if I order those in ascending order should look like small [,1] [1,] /storage/storage0/59Off.Rtable [2,] /storage/storage0/5912314ff.Rtable [3,] /storage/storage0/5912On.Rtable [,2] [1,] 0.220386301811093 [2,] 0.288659374128626 [3,] 0.405237035258638 I have tried with sort, sort.list and order but I have failed . I do not quite undestand how one can complete this task in R. Could you please spend some time helping me? Please provide data using dput. You can do it using order() like this small - data.frame(file.name=c( /storage/storage0/59Off.Rtable, /storage/storage0/5912On.Rtable, /storage/storage0/5912314ff.Rtable), stringsAsFactors=FALSE, value=c( 0.220386301811093, 0.405237035258638, 0.288659374128626) ) v.index - order(small[,value]) small - small[v.index,] small 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] R calculates small numbers, where the result should be zero
Many,many thanks to all of you and your helpful links! I actually experineced something similar in SAS and my research on google was not good enough to figure it out! Well, I may just round the numbers to some digits as proposed So, thank you again for this fast response!! Have a nice day :-) Andrea On Tue, Sep 11, 2012 at 4:48 PM, PIKAL Petr petr.pi...@precheza.cz wrote: Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Andrea Gonnermann Sent: Tuesday, September 11, 2012 4:24 PM To: r-help@r-project.org Subject: [R] R calculates small numbers, where the result should be zero Hi all, my problem is that R does wrong calculations, when the result should be zero. I have the following code: RD_Var1 - ((0.1*(1-0.1))/100)+((0.2*(1-0.2))/100) RD_Var2 - ((0.1*(1-0.1))/100)+((0.2*(1-0.2))/100) RD_1 - 0.1-0.2 RD_1 RD_2 - 0.1-0.2 FEM_Eff_RD - ((1/RD_Var1)*RD_1+(1/RD_Var2)*RD_2)/(1/RD_Var1+1/RD_Var2) Q_RD- 1/RD_Var1*((RD_1-FEM_Eff_RD)^2)+1/RD_Var2*((RD_2- FEM_Eff_RD)^2) Q_RD My result is: 1.540744e-31 When I put the calculated numbers directly into the last formula, I get zero, which is the correct answer: Q_RD- 1/0.0025*((-0.1--0.1)^2)+1/0.0025*((-0.1--0.1)^2) Why does R calculate the other number instead of zero? Because you are probably using computer. Some fractional decimal numbers cannot be expressed as binary finite precision numbers. You can round your result to get 0. BTW it is covered in FAQ 7.31 (I believe) Regards Petr Thank you very much for your help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Find correlation in Clmm?
Den 11/09/2012 16.36 skrev Anera Salucci a.salu...@yahoo.com: Hi all, I am trying to fit a random effect model to categorical response variable using package ordinal /clmm. How can I find the correlation between random effects (random intercept and random slope) You cannot, as such models are not implemented. The model you are fitting is assuming there is no such correlation. Cheers, Rune Thanks in advance Ana [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Repeated Aggregation with data.table
I've been using this setup: flist - expression( list(mean.z = mean(z), sd.z = sd(z)) ) dat[ , eval(flist), list(x)] It works great, but there's one small catch. If I do something like flist - expression(list(x.per.y = sum(x) / sum(y))) dat[, eval(flist), list(y)] it does the wrong thing, because sum(y) in each group is just the common value, rather than that value times the length. Is there any way around this? Obviously I could rewrite the expression if I know I'm going to by grouping by y, but I'd like it to be generic. Thanks. - Elliot On Wed, Aug 8, 2012 at 9:17 AM, David Winsemius dwinsem...@comcast.netwrote: On Aug 7, 2012, at 9:28 PM, arun wrote: HI, Try this: fun1-function(x,.expr){ .expr-expression(list(mean.z=**mean(z),sd.z=sd(z))) z1-eval(.expr) } #or fun1-function(x,.expr){ .expr-expression(list(mean.z=**mean(z),sd.z=sd(z))) z1-.expr } dat[,eval(z1),list(x)] dat[,eval(z1),list(y)] dat[,eval(z1),list(x,y)] I'm not seeing the connection between those functions and the data.table call. (Running that code produces an error on my machine.) If the goal is to have an expression result then just create it with expression(). In the example: flist - expression( list(mean.z = mean(z), sd.z = sd(z)) ) dat[ , eval(flist), list(x)] x mean.z sd.z 1: 2 0.04436034 1.039615 2: 3 -0.06354504 1.077686 3: 1 -0.08879671 1.066916 -- David. A.K. - Original Message - From: Elliot Joel Bernstein elliot.bernstein@fdopartners.**comelliot.bernst...@fdopartners.com To: r-help@r-project.org Cc: Sent: Tuesday, August 7, 2012 5:36 PM Subject: [R] Repeated Aggregation with data.table I have been using ddply to do aggregation, and I frequently define a single aggregation function that I use to aggregate over different groups. For example, require(plyr) dat - data.frame(x = sample(3, 100, replace=TRUE), y = sample(3, 100, replace = TRUE), z = rnorm(100)) f - function(x) { data.frame(mean.z = mean(x$z), sd.z = sd(x$z)) } ddply(dat, x, f) ddply(dat, y, f) ddply(dat, c(x, y), f) I recently discovered the data.table package, which dramatically speeds up the aggregation: require(data.table) dat - data.table(dat) dat[, list(mean.z = mean(z), sd.z = sd(z)), list(x)] dat[, list(mean.z = mean(z), sd.z = sd(z)), list(y)] dat[, list(mean.z = mean(z), sd.z = sd(z)), list(x,y)] But I can't figure out how to save the aggregation function list(mean.z = mean(z), sd.z = sd(z)) as a variable that I can reuse, similar to the function f above. Can someone please explain how to do that? Thanks. - Elliot -- Elliot Joel Bernstein, Ph.D. | Research Associate | FDO Partners, LLC 134 Mount Auburn Street | Cambridge, MA | 02138 Phone: (617) 503-4619 | Email: elliot.bernstein@fdopartners.**comelliot.bernst...@fdopartners.com __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Alameda, CA, USA -- Elliot Joel Bernstein, Ph.D. | Research Associate | FDO Partners, LLC 134 Mount Auburn Street | Cambridge, MA | 02138 Phone: (617) 503-4619 | Email: elliot.bernst...@fdopartners.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] Sort or Permutate
Ah, but note that the OP's 2nd column is character, not numeric... And we don't know what the struct is (a matrix or data frame?? --does the OP know the difference?). Has Alaios perused An Introduction to R where he/she might have gained some enlightenment that would have obviated the need to post? -- Bert On Tue, Sep 11, 2012 at 8:00 AM, Berend Hasselman b...@xs4all.nl wrote: On 11-09-2012, at 13:13, Alaios wrote: Dear all, I am having a struct that contains on the first column file names and on the second column a number which is a rating of the file on first column A small subset looks like that small [,1] [1,] /storage/storage0/59Off.Rtable [2,] /storage/storage0/5912On.Rtable [3,] /storage/storage0/5912314ff.Rtable [,2] [1,] 0.220386301811093 [2,] 0.405237035258638 [3,] 0.288659374128626 I want based on the values of column two to rearrange table elements by keeping though the row elements together. For example if I order those in ascending order should look like small [,1] [1,] /storage/storage0/59Off.Rtable [2,] /storage/storage0/5912314ff.Rtable [3,] /storage/storage0/5912On.Rtable [,2] [1,] 0.220386301811093 [2,] 0.288659374128626 [3,] 0.405237035258638 I have tried with sort, sort.list and order but I have failed . I do not quite undestand how one can complete this task in R. Could you please spend some time helping me? Please provide data using dput. You can do it using order() like this small - data.frame(file.name=c( /storage/storage0/59Off.Rtable, /storage/storage0/5912On.Rtable, /storage/storage0/5912314ff.Rtable), stringsAsFactors=FALSE, value=c( 0.220386301811093, 0.405237035258638, 0.288659374128626) ) v.index - order(small[,value]) small - small[v.index,] small 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem while installing packages in r
Le mardi 11 septembre 2012 à 15:36 +0200, Ravichandra MONDRETI a écrit : Dear R users, Hope someone can help me to solve the problem. I have a problem installing packages in to r . The following message was being displayed in the console when I was trying to install 'rgdal' package. install.packages(rgdal) Warning in install.packages : argument 'lib' is missing: using 'C:/Documents and Settings/mondreti/Mes documents/R/win-library/2.11' Warning in install.packages : Could not open: HTTP status was '404 Not Found' Warning in install.packages : Could not open: HTTP status was '404 Not Found' Warning in install.packages : unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.11 I think you should use another CRAN mirror, or upgrade R to a more recent version. This mirror only includes packages built since R 2.12. 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] problem while installing packages in r
On 11.09.2012 15:36, Ravichandra MONDRETI wrote: Dear R users, Hope someone can help me to solve the problem. I have a problem installing packages in to r . The following message was being displayed in the console when I was trying to install 'rgdal' package. install.packages(rgdal) Warning in install.packages : argument 'lib' is missing: using 'C:/Documents and Settings/mondreti/Mes documents/R/win-library/2.11' Warning in install.packages : Could not open: HTTP status was '404 Not Found' Warning in install.packages : Could not open: HTTP status was '404 Not Found' Warning in install.packages : unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.11 This was caused by a temporary problem. The repository for 32-bit R-2.11.x for Windows binaries will starting working again within 24 hours on the CRAN master (and will propagate to the mirrors). Nevertheless, R-2.11.x binaries are no longer supported. Time to upgrade! Best, Uwe Ligges Warning in install.packages : package 'rgdal' is not available Thanks in advance, Ravi. [[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] Animation Problem
Hi List, I am trying to build an animation and facing problem as animation is not coming live. The goal is to build heart beats like diagram for the data given below. data : structure(list(date = 1971:1991, x = c(41L, 60L, 41L, 61L, 22L, 83L, 31L, 55L, 22L, 14L, 38L, 6L, 29L, 17L, 10L, 99L, 88L, 32L, 68L, 78L, 26L)), .Names = c(date, x), class = data.frame, row.names = c(NA, -21L)) Program : library(animation) library(ggplot2) anim - function(a){for (i in seq(1,21)) {pl - ggplot(a,aes(x=date,y=x))+geom_line()+scale_x_continuous(limits=c(1971,1991))+ scale_y_continuous(limits=c(0,100)) print(pl)}} saveMovie(anim(),interval=0.1,outdir=getwd()) Session Info : R version 2.15.1 (2012-06-22) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices datasets utils methods [7] base other attached packages: [1] animation_2.1 ggplot2_0.9.1 igraph_0.6-2 rcom_2.2-5 [5] rscproxy_2.0-5 loaded via a namespace (and not attached): [1] colorspace_1.1-1 dichromat_1.2-4digest_0.5.2 [4] grid_2.15.1labeling_0.1 MASS_7.3-18 [7] memoise_0.1munsell_0.3plyr_1.7.1 [10] proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1 [13] RGtk2_2.20.25 scales_0.2.1 stringr_0.6.1 [16] tools_2.15.1 Can some one help me to find the problem. The plot is coming but not the animation. Best Regards, Bhupendrasinh Thakre *Disclaimer :* The information contained in this communication is confi...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] creating several different matrices
Hi Homework? No homework policy in this list. Anyway here are some hints. ?for ?split Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of cesare orsini Sent: Tuesday, September 11, 2012 4:17 PM To: r-help@r-project.org Subject: [R] creating several different matrices Dear people, I need to generate 100 different matrices, without particular characteristics but using only one command! Do you know some way? thank You -- View this message in context: http://r.789695.n4.nabble.com/creating- several-different-matrices-tp4642768.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to get curve information from a gam model
I'm using library(mgcv) I did a gam regression like this model - gam(formula = y ~ s(x), family=binomial) Now I'd like to get 2 vectors x and z (with z=s(x)), so that I can implement the model outside R. How can I do this? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/How-to-get-curve-information-from-a-gam-model-tp4642785.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Searching from Dataframe.
Hello, Try which(B == Mylist) Hope this helps, Rui Barradas Em 11-09-2012 13:31, Rantony escreveu: How can I get index from a list if I know the listitem ? For eg:- Mylist-c(A,B,C) Acually,Here I need to get the index of B as 2. From: arun kirshna [via R] [mailto:ml-node+s789695n4642756...@n4.nabble.com] Sent: Tuesday, September 11, 2012 5:56 PM To: Akkara, Antony (GE Energy, Non-GE) Subject: Re: Searching from Dataframe. Hi, You can try this also: df1-read.table(text= Name Age Place Aby 12USA Raj25UK Romi32ENG Amy31IND ,sep=,header=TRUE,stringsAsFactor=FALSE) #row index unlist(apply(df1,1,function(x) which(grepl(ENG,x #[1] 3 #column index unlist(apply(df1,2,function(x) which(grepl(ENG,x #Place # 3 #or, you can use arrayInd(which(df1==ENG), dim(df1)) # [,1] [,2] #[1,]33 #or df2-as.matrix(df1) arrayInd(which(grepl(ENG,df2)), dim(df2)) # [,1] [,2] #[1,]33 A.K. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642756 .html To unsubscribe from Searching from Dataframe., click here http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscrib e_by_codenode=4642722code=YW50b255LmFra2FyYUBnZS5jb218NDY0MjcyMnwxNTUx OTQzMDI5 . NAML http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_view erid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.Bas icNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.tem plate.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml -instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemai l.naml -- View this message in context: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642758.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Searching from Dataframe.
Have you read An Introduction to R (ships with every copy of R) where these sorts of questions are answered? There are other R tutorials on the web also, if you look. -- Bert On Tue, Sep 11, 2012 at 3:59 AM, Rantony antony.akk...@ge.com wrote: And how to get the vector from a list if the list item found inside ? for eg:- MyList- c(US,UK,UAE) Here i want to check a list item UAE which is in 3rd row. How i will get that row position ? - Thanks in advance Antony -- View this message in context: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642744.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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 make a folder as package in R
More to the point, the OP needs to 1) Stop posting 2) Read the relevant portion of the Writing R Extensions Manuakl which has been written specifically to answer these sorts of questions in a comprehensive manner. Then if he/she has questions, he/she can ask. -- Bert On Tue, Sep 11, 2012 at 2:59 AM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, See also http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf Hope this helps, Rui Barradas Em 11-09-2012 09:53, R. Michael Weylandt escreveu: Start with ?package.skeleton() Cheers, Michael On Tue, Sep 11, 2012 at 9:47 AM, purushothaman purushothama...@ge.com wrote: Hi how to make a filder as R Package. for exampled c:\test folder having following files add.r test1.r sub.r i need to make package like this test_v1.zip. thanks B.Purushothaman -- View this message in context: http://r.789695.n4.nabble.com/how-to-make-a-folder-as-package-in-R-tp4642734.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Combine two variables
Hello, Inline. Em 11-09-2012 15:57, Simon Kiss escreveu: Hi: I have two variables in a data frame that are the results of a wording experiment in a survey. I'd like to create a third variable that combines the two variables. Recode doesn't seem to work, because it just recodes the first variable into the third, then recodes the second variable into the third, overwriting the first recode. I can do this with a rather elaborate indexing process, subsetting the first column and then copying the data into the second etc. But I'm looking for a cleaner way to do this. The data frame looks like this. df-data.frame(var1=sample(c('a','b','c',NA),replace=TRUE, size=100), var2=sample(c('a','b','c',NA),replace=TRUE,size=100)) df-subset(df, !is.na(var1) |!is.na(var2)) As you can see, if one variable has an NA, then the other variable has a valid value, No, not necessarily. You are using sample() and there's no reason to believe the sampled values for var1 and var2 are going to be different. My first try gave me several rows with both columns NA. Then I've used set.seed() and it became reproducible. set.seed(1) df1 - data.frame(var1=sample(c('a','b','c',NA), replace=TRUE, size=100), var2=sample(c('a','b','c',NA), replace=TRUE, size=100)) sum(is.na(df1$var1) is.na(df1$var2)) # 8 So I suppose this is not the case with your real dataset. Try the following. df1$var3 - df1$var1 df1$var3[is.na(df1$var1)] - df1$var2[is.na(df1$var1)] Hope this helps, Rui Barradas so how do I just combine the two variables into one? Thank you for your assistance. Simon Kiss __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on Android
On Tue, Sep 11, 2012 at 12:51 PM, Simon Fry s@gmx.ch wrote: Hello I tried to install R on my Transformer Prime without root. I downloaded the three files i found on: http://rwiki.sciviews.org/doku.php?id=getting-started:installation:android and i extract all the files, also without root my prime. But now i can't install R with the files i extractet. Is it possible to install R on my Prime without root and how can i do it? Or is root a must, for using R? It shouldn't be for the build process, (my local builds don't run as root) but it might be for getting the devtools in place. Where in the build process do you hit trouble? If there's a log output, post what you think are the relevant bits (too much is probably better than too little here) Cheers, Michael Thanks for help Simon [[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] Combine two variables
Hi I am not sure I understand correctly. In the sample dataframe you posted, the values in columns are different so based on what you did write I aasume that apply(df,1, paste, collapse=) gives you third variable combined from those 2 variables. If you want to select non NA value from any variable, which one will you select when there is no NA in some row? Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Simon Kiss Sent: Tuesday, September 11, 2012 4:57 PM To: r-help@r-project.org Subject: [R] Combine two variables Hi: I have two variables in a data frame that are the results of a wording experiment in a survey. I'd like to create a third variable that combines the two variables. Recode doesn't seem to work, because it just recodes the first variable into the third, then recodes the second variable into the third, overwriting the first recode. I can do this with a rather elaborate indexing process, subsetting the first column and then copying the data into the second etc. But I'm looking for a cleaner way to do this. The data frame looks like this. df-data.frame(var1=sample(c('a','b','c',NA),replace=TRUE, size=100), var2=sample(c('a','b','c',NA),replace=TRUE,size=100)) df-subset(df, !is.na(var1) |!is.na(var2)) As you can see, if one variable has an NA, then the other variable has a valid value, so how do I just combine the two variables into one? Thank you for your assistance. Simon Kiss __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Animation Problem
On Tue, Sep 11, 2012 at 4:52 PM, Bhupendrasinh Thakre vickytha...@gmail.com wrote: Hi List, I am trying to build an animation and facing problem as animation is not coming live. The goal is to build heart beats like diagram for the data given below. data : structure(list(date = 1971:1991, x = c(41L, 60L, 41L, 61L, 22L, 83L, 31L, 55L, 22L, 14L, 38L, 6L, 29L, 17L, 10L, 99L, 88L, 32L, 68L, 78L, 26L)), .Names = c(date, x), class = data.frame, row.names = c(NA, -21L)) Program : library(animation) library(ggplot2) anim - function(a){for (i in seq(1,21)) {pl - ggplot(a,aes(x=date,y=x))+geom_line()+scale_x_continuous(limits=c(1971,1991))+ scale_y_continuous(limits=c(0,100)) print(pl)}} This bit came out a bit mangled (if you could repost it with nicer formatting that'd be appreciated), but I see no dependence on i in here so there might simply not be any change to observe. Cheers, Michael saveMovie(anim(),interval=0.1,outdir=getwd()) Session Info : R version 2.15.1 (2012-06-22) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices datasets utils methods [7] base other attached packages: [1] animation_2.1 ggplot2_0.9.1 igraph_0.6-2 rcom_2.2-5 [5] rscproxy_2.0-5 loaded via a namespace (and not attached): [1] colorspace_1.1-1 dichromat_1.2-4digest_0.5.2 [4] grid_2.15.1labeling_0.1 MASS_7.3-18 [7] memoise_0.1munsell_0.3plyr_1.7.1 [10] proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1 [13] RGtk2_2.20.25 scales_0.2.1 stringr_0.6.1 [16] tools_2.15.1 Can some one help me to find the problem. The plot is coming but not the animation. Best Regards, Bhupendrasinh Thakre *Disclaimer :* The information contained in this communication is confi...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to make a folder as package in R
On Tue, Sep 11, 2012 at 10:42 AM, purushothaman purushothama...@ge.com wrote: Hi, i used this package.skeleton() function but i created using single R file. but i need to create package using more than one R file. Thanks B.Purushothaman B, Most of us don't use Nabble so posting with context is much appreciated. Could you not simply move the R files into the R/ directory of the package? Michael -- View this message in context: http://r.789695.n4.nabble.com/how-to-make-a-folder-as-package-in-R-tp4642734p4642739.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot dataframe with inconsistently relations
On Tue, Sep 11, 2012 at 2:22 PM, Geophagus f...@retposto.net wrote: Hi @ all, I work with a dataframe like the attached one. Hi Geo, Unfortunately, there is no attached data.frame. The mail servers are somewhat draconian in what they let through. A much better way to send data is to type dput(head(DATA, 20)) which will make some odd (to you) output. However, if you copy and paste that output into the body of your email, we can simply paste it into our R sessions to exactly reproduce your data. It's really a much better way to handle sending small data sets. Perhaps try that? Cheers, Michael I want to plot it, so that value is listed on the y-axis, year on the x-axis and states as lines in the coordinate system. I tried the following code: require(ggplot) plot1-ggplot(TEST, aes(year, value)) + geom_line(aes(colour = state)) The result could be very nice but the the lines are stacked. Maybe there is an easier way to do that? Thanks a lot for your help. Geo -- View this message in context: http://r.789695.n4.nabble.com/plot-dataframe-with-inconsistently-relations-tp4642766.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Maintaining specific order when using aggregate or change order on axis
Hi All, I'm using the following code to produce some stacked bar graphs. *setwd(C:\\Users\\Tinus\\Documents\\NMMU\\R\\Seamounts)* *SChla - read.csv(SM_Chla_data.csv)* * * *#Extract mean values from data file* * * *Coral - SChla[185:223,] #Reduce SChla to Coral only* *coral - with(Coral , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean))* *rownames(coral) - coral[,1] * *coral - t(coral[,-1]) # Remove Station col and transpose* *barplot(coral, main=Size fractionated Chl a for Coral, * * ylab = Coral, xlim = c(0,8), horiz = TRUE,* * xlab = expression (Chlorophyll a ~~ (mu*g ~ l^{-1})), * * col =c(light green, green, dark green),* * legend = rownames(coral))* Here is the *head(Coral) *before station col removal and t() Seamount Station Depth Pico Nano Micro Total_Ch 185Coral1401 Surface 0.216 3.270 4.2407.726 186Coral1401Fmax 0.359 3.890 4.9009.149 187Coral1401 Below 0.178 1.360 1.2102.748 188Coral1402 Surface 0.231 4.140 3.6708.041 189Coral1402Fmax 0.863 4.340 3.7508.953 190Coral1402 Below 0.176 0.386 0.2140.776 So I use the same code for the six other seamounts. The depth has the following values surface, shallow, deep, fmax and below . These are in order as you go down the water column. The problem is when I use the *coral - with(Coral , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean)) *the depth values gets stored in ascending values. head(coral) Group.1 Pico Nano Micro 1 Below 0.1652727 0.8610909 0.7227273 2Deep 0.148 1.170 1.100 3Fmax 0.3067273 3.1845455 3.2245455 4 Shallow 0.2617500 1.8242500 1.8637500 5 Surface 0.169 2.708 2.7858333 I would like to maintain the order surface, shallow, deep, fmax and below. *Or *if there is a way I can rearrange the yaxis in the order surface, shallow, deep, fmax and below. Any suggestions? Thank you Tinus -- M.J. Sonnekus PhD Candidate (The Phytoplankton of the southern Agulhas Current Large Marine Ecosystem (ACLME)) Department of Botany South Campus Nelson Mandela Metropolitan University PO Box 77000 Port Elizabeth South Africa 6031 Cell: 082 080 9638 E-mail: tsonne...@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] creating several different matrices
Further hint: If only there were some recently added distribution that was defined to give random matrices.. news() M On Tue, Sep 11, 2012 at 3:56 PM, PIKAL Petr petr.pi...@precheza.cz wrote: Hi Homework? No homework policy in this list. Anyway here are some hints. ?for ?split Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of cesare orsini Sent: Tuesday, September 11, 2012 4:17 PM To: r-help@r-project.org Subject: [R] creating several different matrices Dear people, I need to generate 100 different matrices, without particular characteristics but using only one command! Do you know some way? thank You -- View this message in context: http://r.789695.n4.nabble.com/creating- several-different-matrices-tp4642768.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Combine two variables
Hi, I am not sure how you describe combine. Try this: df1-subset(df, !is.na(var1) !is.na(var2)) df1$new-paste0(df1$var1,df1$var2) head(df1) # var1 var2 new #1 b a ba #2 c b cb #3 b b bb #5 a a aa #6 b b bb #7 a b ab A.K. - Original Message - From: Simon Kiss sjk...@gmail.com To: r-help@r-project.org Cc: Sent: Tuesday, September 11, 2012 10:57 AM Subject: [R] Combine two variables Hi: I have two variables in a data frame that are the results of a wording experiment in a survey. I'd like to create a third variable that combines the two variables. Recode doesn't seem to work, because it just recodes the first variable into the third, then recodes the second variable into the third, overwriting the first recode. I can do this with a rather elaborate indexing process, subsetting the first column and then copying the data into the second etc. But I'm looking for a cleaner way to do this. The data frame looks like this. df-data.frame(var1=sample(c('a','b','c',NA),replace=TRUE, size=100), var2=sample(c('a','b','c',NA),replace=TRUE,size=100)) df-subset(df, !is.na(var1) |!is.na(var2)) As you can see, if one variable has an NA, then the other variable has a valid value, so how do I just combine the two variables into one? Thank you for your assistance. Simon Kiss __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] creating several different matrices
Hello, Try, using data and matrix dims of your choice, replicate(100, matrix(rnorm(12), ncol = 3)) Hope this helps, Rui Barradas Em 11-09-2012 15:17, cesare orsini escreveu: Dear people, I need to generate 100 different matrices, without particular characteristics but using only one command! Do you know some way? thank You -- View this message in context: http://r.789695.n4.nabble.com/creating-several-different-matrices-tp4642768.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sort or Permutate
Hi, You can also use: within(small,{order(value)}) # file.name value #1 /storage/storage0/59Off.Rtable 0.2203863 #3 /storage/storage0/5912314ff.Rtable 0.2886594 #2 /storage/storage0/5912On.Rtable 0.4052370 A.K. - Original Message - From: Berend Hasselman b...@xs4all.nl To: Alaios ala...@yahoo.com Cc: R help R-help@r-project.org Sent: Tuesday, September 11, 2012 11:00 AM Subject: Re: [R] Sort or Permutate On 11-09-2012, at 13:13, Alaios wrote: Dear all, I am having a struct that contains on the first column file names and on the second column a number which is a rating of the file on first column A small subset looks like that small [,1] [1,] /storage/storage0/59Off.Rtable [2,] /storage/storage0/5912On.Rtable [3,] /storage/storage0/5912314ff.Rtable [,2] [1,] 0.220386301811093 [2,] 0.405237035258638 [3,] 0.288659374128626 I want based on the values of column two to rearrange table elements by keeping though the row elements together. For example if I order those in ascending order should look like small [,1] [1,] /storage/storage0/59Off.Rtable [2,] /storage/storage0/5912314ff.Rtable [3,] /storage/storage0/5912On.Rtable [,2] [1,] 0.220386301811093 [2,] 0.288659374128626 [3,] 0.405237035258638 I have tried with sort, sort.list and order but I have failed . I do not quite undestand how one can complete this task in R. Could you please spend some time helping me? Please provide data using dput. You can do it using order() like this small - data.frame(file.name=c( /storage/storage0/59Off.Rtable, /storage/storage0/5912On.Rtable, /storage/storage0/5912314ff.Rtable), stringsAsFactors=FALSE, value=c( 0.220386301811093, 0.405237035258638, 0.288659374128626) ) v.index - order(small[,value]) small - small[v.index,] small 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Maintaining specific order when using aggregate or change order on axis
Hello, If you order your original (wanted) order and then order that result you get what you want. The example is with fake data but the idea is in the last two lines. # Make up some data set.seed(9210) n - 1e2 depth - c('surface', 'shallow', 'deep', 'fmax', 'below') dat - data.frame(Depth = sample(depth, n, TRUE), Value = runif(n)) # This is sorted by increasing Depth agg - aggregate(Value ~ Depth, data = dat, FUN = mean) ix - order(depth) # First step agg[order(ix), ] # inverse permutation Hope this helps, Rui Barradas Em 11-09-2012 18:52, Tinus Sonnekus escreveu: Hi All, I'm using the following code to produce some stacked bar graphs. *setwd(C:\\Users\\Tinus\\Documents\\NMMU\\R\\Seamounts)* *SChla - read.csv(SM_Chla_data.csv)* * * *#Extract mean values from data file* * * *Coral - SChla[185:223,] #Reduce SChla to Coral only* *coral - with(Coral , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean))* *rownames(coral) - coral[,1] * *coral - t(coral[,-1]) # Remove Station col and transpose* *barplot(coral, main=Size fractionated Chl a for Coral, * * ylab = Coral, xlim = c(0,8), horiz = TRUE,* * xlab = expression (Chlorophyll a ~~ (mu*g ~ l^{-1})), * * col =c(light green, green, dark green),* * legend = rownames(coral))* Here is the *head(Coral) *before station col removal and t() Seamount Station Depth Pico Nano Micro Total_Ch 185Coral1401 Surface 0.216 3.270 4.2407.726 186Coral1401Fmax 0.359 3.890 4.9009.149 187Coral1401 Below 0.178 1.360 1.2102.748 188Coral1402 Surface 0.231 4.140 3.6708.041 189Coral1402Fmax 0.863 4.340 3.7508.953 190Coral1402 Below 0.176 0.386 0.2140.776 So I use the same code for the six other seamounts. The depth has the following values surface, shallow, deep, fmax and below . These are in order as you go down the water column. The problem is when I use the *coral - with(Coral , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean)) *the depth values gets stored in ascending values. head(coral) Group.1 Pico Nano Micro 1 Below 0.1652727 0.8610909 0.7227273 2Deep 0.148 1.170 1.100 3Fmax 0.3067273 3.1845455 3.2245455 4 Shallow 0.2617500 1.8242500 1.8637500 5 Surface 0.169 2.708 2.7858333 I would like to maintain the order surface, shallow, deep, fmax and below. *Or *if there is a way I can rearrange the yaxis in the order surface, shallow, deep, fmax and below. Any suggestions? Thank you Tinus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] lapply with different size lists?
Hello, I have 2 functions (a and b) a = function(n) { matrix (runif(n*2,0.0,1), n) } b = function (m, matrix) { n=nrow (matrix) p=ceiling (n/m) lapply (1:p, function (l,n,m) { inf = ((l-1)*m)+1 if (lp) sup=((l-1)*m)+m else sup=n data.frame (matrix (lapply (inf: sup, function(i) c(i, Inf, matrix[i,1], matrix[i,2]) ), nrow=m ) ) }, n=n, m=m ) } my.matrix = a(7) my.matrix [,1] [,2] [1,] 0.708060983 0.3242221 [2,] 0.356736311 0.1454096 [3,] 0.402880340 0.4763676 [4,] 0.795947223 0.4052168 [5,] 0.001620093 0.2618591 [6,] 0.192215589 0.6595275 [7,] 0.539199304 0.5402015 b (m=6,matrix=my_matrix) [[1]] matrix.lapply.inf.sup..function.i..c.i..Inf..matrix.i..1...matrix.i.. 1 1.000, Inf, 0.7080610, 0.3242221 2 2.000, Inf, 0.3567363, 0.1454096 3 3.000, Inf, 0.4028803, 0.4763676 4 4.000, Inf, 0.7959472, 0.4052168 55.0, Inf, 0.001620093, 0.261859077 6 6.000, Inf, 0.1922156, 0.6595275 [[2]] matrix.lapply.inf.sup..function.i..c.i..Inf..matrix.i..1...matrix.i.. 1 7.000, Inf, 0.5391993, 0.5402015 2 7.000, Inf, 0.5391993, 0.5402015 3 7.000, Inf, 0.5391993, 0.5402015 4 7.000, Inf, 0.5391993, 0.5402015 5 7.000, Inf, 0.5391993, 0.5402015 6 7.000, Inf, 0.5391993, 0.5402015 It seems like the second list is filled with repeated rows (from 2 to 6) I would like the second list to stop in the last row of the my_matrix So, I would like to have the following result: b (m=6,matrix=my_matrix) [[1]] matrix.lapply.inf.sup..function.i..c.i..Inf..matrix.i..1...matrix.i.. 1 1.000, Inf, 0.7080610, 0.3242221 2 2.000, Inf, 0.3567363, 0.1454096 3 3.000, Inf, 0.4028803, 0.4763676 4 4.000, Inf, 0.7959472, 0.4052168 55.0, Inf, 0.001620093, 0.261859077 6 6.000, Inf, 0.1922156, 0.6595275 [[2]] matrix.lapply.inf.sup..function.i..c.i..Inf..matrix.i..1...matrix.i.. 1 7.000, Inf, 0.5391993, 0.5402015 Can`t I do this with an apply function? Is there any more efficient way that substituting the lapply by a for loop? THanks, Rui [[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] cex.lab ignored in plot.zoo for multiple plots
On Sep 11, 2012, at 7:48 AM, Gabor Grothendieck wrote: On Wed, Sep 5, 2012 at 11:06 AM, Nicolai Schneider rstatistics.u...@gmail.com wrote: Hello everyone, a problem with the plot.zoo function. In the parameters of the function, cex.lab is ignored. I tried to reduce the size of the yaxis labels by at least 50%. -- Example: sample - as.zoo(EuStockMarkets) par(las=1) plot.zoo(sample, plot.type=multiple, main=Time Series, xlab=Date, yaxt=n, cex.lab=0.5, xaxs=i) # Try playing with different values for cex.lab par(las=0) Internally it uses mtext to write that text and mtext uses cex which is already taken. Here is a workaround: library(proto) p - proto(plot.zoo = plot.zoo, mtext = function(...) graphics::mtext(..., cex = .5)) with(p, plot.zoo)(sample) So that creates an R environment where you are creating an unmodified instance of the plot.zoo function as well as installing a genetically-modified instance of mtext which has a redefinition of the parameter list to graphics::mtext()? (So using `(... , arg=newval)` is an acceptable way to over-rule a parameter list assignment? It certainly seems to be.) So when you access access that p-instance of plot.zoo(), it finds this new genetically-modified instance of mtext() because it is in the same environment? And the reason it doesn't work to just redefine mtext (I tried) is that it would be in an environment that plot.zoo would not examine first when called from the command line? -- David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get curve information from a gam model
On Sep 11, 2012, at 8:08 AM, exu wrote: I'm using library(mgcv) I did a gam regression like this model - gam(formula = y ~ s(x), family=binomial) Now I'd like to get 2 vectors x and z (with z=s(x)), so that I can implement the model outside R. How can I do this? ?predict.gam -- David Winsemius, MD 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] Strange result from GAMLSS
Hi Folks! Just started using the gamlss package and I tried a simple code example (see below). Why the negative sigma? John y - rt(100, df=1) m1-fitDist(y, type=realline)Warning messages:1: In MLE(ll3, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)2: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)3: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)4: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)5: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8) m1 Family: c(TF, t Family) Fitting method: nlminb Call: gamlssML(y = y, family = DIST[i]) Mu Coefficients: [1] 0.2376 Sigma Coefficients: [1] -0.09865 Nu Coefficients: [1] -0.2281 Degrees of Freedom for the fit: 3 Residual Deg. of Freedom 97 Global Deviance: 545.069 AIC: 551.069 SBC: 558.885 Another draw: y - rt(100, df=1) m1-fitDist(y, type=realline)Warning messages:1: In MLE(ll3, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)2: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)3: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)4: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)5: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8) m1 Family: c(ST1, Skew t (Azzalini type 1)) Fitting method: nlminb Call: gamlssML(y = y, family = DIST[i]) Mu Coefficients: [1] -0.05249 Sigma Coefficients: [1] -0.1545 Nu Coefficients: [1] 0.04445 Tau Coefficients: [1] -0.1352 Degrees of Freedom for the fit: 4 Residual Deg. of Freedom 96 Global Deviance: 505.414 AIC: 513.414 SBC: 523.835 sessionInfo()R version 2.15.1 (2012-06-22) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] splines stats graphics grDevices utils datasets methods base other attached packages: [1] gamlss_4.1-8 gamlss.data_4.1-0 gamlss.dist_4.1-6 nlme_3.1-104 MASS_7.3-21 loaded via a namespace (and not attached): [1] grid_2.15.1 lattice_0.20-10 survival_2.36-14 tools_2.15.1 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cex.lab ignored in plot.zoo for multiple plots
On Tue, Sep 11, 2012 at 2:54 PM, David Winsemius dwinsem...@comcast.net wrote: On Sep 11, 2012, at 7:48 AM, Gabor Grothendieck wrote: On Wed, Sep 5, 2012 at 11:06 AM, Nicolai Schneider rstatistics.u...@gmail.com wrote: Hello everyone, a problem with the plot.zoo function. In the parameters of the function, cex.lab is ignored. I tried to reduce the size of the yaxis labels by at least 50%. -- Example: sample - as.zoo(EuStockMarkets) par(las=1) plot.zoo(sample, plot.type=multiple, main=Time Series, xlab=Date, yaxt=n, cex.lab=0.5, xaxs=i) # Try playing with different values for cex.lab par(las=0) Internally it uses mtext to write that text and mtext uses cex which is already taken. Here is a workaround: library(proto) p - proto(plot.zoo = plot.zoo, mtext = function(...) graphics::mtext(..., cex = .5)) with(p, plot.zoo)(sample) So that creates an R environment where you are creating an unmodified instance of the plot.zoo function as well as installing a genetically-modified instance of mtext which has a redefinition of the parameter list to graphics::mtext()? (So using `(... , arg=newval)` is an acceptable way to over-rule a parameter list assignment? It certainly seems to be.) So when you access access that p-instance of plot.zoo(), it finds this new genetically-modified instance of mtext() because it is in the same environment? And the reason it doesn't work to just redefine mtext (I tried) is that it would be in an environment that plot.zoo would not examine first when called from the command line? Yes, proto changes the environment of plot.zoo when its inserted into p. For comparison it could be done like this without proto: e - local({ mtext - function(...) graphics::mtext(..., cex = 0.5) environment(plot.zoo) - environment() }) with(e, plot.zoo)(sample) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lapply with different size lists?
Hello, When you don't know what's going on, break long instructions into simpler ones. R is good at doing a lot in one line, to debug don't do that. b = function (m, mat) { n=nrow (mat) p=ceiling (n/m) lapply (1:p, function (l,n,m) { inf = ((l-1)*m)+1 if (lp) sup=((l-1)*m)+m else sup=n lst - lapply( inf:sup, function(i) c(i, Inf, mat[i, 1], mat[i, 2]) ) data.frame( matrix(lst, nrow=length(lst)) ) #data.frame( matrix(unlist(lst), nrow=length(lst)) ) }, n=n, m=m ) } It returns a list of data.frames with 1 column only. If you want 4 column data.frames, uncomment the instruction above (and comment out the previuos one). Hope this helps, Rui Barradas Em 11-09-2012 19:44, Rui Esteves escreveu: Hello, I have 2 functions (a and b) a = function(n) { matrix (runif(n*2,0.0,1), n) } b = function (m, matrix) { n=nrow (matrix) p=ceiling (n/m) lapply (1:p, function (l,n,m) { inf = ((l-1)*m)+1 if (lp) sup=((l-1)*m)+m else sup=n data.frame (matrix (lapply (inf: sup, function(i) c(i, Inf, matrix[i,1], matrix[i,2]) ), nrow=m ) ) }, n=n, m=m ) } my.matrix = a(7) my.matrix [,1] [,2] [1,] 0.708060983 0.3242221 [2,] 0.356736311 0.1454096 [3,] 0.402880340 0.4763676 [4,] 0.795947223 0.4052168 [5,] 0.001620093 0.2618591 [6,] 0.192215589 0.6595275 [7,] 0.539199304 0.5402015 b (m=6,matrix=my_matrix) [[1]] matrix.lapply.inf.sup..function.i..c.i..Inf..matrix.i..1...matrix.i.. 1 1.000, Inf, 0.7080610, 0.3242221 2 2.000, Inf, 0.3567363, 0.1454096 3 3.000, Inf, 0.4028803, 0.4763676 4 4.000, Inf, 0.7959472, 0.4052168 55.0, Inf, 0.001620093, 0.261859077 6 6.000, Inf, 0.1922156, 0.6595275 [[2]] matrix.lapply.inf.sup..function.i..c.i..Inf..matrix.i..1...matrix.i.. 1 7.000, Inf, 0.5391993, 0.5402015 2 7.000, Inf, 0.5391993, 0.5402015 3 7.000, Inf, 0.5391993, 0.5402015 4 7.000, Inf, 0.5391993, 0.5402015 5 7.000, Inf, 0.5391993, 0.5402015 6 7.000, Inf, 0.5391993, 0.5402015 It seems like the second list is filled with repeated rows (from 2 to 6) I would like the second list to stop in the last row of the my_matrix So, I would like to have the following result: b (m=6,matrix=my_matrix) [[1]] matrix.lapply.inf.sup..function.i..c.i..Inf..matrix.i..1...matrix.i.. 1 1.000, Inf, 0.7080610, 0.3242221 2 2.000, Inf, 0.3567363, 0.1454096 3 3.000, Inf, 0.4028803, 0.4763676 4 4.000, Inf, 0.7959472, 0.4052168 55.0, Inf, 0.001620093, 0.261859077 6 6.000, Inf, 0.1922156, 0.6595275 [[2]] matrix.lapply.inf.sup..function.i..c.i..Inf..matrix.i..1...matrix.i.. 1 7.000, Inf, 0.5391993, 0.5402015 Can`t I do this with an apply function? Is there any more efficient way that substituting the lapply by a for loop? THanks, Rui [[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] balanced two-way crossed balanced random effects analysis of variance
Hello, All, I am wondering if there is a standard library/function for calculating variance components (or the variance of the total mean) of a balanced two-way crossed random effects problem a la equation 7.4.10 of Scheffe or section 14.5 of Brownlee. My model is s_ij = \mu + x_i + y_j + e_ij x, y, and e are random and I need the variance of the mean of s. I know that I can do this with lme4 or nlme, but I need the unbiased variance calculated from the sum of squares, not a maximum likelihood estimate. I know this is easy enough to implement myself (I have already done it.), but I would like to be able to reference an existing downloadable implementation. Thanks for any help. -Frank __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Detrended Fluctuation Analysis (fractal pkg) troubleshooting
I'm working with the DFA (detrended fluctuation analysis) function in the package fractal on postural sway data, and for the life of me can't get the results to turn out as they should given what my data looks like. The data resemble a random walk, but the Hurst exponent estimates that I'm getting at ~0.9 instead of ~1.4, which is the value a researcher I've been working with who uses Matlab has been able to get and which makes more sense as a valid outcome. I've set my scale.order parameter to 1, in order to integrate the data before performing DFA, and otherwise left the other parameters as default. Anyone have experience with DFA in R either with this package or another? I'd really appreciate any guidance on the subject. - Rachel Graduate Student at University of MN, Frantically trying to finish Masters Project in the next week or so. -- View this message in context: http://r.789695.n4.nabble.com/Detrended-Fluctuation-Analysis-fractal-pkg-troubleshooting-tp4642820.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] how can I get a layout like in pairs()?
dear R gurus, I repeatedly run into this problem, maybe there's an easy way to solve it. I want a composite plot with multiple graphs that share the same axis, similar way as done by the pairs() (eg. like this here http://www.r-project.org/screenshots/iris-pairs.jpg). all plot panels shall have the same size, but there need to be extra space at the outside of the whole graphic to label the axis. space between the panels should be minimal. I tried to set par(mar) to low levels, and add additional space with par(oma) for axistick labels, however, the individual plots can't draw into the oma space - is there an alternative way? thanks a lot, lukas This electronic communication is governed by the terms and conditions at http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2012.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Maintaining specific order when using aggregate or change order on axis
Hi, The order you mentioned is confusing. The given data shows depth to be increasing from Below,Surface,Fmax. This might help you in ordering. Coral1-read.table(text= Seamount Station Depth Pico Nano Micro Total_Ch Coral 1401 Surface 0.216 3.270 4.240 7.726 Coral 1401 Fmax 0.359 3.890 4.900 9.149 Coral 1401 Below 0.178 1.360 1.210 2.748 Coral 1402 Surface 0.231 4.140 3.670 8.041 Coral 1402 Fmax 0.863 4.340 3.750 8.953 Coral 1402 Below 0.176 0.386 0.214 0.776 ,sep=,header=TRUE,stringsAsFactors=TRUE) Coral2-with(Coral1 , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean)) Coral2[order(Coral2$Pico,Coral2$Nano,Coral2$Micro),] # Group.1 Pico Nano Micro #1 Below 0.1770 0.873 0.712 #3 Surface 0.2235 3.705 3.955 #2 Fmax 0.6110 4.115 4.325 #reverse order Coral2[rev(order(Coral2$Pico,Coral2$Nano,Coral2$Micro)),] # Group.1 Pico Nano Micro #2 Fmax 0.6110 4.115 4.325 #3 Surface 0.2235 3.705 3.955 #1 Below 0.1770 0.873 0.712 A.K. - Original Message - From: Tinus Sonnekus tsonne...@gmail.com To: r-help@r-project.org Cc: Sent: Tuesday, September 11, 2012 1:52 PM Subject: [R] Maintaining specific order when using aggregate or change order on axis Hi All, I'm using the following code to produce some stacked bar graphs. *setwd(C:\\Users\\Tinus\\Documents\\NMMU\\R\\Seamounts)* *SChla - read.csv(SM_Chla_data.csv)* * * *#Extract mean values from data file* * * *Coral - SChla[185:223,] #Reduce SChla to Coral only* *coral - with(Coral , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean))* *rownames(coral) - coral[,1] * *coral - t(coral[,-1]) # Remove Station col and transpose* *barplot(coral, main=Size fractionated Chl a for Coral, * * ylab = Coral, xlim = c(0,8), horiz = TRUE,* * xlab = expression (Chlorophyll a ~~ (mu*g ~ l^{-1})), * * col =c(light green, green, dark green),* * legend = rownames(coral))* Here is the *head(Coral) *before station col removal and t() Seamount Station Depth Pico Nano Micro Total_Ch 185 Coral 1401 Surface 0.216 3.270 4.240 7.726 186 Coral 1401 Fmax 0.359 3.890 4.900 9.149 187 Coral 1401 Below 0.178 1.360 1.210 2.748 188 Coral 1402 Surface 0.231 4.140 3.670 8.041 189 Coral 1402 Fmax 0.863 4.340 3.750 8.953 190 Coral 1402 Below 0.176 0.386 0.214 0.776 So I use the same code for the six other seamounts. The depth has the following values surface, shallow, deep, fmax and below . These are in order as you go down the water column. The problem is when I use the *coral - with(Coral , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean)) *the depth values gets stored in ascending values. head(coral) Group.1 Pico Nano Micro 1 Below 0.1652727 0.8610909 0.7227273 2 Deep 0.148 1.170 1.100 3 Fmax 0.3067273 3.1845455 3.2245455 4 Shallow 0.2617500 1.8242500 1.8637500 5 Surface 0.169 2.708 2.7858333 I would like to maintain the order surface, shallow, deep, fmax and below. *Or *if there is a way I can rearrange the yaxis in the order surface, shallow, deep, fmax and below. Any suggestions? Thank you Tinus -- M.J. Sonnekus PhD Candidate (The Phytoplankton of the southern Agulhas Current Large Marine Ecosystem (ACLME)) Department of Botany South Campus Nelson Mandela Metropolitan University PO Box 77000 Port Elizabeth South Africa 6031 Cell: 082 080 9638 E-mail: tsonne...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Maintaining specific order when using aggregate or change order on axis
Right after importing your data with read.csv, make a factor out of your Depth column and give it levels in the desired order. E.g., SChla$Depth - factor(SChla$Depth, levels=c(Surface, Shallow, Deep, Fmax, Below)) (Capitalization is important, Below is not the same as below.) To check that things were imported as expect do table(SChla$Dept) before and after the change. Only the order of the table entries should change. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tinus Sonnekus Sent: Tuesday, September 11, 2012 10:52 AM To: r-help@r-project.org Subject: [R] Maintaining specific order when using aggregate or change order on axis Hi All, I'm using the following code to produce some stacked bar graphs. *setwd(C:\\Users\\Tinus\\Documents\\NMMU\\R\\Seamounts)* *SChla - read.csv(SM_Chla_data.csv)* * * *#Extract mean values from data file* * * *Coral - SChla[185:223,] #Reduce SChla to Coral only* *coral - with(Coral , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean))* *rownames(coral) - coral[,1] * *coral - t(coral[,-1]) # Remove Station col and transpose* *barplot(coral, main=Size fractionated Chl a for Coral, * * ylab = Coral, xlim = c(0,8), horiz = TRUE,* * xlab = expression (Chlorophyll a ~~ (mu*g ~ l^{-1})), * * col =c(light green, green, dark green),* * legend = rownames(coral))* Here is the *head(Coral) *before station col removal and t() Seamount Station Depth Pico Nano Micro Total_Ch 185Coral1401 Surface 0.216 3.270 4.2407.726 186Coral1401Fmax 0.359 3.890 4.9009.149 187Coral1401 Below 0.178 1.360 1.2102.748 188Coral1402 Surface 0.231 4.140 3.6708.041 189Coral1402Fmax 0.863 4.340 3.7508.953 190Coral1402 Below 0.176 0.386 0.2140.776 So I use the same code for the six other seamounts. The depth has the following values surface, shallow, deep, fmax and below . These are in order as you go down the water column. The problem is when I use the *coral - with(Coral , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean)) *the depth values gets stored in ascending values. head(coral) Group.1 Pico Nano Micro 1 Below 0.1652727 0.8610909 0.7227273 2Deep 0.148 1.170 1.100 3Fmax 0.3067273 3.1845455 3.2245455 4 Shallow 0.2617500 1.8242500 1.8637500 5 Surface 0.169 2.708 2.7858333 I would like to maintain the order surface, shallow, deep, fmax and below. *Or *if there is a way I can rearrange the yaxis in the order surface, shallow, deep, fmax and below. Any suggestions? Thank you Tinus -- M.J. Sonnekus PhD Candidate (The Phytoplankton of the southern Agulhas Current Large Marine Ecosystem (ACLME)) Department of Botany South Campus Nelson Mandela Metropolitan University PO Box 77000 Port Elizabeth South Africa 6031 Cell: 082 080 9638 E-mail: tsonne...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Maintaining specific order when using aggregate or change order on axis
Hi, In that case, try this: #made up data Coral1-read.table(text= Seamount Station Depth Pico Nano Micro Total_Ch Coral 1401 Surface 0.216 3.270 4.240 7.726 Coral 1401 Fmax 0.359 3.890 4.900 9.149 Coral 1401 Below 0.178 1.360 1.210 2.748 Coral 1402 Surface 0.231 4.140 3.670 8.041 Coral 1402 Fmax 0.863 4.340 3.750 8.953 Coral 1402 Below 0.176 0.386 0.214 0.776 Coral 1401 Surface 0.216 3.270 4.240 7.726 Coral 1401 Shallow 0.359 3.890 4.900 9.149 Coral 1401 Deep 0.278 1.860 1.210 2.748 Coral 1402 Surface 0.331 4.940 3.670 8.041 Coral 1402 Fmax 0.493 4.840 3.750 8.953 Coral 1402 Below 0.186 0.486 0.214 0.776 ,sep=,header=TRUE,stringsAsFactors=FALSE) Coral2-with(Coral1 , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean)) Coral2[order(order(c(Surface,Shallow,Deep,Fmax,Below))),] # Group.1 Pico Nano Micro #5 Surface 0.2485000 3.905000 3.955000 #4 Shallow 0.359 3.89 4.90 #2 Deep 0.278 1.86 1.21 #3 Fmax 0.5716667 4.356667 4.13 #1 Below 0.180 0.744000 0.546000 A.K. From: Tinus Sonnekus tsonne...@gmail.com To: arun smartpink...@yahoo.com Sent: Tuesday, September 11, 2012 2:36 PM Subject: Re: [R] Maintaining specific order when using aggregate or change order on axis Hi, Thanks for the reply. I know the order is abit confusing, but here is abit more background info to the depths. For the various depths the ships's ctd sampled. surface = ctd @ surface e.g 5m shallow = between surface and fmax e.g. 25m deep = between surface and fmax, but deeper than shallow e.g 50m fmax = ctd sampled at maximum flouresence e.g 100m below = below the fmax e.g. 200m The problem I can't really assign a specific depth value to each as fmax changed depth depending on location. If fmax was very shallow then deep and shallow was dropped from the predetermined sampling depths. Hope this helps explain what I'm trying to do with the ordering of the data. Thanks for all your help. Been a steep learning curve this last week with R Shot Tinus On Tue, Sep 11, 2012 at 8:16 PM, arun smartpink...@yahoo.com wrote: Hi, The order you mentioned is confusing. The given data shows depth to be increasing from Below,Surface,Fmax. This might help you in ordering. Coral1-read.table(text= Seamount Station Depth Pico Nano Micro Total_Ch Coral 1401 Surface 0.216 3.270 4.240 7.726 Coral 1401 Fmax 0.359 3.890 4.900 9.149 Coral 1401 Below 0.178 1.360 1.210 2.748 Coral 1402 Surface 0.231 4.140 3.670 8.041 Coral 1402 Fmax 0.863 4.340 3.750 8.953 Coral 1402 Below 0.176 0.386 0.214 0.776 ,sep=,header=TRUE,stringsAsFactors=TRUE) Coral2-with(Coral1 , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean)) Coral2[order(Coral2$Pico,Coral2$Nano,Coral2$Micro),] # Group.1 Pico Nano Micro #1 Below 0.1770 0.873 0.712 #3 Surface 0.2235 3.705 3.955 #2 Fmax 0.6110 4.115 4.325 #reverse order Coral2[rev(order(Coral2$Pico,Coral2$Nano,Coral2$Micro)),] # Group.1 Pico Nano Micro #2 Fmax 0.6110 4.115 4.325 #3 Surface 0.2235 3.705 3.955 #1 Below 0.1770 0.873 0.712 A.K. - Original Message - From: Tinus Sonnekus tsonne...@gmail.com To: r-help@r-project.org Cc: Sent: Tuesday, September 11, 2012 1:52 PM Subject: [R] Maintaining specific order when using aggregate or change order on axis Hi All, I'm using the following code to produce some stacked bar graphs. *setwd(C:\\Users\\Tinus\\Documents\\NMMU\\R\\Seamounts)* *SChla - read.csv(SM_Chla_data.csv)* * * *#Extract mean values from data file* * * *Coral - SChla[185:223,] #Reduce SChla to Coral only* *coral - with(Coral , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean))* *rownames(coral) - coral[,1] * *coral - t(coral[,-1]) # Remove Station col and transpose* *barplot(coral, main=Size fractionated Chl a for Coral, * * ylab = Coral, xlim = c(0,8), horiz = TRUE,* * xlab = expression (Chlorophyll a ~~ (mu*g ~ l^{-1})), * * col =c(light green, green, dark green),* * legend = rownames(coral))* Here is the *head(Coral) *before station col removal and t() Seamount Station Depth Pico Nano Micro Total_Ch 185 Coral 1401 Surface 0.216 3.270 4.240 7.726 186 Coral 1401 Fmax 0.359 3.890 4.900 9.149 187 Coral 1401 Below 0.178 1.360 1.210 2.748 188 Coral 1402 Surface 0.231 4.140 3.670 8.041 189 Coral 1402 Fmax 0.863 4.340 3.750 8.953 190 Coral 1402 Below 0.176 0.386 0.214 0.776 So I use the same code for the six other seamounts. The depth has the following values surface, shallow, deep, fmax and below . These are in order as you go down the water column. The problem is when I use the *coral - with(Coral , aggregate(cbind(Pico, Nano, Micro), list(Depth),FUN=mean)) *the depth values gets stored in ascending values. head(coral) Group.1 Pico Nano Micro
Re: [R] How to get curve information from a gam model
Thanks for the response. But I'm relatively new to R, could you elaborate a bit? I tried P -predict.gam(model,type=terms) But I'm having a hard time to trying to make sense of the resulting data. Regards, Eugene Xu LIBREMAX CAPITAL, LLC. 830 Third Avenue Suite 801 NewYork, NY 10022 (212) 612-1598 (O) (908) 656-0306 (M) (646) 380-2689 (F) From: David Winsemius [via R] [mailto:ml-node+s789695n4642822...@n4.nabble.com] Sent: Tuesday, September 11, 2012 3:00 PM To: Eugene Xu Subject: Re: How to get curve information from a gam model On Sep 11, 2012, at 8:08 AM, exu wrote: I'm using library(mgcv) I did a gam regression like this model - gam(formula = y ~ s(x), family=binomial) Now I'd like to get 2 vectors x and z (with z=s(x)), so that I can implement the model outside R. How can I do this? ?predict.gam -- David Winsemius, MD Alameda, CA, USA __ [hidden email]/user/SendEmail.jtp?type=nodenode=4642822i=0 mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/How-to-get-curve-information-from-a-gam-model-tp4642785p4642822.html To unsubscribe from How to get curve information from a gam model, click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4642785code=ZXh1QGxpYnJlbWF4LmNvbXw0NjQyNzg1fDg4MjI4NzM1. NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml This communication and any attachments may contain confidential/proprietary information and is intended for information purposes only. It is not an invitation or offer to purchase interests from LibreMax Capital, LLC or any of its funds. Any representation to the contrary is unintentional. This communication is intended only for the person(s) to whom it is addressed. If you are not the intended recipient you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message or any attachments is not permitted. If you have received this in error, please notify the sender immediately by e-mail and delete this message. All e-mails sent to or received from this address will be received by LibreMax Capital's company e-mail system and are subject to archival and possible review by someone other than the recipient. -- View this message in context: http://r.789695.n4.nabble.com/How-to-get-curve-information-from-a-gam-model-tp4642785p4642823.html Sent from the R help mailing list archive at Nabble.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] Strange result from GAMLSS
Hi John, I don't have access to R right now but do remember that some of the parametersin gamlss have log and/or logit link functions which would give the possibility for negative values. Hth, Ingmar Department of Psychology University of Amsterdam Op 11 Sep 2012 om 21:01 heeft John Kerpel john.ker...@gmail.com het volgende geschreven: Hi Folks! Just started using the gamlss package and I tried a simple code example (see below). Why the negative sigma? John y - rt(100, df=1) m1-fitDist(y, type=realline)Warning messages:1: In MLE(ll3, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)2: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)3: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)4: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)5: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8) m1 Family: c(TF, t Family) Fitting method: nlminb Call: gamlssML(y = y, family = DIST[i]) Mu Coefficients: [1] 0.2376 Sigma Coefficients: [1] -0.09865 Nu Coefficients: [1] -0.2281 Degrees of Freedom for the fit: 3 Residual Deg. of Freedom 97 Global Deviance: 545.069 AIC: 551.069 SBC: 558.885 Another draw: y - rt(100, df=1) m1-fitDist(y, type=realline)Warning messages:1: In MLE(ll3, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)2: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)3: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)4: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8)5: In MLE(ll4, start = list(eta.mu = eta.mu, eta.sigma = eta.sigma, : possible convergence problem: optim gave code=1 false convergence (8) m1 Family: c(ST1, Skew t (Azzalini type 1)) Fitting method: nlminb Call: gamlssML(y = y, family = DIST[i]) Mu Coefficients: [1] -0.05249 Sigma Coefficients: [1] -0.1545 Nu Coefficients: [1] 0.04445 Tau Coefficients: [1] -0.1352 Degrees of Freedom for the fit: 4 Residual Deg. of Freedom 96 Global Deviance: 505.414 AIC: 513.414 SBC: 523.835 sessionInfo()R version 2.15.1 (2012-06-22) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] splines stats graphics grDevices utils datasets methods base other attached packages: [1] gamlss_4.1-8 gamlss.data_4.1-0 gamlss.dist_4.1-6 nlme_3.1-104 MASS_7.3-21 loaded via a namespace (and not attached): [1] grid_2.15.1 lattice_0.20-10 survival_2.36-14 tools_2.15.1 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Panels of Geographical Maps
Dear All, Please consider the snippet at the end of the email. My problem is rather simple: I can generate individual maps of a country where each region is colored according to a scalar, but I am experiencing problems when I try to combine e.g. 2 maps into a single figure using the mfrow(2,1) parameter. This does not give me any trouble when I use plot, but I must be misunderstanding something when I resort to spplot (one plot gets overwritten and no panel is generated). Any suggestion is really appreciated. Cheers Lorenzo # library(sp) con - load(ITA_adm1.RData) unemployment - c(6.2,11.2,9.5,11.2,11.2,2.9, 3.4,6.4,4.8,3.4,4.2,8.1,4.2,9.9,13.0,4.3,2.7,4.6,3.2,3.3) gadm$unemployment - as.factor(unemployment) col = rev(heat.colors(length(levels(gadm$unemployment par.set - list(axis.line=list(col=transparent), clip=list(panel=off), par.main.text=list(col=white), axis.text=list(col=white), fontsize=list(text=18)) png(unemployment2.png, width=630, height=630, bg=grey15) print(spplot(gadm, unemployment, col.regions=col, col=grey15, main=list(label=Italia - Tassi di disoccupazione 2007), res=88, par.settings=par.set)) dev.off() png(unemployment-panel.png, width=630, height=630, bg=grey15) par(mfrow=c(2,1), mar = c(4.5,5, 1, 1) + 0.1) print(spplot(gadm, unemployment, col.regions=col, col=grey15, main=list(label=Italia - Tassi di disoccupazione 2007), res=88, par.settings=par.set)) print(spplot( gadm, unemployment, col.regions=col, col=grey15, main=list(label=Italia - Figure 2), res=88, par.settings=par.set)) dev.off() __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 get curve information from a gam model
On Sep 11, 2012, at 12:10 PM, exu wrote: Thanks for the response. But I'm relatively new to R, could you elaborate a bit? I tried P -predict.gam(model,type=terms) But I'm having a hard time to trying to make sense of the resulting data. And I'm having even greater difficulty because I cannot see any of it. (My prediction: It gave you linear predictors at your original data points, since you did not give it a newdata argument and you only have one term. I suspect that the chosen smoothing basis might have constructed a matrix output.) The help page ?mgcv::predict.gam has worked examples. In fact the first example illustrated what I thought you would be attempting. Working through all the examples on a help page is a great way to learn a function's capabilities. -- David. Regards, Eugene Xu LIBREMAX CAPITAL, LLC. 830 Third Avenue Suite 801 NewYork, NY 10022 (212) 612-1598 (O) (908) 656-0306 (M) (646) 380-2689 (F) From: David Winsemius [via R] [mailto:ml-node+s789695n4642822...@n4.nabble.com] Sent: Tuesday, September 11, 2012 3:00 PM To: Eugene Xu Subject: Re: How to get curve information from a gam model On Sep 11, 2012, at 8:08 AM, exu wrote: I'm using library(mgcv) I did a gam regression like this model - gam(formula = y ~ s(x), family=binomial) Now I'd like to get 2 vectors x and z (with z=s(x)), so that I can implement the model outside R. How can I do this? ?predict.gam -- David Winsemius, MD Alameda, CA, USA David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] .NAME in .Fortran
Duncan: I experimented by using .NAME = in a call to .Fortran() in one of my packages and got the same error as Peter. I am definitely (!) using R version 2.15.1. Doing args(.Fortran) gives: function (.NAME, ..., NAOK = FALSE, DUP = TRUE, PACKAGE, ENCODING) NULL bytecode: 0x9e7762c If I replace .NAME by name in my call to .Fortran() everything works smoothly. Consequently: It looks to me like there is a bug here. An inconsistency between .Fortran() and .Primitive(.Fortran) perhaps. cheers, Rolf On 12/09/12 00:09, Duncan Murdoch wrote: On 12-09-10 9:21 PM, Peter Dunn wrote: Hi all I've been getting some emails from the R package maintainers that I need to update some code in a CRAN packge that uses FORTRAN, to comply with (not so recent) changes. I've been a little busy... I'm having trouble adjusting my code. I hope someone can help. The package was working fine, and a few R functions in my package had lines like this: tmp - .Fortran( name=pdf, other parameters here) and similar. The pdf is the name of the FORTRAN subroutine being called, of course. When I replace that line with tmp - .Fortran( .NAME=pdf, other parameters here) ...the package then does not pass the checks. The library package builds OK with no errors or warnings, and then during R CMD check the examples give this error: out - tweedie.profile( y~1, p.vec=seq(1.1, 1.9, length=9), do.plot=TRUE) 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 .Error in .Fortran(.NAME = pdfun, as.double(power), as.double(phi[i]/(y[i]^(2 - : supplied argument name '.NAME' does not match 'name' Calls: tweedie.profile - dtweedie.inversion - .Fortran Execution halted I've had a search--including a read of the Writing R Extensions manual on CRAN (I did read it, but interestingly a search of that document did not reveal any instance of .NAME)--and I cannot see the problem. It's probably obvious. Any help appreciated, even pointers to more info. I suspect you are doing your checks with an old version, not with the one listed below. The first argument was called name until R 2.13.0 was released; at that point it was changed to .NAME (to prevent conflicts with something or other). It seems someone forgot to note this in the NEWS file... You can find which version did the checks by looking at the header in the 00check.log file created during the check. You could also follow Rolf's advice and not name the first arg. Duncan Murdoch P. sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base The output from R CMD check: R CMD check tweedie * using log directory '/Users/pdunn2/Documents/SharedFiles/pkd/Research/Rlibraries/tweedie/tweedi e.Rcheck' * using R version 2.15.1 (2012-06-22) * using platform: x86_64-apple-darwin9.8.0 (64-bit) * using session charset: UTF-8 * checking for file 'tweedie/DESCRIPTION' ... OK * this is package 'tweedie' version '2.1.2' * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking whether package 'tweedie' can be installed ... OK * checking installed package size ... OK * checking package directory ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * loading checks for arch 'i386' ** checking whether the package can be loaded ... OK ** checking whether the package can be loaded with stated dependencies ... OK ** checking whether the package can be unloaded cleanly ... OK ** checking whether the namespace can be loaded with stated dependencies ... OK ** checking whether the namespace can be unloaded cleanly ... OK * loading checks for arch 'x86_64' ** checking whether the package can be loaded ... OK ** checking whether the package can be loaded with stated dependencies ... OK ** checking whether the package can be unloaded cleanly ... OK ** checking whether the namespace can be loaded with stated dependencies ... OK ** checking whether the namespace can be unloaded cleanly ... OK * checking for unstated dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... NOTE dtweedie.stable: no visible global function definition for 'dstable' * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd cross-references ... OK * checking for missing
[R] splines package
Hello all, I have been working with b-splines and noted that the splines package is not available in CRAN. Does any body know what happened with it? Or, is there any package that replaces it? Thank you Felipe Parra [[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] using alternative models in glmulti
All, I am working on a multiple-regression meta-analysis and have too many alternative models to fit by hand. I am using the metafor package in R, which generates AIC scores among other metrics. I'm using a simple formula to define these models. For example, rma(Effect_size,variance, mods=~Myco_type + N.type +total, method=ML)-mod where Effect_size is the mean response for each experiment, variance is the SE around the mean, mods are the variables, and the method used to fit the AIC score is maximum likelihood estimation. I thought I might be able to use the function glmulti(mod, level=1) to rank all alternative models using AICc scores. If I fit a glm in in this way (e.g. glm(Effect_size~Myco_type+N.type+total)-mod), the glmulti function works beautifully. Is it possible to extract AIC scores from the rma models as well? Is there another package that might assimilate AIC scores from many alternative models more easily? Thank you for any insight, Meghan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Can I make spss.get reencode from Windows-1252?
If you have control of the SPSS file and you set Unicode on in SPSS, the sav file will be encoded in Unicode - utf-8. With any sav file from SPSS V15 or later, the encoding is written into the file header. If it isn't Unicode, it is determined by the SPSS locale setting. -- View this message in context: http://r.789695.n4.nabble.com/Can-I-make-spss-get-reencode-from-Windows-1252-tp4642563p4642839.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] splines package
It should be included in your binary download of R. Is it not? Michael On Tue, Sep 11, 2012 at 11:18 PM, Luis Felipe Parra felipe.pa...@quantil.com.co wrote: Hello all, I have been working with b-splines and noted that the splines package is not available in CRAN. Does any body know what happened with it? Or, is there any package that replaces it? Thank you Felipe Parra [[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] splines package
You likely need to load the package before you can use it: library(splines) ? bs works for me. Cheers, M On Tue, Sep 11, 2012 at 11:32 PM, Luis Felipe Parra felipe.pa...@quantil.com.co wrote: Hello Michael when I search for documentation it always appears as a separate package, if I try ?bs No documentation for ‘bs’ in specified packages and libraries: you could try ‘??bs’ ??bs I find this function is on the splines package. All this I am doing it on R 2.15.0 for Windows. any idea? On Tue, Sep 11, 2012 at 5:29 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: It should be included in your binary download of R. Is it not? Michael On Tue, Sep 11, 2012 at 11:18 PM, Luis Felipe Parra felipe.pa...@quantil.com.co wrote: Hello all, I have been working with b-splines and noted that the splines package is not available in CRAN. Does any body know what happened with it? Or, is there any package that replaces it? Thank you Felipe Parra [[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. -- Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede contener información confidencial o privilegiada. This e-mail is sent by Quantil S.A.S and may contain confidential or privileged information __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] .NAME in .Fortran
On 12-09-11 4:44 PM, Rolf Turner wrote: Duncan: I experimented by using .NAME = in a call to .Fortran() in one of my packages and got the same error as Peter. I am definitely (!) using R version 2.15.1. Yes, Peter told me the same. Doing args(.Fortran) gives: function (.NAME, ..., NAOK = FALSE, DUP = TRUE, PACKAGE, ENCODING) NULL bytecode: 0x9e7762c If I replace .NAME by name in my call to .Fortran() everything works smoothly. Consequently: It looks to me like there is a bug here. An inconsistency between .Fortran() and .Primitive(.Fortran) perhaps. There was a bug; it was fixed in August (also without a NEWS entry). You shouldn't see it in R-patched, or 2.15.2, when that is released. Duncan Murdoch cheers, Rolf On 12/09/12 00:09, Duncan Murdoch wrote: On 12-09-10 9:21 PM, Peter Dunn wrote: Hi all I've been getting some emails from the R package maintainers that I need to update some code in a CRAN packge that uses FORTRAN, to comply with (not so recent) changes. I've been a little busy... I'm having trouble adjusting my code. I hope someone can help. The package was working fine, and a few R functions in my package had lines like this: tmp - .Fortran( name=pdf, other parameters here) and similar. The pdf is the name of the FORTRAN subroutine being called, of course. When I replace that line with tmp - .Fortran( .NAME=pdf, other parameters here) ...the package then does not pass the checks. The library package builds OK with no errors or warnings, and then during R CMD check the examples give this error: out - tweedie.profile( y~1, p.vec=seq(1.1, 1.9, length=9), do.plot=TRUE) 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 .Error in .Fortran(.NAME = pdfun, as.double(power), as.double(phi[i]/(y[i]^(2 - : supplied argument name '.NAME' does not match 'name' Calls: tweedie.profile - dtweedie.inversion - .Fortran Execution halted I've had a search--including a read of the Writing R Extensions manual on CRAN (I did read it, but interestingly a search of that document did not reveal any instance of .NAME)--and I cannot see the problem. It's probably obvious. Any help appreciated, even pointers to more info. I suspect you are doing your checks with an old version, not with the one listed below. The first argument was called name until R 2.13.0 was released; at that point it was changed to .NAME (to prevent conflicts with something or other). It seems someone forgot to note this in the NEWS file... You can find which version did the checks by looking at the header in the 00check.log file created during the check. You could also follow Rolf's advice and not name the first arg. Duncan Murdoch P. sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base The output from R CMD check: R CMD check tweedie * using log directory '/Users/pdunn2/Documents/SharedFiles/pkd/Research/Rlibraries/tweedie/tweedi e.Rcheck' * using R version 2.15.1 (2012-06-22) * using platform: x86_64-apple-darwin9.8.0 (64-bit) * using session charset: UTF-8 * checking for file 'tweedie/DESCRIPTION' ... OK * this is package 'tweedie' version '2.1.2' * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking whether package 'tweedie' can be installed ... OK * checking installed package size ... OK * checking package directory ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * loading checks for arch 'i386' ** checking whether the package can be loaded ... OK ** checking whether the package can be loaded with stated dependencies ... OK ** checking whether the package can be unloaded cleanly ... OK ** checking whether the namespace can be loaded with stated dependencies ... OK ** checking whether the namespace can be unloaded cleanly ... OK * loading checks for arch 'x86_64' ** checking whether the package can be loaded ... OK ** checking whether the package can be loaded with stated dependencies ... OK ** checking whether the package can be unloaded cleanly ... OK ** checking whether the namespace can be loaded with stated dependencies ... OK ** checking whether the namespace can be unloaded cleanly ... OK * checking for unstated dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for
[R] R equivalent of python module structure and functionality?
summary: how to structure an R file such that it can be both 1. used as a script via, e.g., (from OS commandline) $ Rscript foo.r bar=baz 2. imported and called as a function via, e.g. (from R commandline) source('./foo.r) foo(bar='baz') ? I'm looking for the 'R equivalent' of how python supports this usecase. details: As discussed in the thread beginning https://stat.ethz.ch/pipermail/r-help/2012-September/323255.html I have a script https://github.com/TomRoche/GEIA_to_netCDF/blob/master/netCDF.stats.to.stdout.r that takes named arguments without undue pain. I would also like to be able to call it as a function from other scripts. How to do that in R? In case that's not specific enough :-) I know how to structure files/ modules in python like http://python.net/~goodger/projects/pycon/2007/idiomatic/cmdline.py (i.e., generically, http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#module-structure module docstring # imports # constants # exception classes # interface functions # classes # internal functions classes def main(...): ... if __name__ == '__main__': status = main() sys.exit(status) ) so that the file/module is both 1. callable from the OS commandline via, e.g., $ /path/to/cmdline.py 2. importable without mere import causing execution of the script's functionality, e.g., sys.path.append('/path/to') from cmdline import * process_command_line(...) How to do this in R? TIA, Tom Roche tom_ro...@pobox.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] how can I get a layout like in pairs()?
On 12-09-11 2:40 PM, Lukas Kohl wrote: dear R gurus, I repeatedly run into this problem, maybe there's an easy way to solve it. I want a composite plot with multiple graphs that share the same axis, similar way as done by the pairs() (eg. like this here http://www.r-project.org/screenshots/iris-pairs.jpg). all plot panels shall have the same size, but there need to be extra space at the outside of the whole graphic to label the axis. space between the panels should be minimal. I tried to set par(mar) to low levels, and add additional space with par(oma) for axistick labels, however, the individual plots can't draw into the oma space - is there an alternative way? pairs.default is written in R; you could read the code and do what it does. (It does it by calling the Axis function with xpd=NA. See ?par for what this means.) Duncan Murdoch thanks a lot, lukas This electronic communication is governed by the terms and conditions at http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2012.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 equivalent of python module structure and functionality?
On Tue, Sep 11, 2012 at 6:00 PM, Tom Roche tom_ro...@pobox.com wrote: summary: how to structure an R file such that it can be both 1. used as a script via, e.g., (from OS commandline) $ Rscript foo.r bar=baz 2. imported and called as a function via, e.g. (from R commandline) source('./foo.r) foo(bar='baz') ? I'm looking for the 'R equivalent' of how python supports this usecase. details: As discussed in the thread beginning https://stat.ethz.ch/pipermail/r-help/2012-September/323255.html I have a script https://github.com/TomRoche/GEIA_to_netCDF/blob/master/netCDF.stats.to.stdout.r that takes named arguments without undue pain. I would also like to be able to call it as a function from other scripts. How to do that in R? In case that's not specific enough :-) I know how to structure files/ modules in python like http://python.net/~goodger/projects/pycon/2007/idiomatic/cmdline.py (i.e., generically, http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#module-structure module docstring # imports # constants # exception classes # interface functions # classes # internal functions classes def main(...): ... if __name__ == '__main__': status = main() sys.exit(status) ) so that the file/module is both 1. callable from the OS commandline via, e.g., $ /path/to/cmdline.py 2. importable without mere import causing execution of the script's functionality, e.g., sys.path.append('/path/to') from cmdline import * process_command_line(...) How to do this in R? Maybe take a look at littler. littler provides hash-bang (i.e. script starting with #!/some/path) capability for GNU R, as well as simple command-line and piping use. http://dirk.eddelbuettel.com/code/littler.html James __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 equivalent of python module structure and functionality?
On 11 September 2012 at 18:47, J Toll wrote: | Maybe take a look at littler. | | littler provides hash-bang (i.e. script starting with #!/some/path) | capability for GNU R, as well as simple command-line and piping use. | | http://dirk.eddelbuettel.com/code/littler.html Thanks for the plug. I also wanted to point Tom to CRAN packages getopt optparse written specifically to support command-line argument parsing with R scripts (ie via Rscript and littler). Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.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] Plotting every probability curve
I don't have a logistic regression model and am trying to generate probability curves for all possible combinations of the variables. My logit model has 5+ variables, and I want to draw curves for every scenario. See code below. When home_owner is 0 and 1, I want curves. The same goes for all other variables categories, so that I have permutations for all possible combinations. I've found that I can use the TeachingDemos package (see below) to construct a gui which makes this easier, but I want to form curve separately so that I can save them library(TeachingDemos) TkPredict(mod1) Predict.Plot(mod1, pred.var = our_bid, our_bid = c(0,300), age_of_oldest_driver2 = 18 to 21, credit_type2 = POOR, coverage_type2 = BASIC, home_owner2 = 0, state2 = other, currently_insured2 = 0, vehicle_driver_score = 0, plot.args = list(), type = response) Quick reproduceable example = df = data.frame(sell=c(0,1,0,0,1), home=c(own,rent,rent,rent,own), income=c(50,20,20,50,50), gender=c(M,M,F,F,F)) df$sell = as.factor(df$sell) df$home = as.factor(df$home) df$income = as.factor(df$income) df$gender = as.factor(df$gender) str(df) m1 = glm(factor(sell) ~ home + income + gender, data=df, family=binomial(link=logit)) summary(m1) library(TeachingDemos) TkPredict(m1) Thanks -- *Abraham Mathew Statistical Analyst www.amathew.com 720-648-0108 @abmathewks* [[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] CairoWin on Windows 7 doesn't refresh
I'm trying to use the Cairo package (R 2.15.1) with Windows 7. If the graphics device window is behind another window, when I move the graphics device window to the foreground, the contents of the window are not refreshed, and continue to contain the image of the window that was on top of the graphics window. Anybody else experience this? -- Kevin Wright __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] CairoWin on Windows 7 doesn't refresh
On 12-09-11 9:29 PM, Kevin Wright wrote: I'm trying to use the Cairo package (R 2.15.1) with Windows 7. If the graphics device window is behind another window, when I move the graphics device window to the foreground, the contents of the window are not refreshed, and continue to contain the image of the window that was on top of the graphics window. Anybody else experience this? Yes, I see it too. If you resize the window it redraws, and after that it refreshes when being covered and brought to the front. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.