[R] [Question] about plot.xts
Hi All, I am trying to use xts and xtsExtra packages to plot multiple time series on one plot. I got two questions about this package. What's the meaning of *The following object is masked from ‘package:xts’:* when load xts and xtsExtra?* which plot.xts will be available if I local xts first and then xtsExtra?* How to draw multiple lines horizontal legend using legend.pars? Many thanks. Endeavor --- R version 3.1.2 (2014-10-31) -- Pumpkin Helmet Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. library(xts) Loading required package: zoo Attaching package: ‘zoo’ The following objects are masked from ‘package:base’: as.Date, as.Date.numeric library(xtsExtra) Attaching package: ‘xtsExtra’ *The following object is masked from ‘package:xts’:* plot.xts [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 please metro_hastings function
It looks like you posted in HTML and the result are garbbled. ONly post in plain text. Also it might help to read one or both of these https://github.com/hadley/devtools/wiki/Reproducibility http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example John Kane Kingston ON Canada -Original Message- From: cute_loo...@hotmail.com Sent: Sat, 14 Feb 2015 15:27:58 +0300 To: r-help@r-project.org Subject: [R] help please metro_hastings function Hi :)anybody can help me please I'm trying to use Metro_Hastings ( MHadaptive package)the proplem is: How can I know the covariance matrix( prop_sigma ) to enter it in Metro_Hastings: mcmc_r=Metro_Hastings(li_func=baysianlog, pars=c(1,1,1), prop_sigma =NULL,par_names=c('alpha','gamma','delta'),data=x ) its gave me an error , I must enter the cov matrix but I don't know how to calculate it, somebody told me to wrote the function without prop_sigma but its also gave me an error what can I do?? Thank you,Sara [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 please metro_hastings function
Hi :)anybody can help me please I'm trying to use Metro_Hastings ( MHadaptive package)the proplem is: How can I know the covariance matrix( prop_sigma ) to enter it in Metro_Hastings: mcmc_r=Metro_Hastings(li_func=baysianlog, pars=c(1,1,1), prop_sigma =NULL,par_names=c('alpha','gamma','delta'),data=x ) its gave me an error , I must enter the cov matrix but I don't know how to calculate it, somebody told me to wrote the function without prop_sigma but its also gave me an error what can I do?? Thank you,Sara [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 you validate association rules?
It will help greatly if you can learn to communicate according to the norms of the list. Reading the Posting Guide mentioned at the bottom of this email will help. 1) This mailing list is plain text. If you send HTML email it will get converted and we won't see what you see, which leads to miscommunication. 2) The topic here is R, not statistics, so be careful not to wander too far off into why algorithms work. There are other forums where that kind of discussion makes sense, such as stats.stackexchange.com. Your question in its current form seems to belong there, though it sounds like you could probably get on topic here with a little work. Have you read the CRAN task view on machine learning? [1] 3) A small, reproducible example expressed in R of what you have achieved is highly recommended [2]. A clear specification of what you want to achieve is also needed. (We could probably make progress on this question here if you had the example.) If you reference examples in R help files that you have read then you will clarify how far along you are in understanding the use of R. [1] http://cran.r-project.org/web/views/MachineLearning.html [2] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --- 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. On February 13, 2015 8:46:32 AM PST, ayane celestialxan...@hotmail.com wrote: Hey everyone, I just started learning R and statistics. I made association rules with the apriori algorithm in the arules package. I sorted them and pruned them. But now I want to validate/test them. In supervised learning they use cross validation. In this paper by Patrick O Perry http://arxiv.org/abs/0909.3052 I read it is possible to use cross validation on unsupervised learning methods (such as arules). But since my background in R, statistics and machine learning is weak the paper was quite hard to get through (also I'm not in college, I just finished high school and am preparing to study computer sciencec). So my question is, how do you validate your rules? How can you use cross validation to do so? I have my main data set Orders, it has 2 million records. I used the sample function to make a training data set and a test data set. But what do I do next? Are there other techniques I should know of? If there are any specific tutorials on this subject, I would also love to learn from them. Kind regards, Ayane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 shifting bars to only overlap in groups
John Kane Kingston ON Canada -Original Message- From: hyil...@gmail.com Sent: Sat, 14 Feb 2015 16:32:03 +0800 To: jrkrid...@inbox.com Subject: Re: [R] ggplot2 shifting bars to only overlap in groups I think maybe it is possible to first produce a blank axis, and then splitting the data frame by the value of _direction. _Then add the goem_bar and goem_errorbar for the blank axis for the first split, then add them for the second half split. This is actually a slit-apply-combine strategy. It would be perfect if we could come up with the way to do that using _d_ply()._ == john: It may be but I think it is beyond my knowledge. I almost never would use a barchart and I really don't understand them very well. I'd reccomend taking what you have both in barchart and scatterplot and talking to the real experts in the Google Groups ggplot group. You can get advice from Hadly and the other people who actually wrote the software. == I see where you are at when you are saying geom_point. I have adjusted it a bit so that the _direction_ factor is also labeled out with _linetype_, simply adding _linetype=direction_ in the goem_errorbar function. One problem for this is normally we use bar charts as a standard for this type of statistics, and the comparison is visually more easier using bar charts than the geom_point version. ### john: Ah yes, I totally missed the up-down distinction. I am not so sure that the visual comparison is as informative but yes it is easier. Perhaps the worst problem is that ...normally we use barcharts... Geting around some conventions can be a real *^%. It's like broken axes and two scales on one graph. It is accepted even if probably not at all a good idea. A question about this, though. What determines the vertical axis value for the points? I see they are layered so that they do not overlap although a lot of dots share the same horizontal value: male. Is that handled utterly by a mechanism that is not relevant with the data, but to produce less clattered plot? john Trial and error? Yes it is the jitter() function. It is a very handy function to handle overlapping or very crowded data points It took a little tweaking of the data but it seemed to work. I was thinking of ikoverlap problem on the way home a couple of nights ago and realised that while I could not jitter a factor I could recode it into a new numeric variable and jitter that and use it as the x-axis rather than use Gender directly. So what I did was create a new variable dat1$jit and add some jitter. Then I plotted the data using dat1$jiit rather than dat1$gender and just re-named the Y axis to Gender. I hope that is an answer to what you asked See http://sape.inf.usi.ch/quick-reference/ggplot2/geom_jitter for what seems some basic info. Since this is the first time I have ever had an occasion to use them I am not really all that familiar with all the ins and outs 3 Thanks so much for your hlep! Here is the code I have tweaked based on yours, adding the dashed line for direction: 3 I am happy to have been of a little help and it was an interesting exercise. Good luck with the rest of it and if you get those bars to work please post back here for our other readers to see what was done. Gook luck john dat1 - structure(list(gender = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c(male, female ), class = factor), direction = structure(c(1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), .Label = c(up, down), class = factor), condition = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L), .Label = c(c1, c2, c3, c4), class = factor), location = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(east, west), class = factor), t = c(1.78664348823968, 1.045971213672, 1.45271943418506, 1.52433880441405, 0.894240903766416, 1.04200421306615, 0.992602172725307, 1.35686661120166, 1.15664717132331, 1.78519605814623, 1.3131987417228, 1.23649081362245, 1.33657440193627, 1.39069933103098, 1.16990353110185, 1.50384132346169, 0.240063246756554, 0.151918103772423, 1.26918566082989, 1.44462610872269, 0.944676078996681, 0.945358342820427, 0.68274449456263, 0.983609699924918, 1.06442538569853, 0.917922814494952, 1.06681054493614, 0.899670881737641, 0.639091165646195, 1.81227533189609, 1.02711921654525, 2.05244515236416), ci = c(0.199453475099606, 0.0208699634619525, 0.0267762622040696,
Re: [R] Use of R for Hypothesis Testing
There are anumber of good papers and books in pdf format at the R site. Select a CRAN location and you should see an entry for them on the left side of the page. Pick a couple and see if they help. And for a fun read on introductory statistics in general which should cover everything you wanted to know and more have a look at Danial Navarro's downloadable stats book at http://health.adelaide.edu.au/psychology/ccs/teaching/lsr/ John Kane Kingston ON Canada -Original Message- From: lis...@terpmail.umd.edu Sent: Fri, 13 Feb 2015 12:17:10 -0500 To: r-help@r-project.org Subject: [R] Use of R for Hypothesis Testing Dear Staff Hello, I am recently trying to learn some functions of R. How would I use R to do T-test, confidence interval calculation, chi-square test and ANOVA? -- Thank you Sike Li (Lydia) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] 2d rotation: vegan?
Randall, You might try the factor.rotate function in the psych package. That will allow you to “hand rotate” any solution where (in your example) nmdp is a matrix. You also could look at the the various rotations available in the GPArotation package. Bill On Feb 13, 2015, at 9:08 AM, Randall Morris-Ostrom randall.morrisost...@icloud.com wrote: I've been working at interpreting the results of a non-metric multidimensional scaling analysis. I have been using metaMDS in the vegan package because one of the benefits is that it also rotates to solution to its principal components. (Eventually I realized that there is no reason why my results would be most interpretable when aligned along the PC, but it was a nice starting point.) I have been trying to find ways to rotate the resulting plot so I can visualize it differently and look at actual plot positions (as opposed to just rotating the print outs I have been looking at.) I'm able to find lots of suggestions for how to rotate3d plots, but almost nothing for 2d. I have tried using the MDSrotate function in vegan, but really it comes down to the fact that I'm clueless when I try to make sense of the documentation. *somewhat embarrassed* My goal is basically to rotate the plot and exam the structure as a tool to generate theories about the meaning of the different dimensions (the interpretation of the clusters in my research are crystal clear.) I generated a little fake data, just so there would be a plot. I've been trying to figure out how to do this as either just a simple scatterplot or using the vegan package. Thank you for your time, Randy Randall Morris-Ostrom J.D., M.S. Doctoral Candidate in Psychology, University of St. Thomas randall.morrisost...@icloud.com Sample Code library(vegan) set.seed(12345) x - rnorm(1:10) y - rnorm(1:10) df - data.frame(x,y) d - dist(df, method = euclidean) nmds - metaMDS(df, distance = euclidean, k = 2) plot(nmds) # or nmdp - as.data.frame(nmds$points) plot(nmdp$MDS1, nmdp$MDS2) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. William Revellehttp://personality-project.org/revelle.html Professor http://personality-project.org Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern Universityhttp://www.northwestern.edu/ Use R for psychology http://personality-project.org/r It is 3 minutes to midnighthttp://www.thebulletin.org __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Use of R for Hypothesis Testing
You will only really learn R by reading and trying things yourself. As John says, there are many good books out there. Have you read the introductory material that comes with R in the help system? I would recommend you start the help system and scroll through the list of functions contained in the stats package. You will be amazed at what you find. Kevin On 02/14/2015 12:08 PM, John Kane wrote: There are anumber of good papers and books in pdf format at the R site. Select a CRAN location and you should see an entry for them on the left side of the page. Pick a couple and see if they help. And for a fun read on introductory statistics in general which should cover everything you wanted to know and more have a look at Danial Navarro's downloadable stats book at http://health.adelaide.edu.au/psychology/ccs/teaching/lsr/ John Kane Kingston ON Canada -Original Message- From: lis...@terpmail.umd.edu Sent: Fri, 13 Feb 2015 12:17:10 -0500 To: r-help@r-project.org Subject: [R] Use of R for Hypothesis Testing Dear Staff Hello, I am recently trying to learn some functions of R. How would I use R to do T-test, confidence interval calculation, chi-square test and ANOVA? -- Thank you Sike Li (Lydia) [[alternative HTML version deleted]] -- Kevin E. Thorpe Head of Biostatistics, Applied Health Research Centre (AHRC) Li Ka Shing Knowledge Institute of St. Michael's Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] BondLab Package
Hi All, I am getting closer to finalizing the package. Below is all my information; Description, namespace, and check from R Studio. I know its basically lubridate as well as bond basis function. I re-read the section on environments in Advanced R as I was thinking this is environment related. I am going over the creating packages documentation now. Unfortunately, whatever I am missing is not getting into my coconut. Any ideas are appreciated. Here are my last issues: All declared Imports should be used. Not sure what this is telling me. I have the packages in imports No visible global function defined this seems like it all lubridate related. Here is the pertinent section from check = * checking dependencies in R code ... NOTE Namespaces in Imports field not imported from: ‘ggplot2’ ‘grid’ ‘lubridate’ ‘methods’ ‘optimx’ ‘plyr’ ‘reshape2’ ‘termstrc’ All declared Imports should be used. See the information on DESCRIPTION files in the chapter ‘Creating R packages’ of the ‘Writing R Extensions’ manual. * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... NOTE BondBasisConversion: no visible global function definition for ‘day’ BondBasisConversion: no visible global function definition for ‘month’ BondBasisConversion: no visible global function definition for ‘year’ Mtg.Scenario : ReturnAnalysis: no visible global function definition for ‘%m+%’ PrepaymentAssumption: no visible global function definition for ‘%m+%’ Schedule: no visible global function definition for ‘%m+%’ Here is my description file = Package: BondLab Type: Package Title: A package for the analysis of structured products Version: 0.0.0 Date: 2013-12-08 Author: Glenn Schultz, CFA Maintainer: Glenn Schultz glennmschu...@me.com Description: The package provides a suite of software utilities for the analysis of Mortgage and Asset Backed securities LazyLoad: yes License: GPL(=3.0) Imports: termstrc, reshape2, ggplot2, lubridate, methods, plyr, grid, optimx Suggests: knitr, devtools, testthat VignetteBuilder: knitr Here is my namespace = # Generated by roxygen2 (4.1.0): do not edit by hand export(CPR.To.SMM) export(DollarRoll) export(Effective.Convexity) export(Effective.Duration) export(EstimYTM) export(Mortgage.Monthly.Payment) export(MortgageCashFlow) export(PPC.Ramp) export(PassThroughAnalytics) export(PassThroughOAS) export(Rates) export(Remain.Balance) export(SMM.To.CPR) export(SMMVector.To.CPR) export(Sched.Prin) export(TimeValue) export(YTMtoPrice) export(bondprice) exportClasses(DollarRoll) exportClasses(MBSDetails) exportClasses(MortgageCashFlow) exportClasses(MortgageOAS) exportClasses(MortgageTermStructure) exportClasses(Mtg.Scenario) exportClasses(PrepaymentAssumption) exportClasses(Scenario) == Here is my full check == devtools::check() Updating BondLab documentation Loading BondLab '/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD build \ '/Users/glennschultz/BondLab' --no-resave-data --no-manual * checking for file ‘/Users/glennschultz/BondLab/DESCRIPTION’ ... OK * preparing ‘BondLab’: * checking DESCRIPTION meta-information ... OK * installing the package to build vignettes * creating vignettes ... OK * checking for LF line-endings in source and make files * checking for empty or unneeded directories * building ‘BondLab_0.0.0.tar.gz’ '/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD check \ '/var/folders/tv/sq6gmnvs13j8jrhkt87f_zmcgn/T//RtmpiHfQ8g/BondLab_0.0.0.tar.gz' \ --timings * using log directory ‘/Users/glennschultz/BondLab.Rcheck’ * using R version 3.1.2 (2014-10-31) * using platform: x86_64-apple-darwin13.4.0 (64-bit) * using session charset: UTF-8 * checking for file ‘BondLab/DESCRIPTION’ ... OK * checking extension type ... Package * this is package ‘BondLab’ version ‘0.0.0’ * 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 for hidden files and directories ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘BondLab’ can be installed ... OK * checking installed package size ... OK * checking package directory ... OK * checking ‘build’ directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... NOTE Non-standard files/directories found at top level: ‘BondData’ ‘Groups’ ‘PrepaymentModel’ ‘RAID’ ‘RDME’ ‘REMICData’
[R] Automate multiple meta-analyses
I have scores of data sets ready for meta-analyses. I would like to run them as separate meta-analyses because otherwise I will be mixing apples with oranges. In the code below, I successfully run a single meta-analysis with a moderator. metacor(rho,N,Study,data=Leadership,comb.fixed=F,prediction=T,byvar=Leadership$Moderator) To test my idea, I used the variable Moderator to try to produce separate meta analyses with either by or tapply, to no avail. The closest I got to what I need is the code below. It does produce separate output for each level of Moderator, but it just replicate the results without separating the data. That is, I have k=13, and I just get the same k=13 meta-analysis for each level of Moderator. attach(Leadership) f-metacor(rho,N,Study,comb.fixed=F,prediction=T) by(Leadership,Moderator,function(x) f) Yours, Avi Klugerhttp://pluto.huji.ac.il/~mskluger/kluger.html [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] my code in Metro_Hastings
Hi again :) my code is in the attachment file the problem I think in the : mcmc_r=Metro_Hastings(li_func=baysianlog, pars=c(1,1,1),par_names=c('alpha','gamma','delta'),data=x ) because I did not write the prop_sigma because I don't know how can I calcalute the covariance matrix. somebody told me to compute the cov without itreation then add the reasulting cov matrix to metro hasting using itreation but it also gave me an error Can you check my code and correct it please Thank you, Sara __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Unable to use `eval(parse(text))' in nlme::lme
Yes, this is a very important point. Thank you, Bill. Best, Ravi From: William Dunlap wdun...@tibco.com Sent: Friday, February 13, 2015 4:56 PM To: Ravi Varadhan Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Unable to use `eval(parse(text))' in nlme::lme ff - reformulate(termlabels=c(time,as.factor(gvhd)), response=yname, intercept=TRUE) If the right hand side of the formula were more complicated than an additive list of terms, say '~ time * as.factor(gvhd)' or the left side were more than a name, say 'log(yname)' you could use bquote() instead of reformulate. E.g., formulaTemplate - log(.(responseName)) ~ time * as.factor(gvhd) lapply(c(y1,y2,y3), function(yname)do.call(bquote, list(formulaTemplate, list(responseName=as.namehttp://as.name(yname) [[1]] log(y1) ~ time * as.factor(gvhd) [[2]] log(y2) ~ time * as.factor(gvhd) [[3]] log(y3) ~ time * as.factor(gvhd) I used 'do.call' because bquote does not evaluate its first argument, but we need to evaluate the name 'formulaTemplate'. You could avoid that by putting the template verbatim in the call to bquote, as in lapply(c(y1,y2,y3), function(yname)bquote(log(.(responseName)) ~ time * as.factor(gvhd), list(responseName=as.namehttp://as.name(yname I like the do.call method because I can bury it in a function and forget about it. bquote() retains the environment of the formula template. Bill Dunlap TIBCO Software wdunlap tibco.comhttp://tibco.com On Mon, Feb 9, 2015 at 6:44 AM, Ravi Varadhan ravi.varad...@jhu.edumailto:ravi.varad...@jhu.edu wrote: Thanks to Rolf, Duncan, and Ben. Ben, your suggestion worked (with a minor correction of concatenating the termlabels into a vector). Here is the solution to those interested. ff - reformulate(termlabels=c(time,as.factor(gvhd)), response=yname, intercept=TRUE) dd - subset(labdata2, Transplant_type!=0 time 0) lme(ff, random=~1|Patient, data=dd, correlation=corAR1(), na.action=na.omit) Best, Ravi Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg) Associate Professor Department of Oncology Division of Biostatistics Bionformatics Johns Hopkins University 550 N. Broadway Baltimore, MD 21205 40-502-2619 [[alternative HTML version deleted]] __ R-help@r-project.orgmailto:R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] RMySQL works inside function, but prints Error output when executed outside a function
On my computer, if I execute this R code inside the console of Rgui.exe execInsideFunction = function() { dbc = dbcLocal conn - dbConnect(MySQL(), host = dbc$host, dbname = xxx, user=dbc$user, password=dbc$password) dbSendQuery(conn, delete from yyy) dbDisconnect(conn) } execInsideFunction() It seems to work fine, printing [1] TRUE ~~ However, if I copy the body of that function dbc = dbcLocal conn - dbConnect(MySQL(), host = dbc$host, dbname = goral, user=dbc$user, password=dbc$password) dbSendQuery(conn, delete from archive_batches) dbDisconnect(conn) and paste it the console to execute it, then it prints the Error output Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Error during wrapup: evaluation nested too deeply: infinite recursion / options(expressions=)? What the heck is happening?! ~~ I note that that Error output appears to be bogus: the database action (delete all rows from a table above) is actually carried out. Indeed, the 2nd line (Error during wrapup) indicates that the error only occurred later on. Still, it is disturbing. ~~ Note: I am using Revolution R Open 8.01-Beta 64 bit. Below is the output when I execute sessionInfo(): R version 3.1.2 (2014-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] grDevices datasets tcltk stats tools utils graphics methods base other attached packages: [1] timeDate_3011.99 stringr_0.6.2 RODBC_1.3-10 quantmod_0.4-3 quadprog_1.5-5 gWidgets_0.0-54 debug_1.3.1 goralSpeedUp_1.0 RMySQL_0.9-3 DBI_0.3.1 bitops_1.0-6 caTools_1.17.1 lattice_0.20-29 TTR_0.22-0 xts_0.9-7 zoo_1.7-11 Rcpp_0.11.3 mvbutils_2.7.4.1 [19] Matrix_1.1-4 inline_0.3.13 loaded via a namespace (and not attached): [1] grid_3.1.2 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Genrating Ordinal Responses in R
Thank you very much JS Huang. It helps. Thanks Regards, Arnab Arnab Kumar Maity Graduate Teaching Assistant Division of Statistics Northern Illinois University DeKalb, IL 60115 Email: ma...@math.niu.edu Ph: 779-777-3428 On Fri, Feb 13, 2015 at 5:03 PM, JS Huang [via R] ml-node+s789695n4703244...@n4.nabble.com wrote: Hi, Here assume there are four elements in the ordinal set y and take a random sample of size 10 according to the cumulative distribution given, or probability distribution p below. y - c(levels = c(First, Second, Third, Fourth)) y levels1 levels2 levels3 levels4 First Second Third Fourth (x - c(1/9, 1/4, 3/5, 1)) [1] 0.111 0.250 0.600 1.000 p - c(x[1], x[2]-x[1], x[3]-x[2], x[4]-x[3]) p [1] 0.111 0.139 0.350 0.400 sample(y, 10, replace=TRUE, prob=p) levels2 levels4 levels4 levels3 levels1 levels3 levels4 levels2 levels4 levels3 Second Fourth Fourth Third First Third Fourth Second Fourth Third -- If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Genrating-Ordinal-Responses-in-R-tp4703159p4703244.html To unsubscribe from Genrating Ordinal Responses in R, click here http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4703159code=bWFpdHlAbWF0aC5uaXUuZWR1fDQ3MDMxNTl8MTMwNTA3NDMzMA== . NAML http://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/Genrating-Ordinal-Responses-in-R-tp4703159p4703274.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Nonlinear integer programming (again)
Another user suggested I elaborate on my previous post, giving specifics of the problem I am trying to solve. Here they are: It is a selection problem involving sample weights. Say we have applicants with test scores x. The vector y indicates whether the applicant is a member of Group Y, which is relevant to selection. The vector w contains the sample weights. The vector z is to contain zeroes and ones indicating which applicants are selected. I want to maximize the weighted average test score for the selected applicants, [1/(z'w)]*(z'diag(xw'), under the following constraints: All elements of z are either 0 or 1. Additional constraints are of the form a � z'w � b and z'diag(yw') � c, where a, b, and c are positive constants. The inequality constraints are linear in z, but the quantity to be maximized is not. My question is whether there is an R package that can handle this problem. PREVIOUS POST: I am seeking an optimization routine that can deal with the following problem: Maximize g(x), where x is a vector and g is nonlinear, subject to linear constraints of the form h(x)0 and m(x)=0 and subject to the constraint that all values of x are 0 or 1. I can't find a nonlinear optimization program in R that states that it can accommodate 0-1 constraints. Oddly, Excel's Solver will produce a solution to such problems but (1) I don't trust it and (2) it cannot handle a large number of constraints. Rebecca Zwick (Santa Barbara, California) Statistical Analysis, Data Analysis, and Psychometric Research Educational Testing Service This e-mail and any files transmitted with it may contain privileged or confidential information. It is solely for use by the individual for whom it is intended, even if addressed incorrectly. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited. Thank you for your compliance. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Nonlinear integer programming (again)
On Sat, 14 Feb 2015, Zwick, Rebecca J wrote: My question is whether there is an R package that can handle this problem. Rebecca, I'm not sure, but have you looked at the Simplex method in the boot() package? http://www.astrostatistics.psu.edu/datasets/R/html/boot/html/simplex.html Rich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 you validate association rules?
Hey everyone, I just started learning R and statistics. I made association rules with the apriori algorithm in the arules package. I sorted them and pruned them. But now I want to validate/test them. In supervised learning they use cross validation. In this paper by Patrick O Perry http://arxiv.org/abs/0909.3052 I read it is possible to use cross validation on unsupervised learning methods (such as arules). But since my background in R, statistics and machine learning is weak the paper was quite hard to get through (also I'm not in college, I just finished high school and am preparing to study computer sciencec). So my question is, how do you validate your rules? How can you use cross validation to do so? I have my main data set Orders, it has 2 million records. I used the sample function to make a training data set and a test data set. But what do I do next? Are there other techniques I should know of? If there are any specific tutorials on this subject, I would also love to learn from them. Kind regards, Ayane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error when I attempt to create a list or a data frame
When I try to create a list with three classes of objects: a numeric, boolean, and vector of character data: lst - list(c(1,2),TRUE,c(“a”,“b”,“c”)) I receive this error: Error: unexpected input in lst - list(c(1,2),TRUE,c(“ I receive a similar error when I create a data frame with mixed classes of objects. Thanks ahead of time! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Coverage probability for a Poisson parameter
Hi, In your function cover, lambda1 and lambda2 are used but not in the argument of the function. I suppose that you need to have lambda1 and lambda2 in the argument of the function cover, like function(lambda1, lambda2, n, significance.level). Give it a try. cover - function(lambda, n, significance.level) { s1 - rpois(1,lambda1) s2 - rpois(1,lambda2) theta - lambda2/(lambda1+lambda2) s - s1+s2 z - qnorm(1-0.05/2) k - z^2 pi - s2/s lower - (pi+(k/(2*s))-z*sqrt((pi*(1-pi)+(k/4*s))/s))/(1+k/s) upper - (pi+(k/(2*s))+z*sqrt((pi*(1-pi)+(k/4*s))/s))/(1+k/s) if (theta = lower theta = upper){1} else {0} } -- View this message in context: http://r.789695.n4.nabble.com/Coverage-probability-for-a-Poisson-parameter-tp4702535p4703230.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Sorting Surv objects
Thanks for the quick response. My work-around was suggested as a quick fix for right-censored data, not as a general sort method for censored data. My concern was that sort does not work on right-censored data as described in the xtfrm documentation. Mik Bickis On Feb 13, 2015, at 05:53 AM, Therneau, Terry M., Ph.D. thern...@mayo.edu wrote: Your work around is not as easy looking to me. Survival times come in multiple flavors: left censored, right censored, interval censored, left-truncated and right censored, and multi-state. Can you give me guidance on how each of these should sort? If a sort method is added to the package it needs to deal with all of these. Professor Ripley has pointed out that the default action of sort() for right censored times, which I agree is reasonable. Terry Therneau (author of the survival package) On 02/13/2015 05:00 AM, r-help-requ...@r-project.org wrote: It seems that Surv objects do not sort correctly. This seems to be a bug. Anyone else found this? survival.data [1] 4+ 3 1+ 2 5+ class(survival.data) [1] Surv sort(survival.data) [1] 2 1+ 4+ 3 5+ An easy work-around is to define a function sort.Surv __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] sd, mean with a frequency distribution matrix
Or if you want to perform the calculation without using sd: sqrt((sum(p[,1]^2*p[,2])-(sum(p[,1]*p[,2]))^2/sum(p[,2]))/(sum(p[,2])-1)) -- View this message in context: http://r.789695.n4.nabble.com/sd-mean-with-a-frequency-distribution-matrix-tp4703218p4703231.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Use of R for Hypothesis Testing
Dear Staff Hello, I am recently trying to learn some functions of R. How would I use R to do T-test, confidence interval calculation, chi-square test and ANOVA? -- Thank you Sike Li (Lydia) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Coverage probability for a Poisson parameter
Hi, Given the function cover, it's very likely that you will get 0 for both s1 and s1 with small value of lambda1 and lambda2. In that case the sum s will be 0. With s being 0, you will have issue with the expression in pi - s2/s and root - ((s2/s)*(1-s2/s)+k/(4*s))^(1/2). You need to take care of the case that s is 0 before proceeding calculating pi and root. cover - function(theta, lambda1, lambda2, significance.level) { s1 - rpois(1,lambda1) s2 - rpois(1,lambda2) theta - lambda2/(lambda1+lambda2) s - s1+s2 z - qnorm(1-0.05/2) k - z^2 pi - s2/s root - ((s2/s)*(1-s2/s)+k/(4*s))^(1/2) low - (s2+k/2)/(s+k)-((z*sqrt(s))/(s+k))*root hig - (s2+k/2)/(s+k)+((z*sqrt(s))/(s+k))*root if (theta = low theta = hig){1} else {0} } -- View this message in context: http://r.789695.n4.nabble.com/Coverage-probability-for-a-Poisson-parameter-tp4702535p4703238.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Caleberating weights
Hi, Suppose I have weights di, I want to calibrate thesis weights I used the objective function Obj = Sum( wi/di-1)^2/2 ; where will be the resulting calibrated weights My calibration constraint is Sum(wizi) = Z , Z is pop total(1) I need r-code to minimize 'Obj' subject to the constraint (1) to obtain calibrated weights wi Thanks -- View this message in context: http://r.789695.n4.nabble.com/Caleberating-weights-tp4703226.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] sd, mean with a frequency distribution matrix
Thank you, I'll try as soon as possible! Il 13/Feb/2015 22:28 JS Huang [via R] ml-node+s789695n470323...@n4.nabble.com ha scritto: Or if you want to perform the calculation without using sd: sqrt((sum(p[,1]^2*p[,2])-(sum(p[,1]*p[,2]))^2/sum(p[,2]))/(sum(p[,2])-1)) -- If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/sd-mean-with-a-frequency-distribution-matrix-tp4703218p4703231.html To unsubscribe from sd, mean with a frequency distribution matrix, click here http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4703218code=ZG9yaWFuLmdyZWxsaUBnbWFpbC5jb218NDcwMzIxOHwtOTUyODE5MTM5 . NAML http://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/sd-mean-with-a-frequency-distribution-matrix-tp4703218p4703232.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Genrating Ordinal Responses in R
Hi, Here assume there are four elements in the ordinal set y and take a random sample of size 10 according to the cumulative distribution given, or probability distribution p below. y - c(levels = c(First, Second, Third, Fourth)) y levels1 levels2 levels3 levels4 First Second Third Fourth (x - c(1/9, 1/4, 3/5, 1)) [1] 0.111 0.250 0.600 1.000 p - c(x[1], x[2]-x[1], x[3]-x[2], x[4]-x[3]) p [1] 0.111 0.139 0.350 0.400 sample(y, 10, replace=TRUE, prob=p) levels2 levels4 levels4 levels3 levels1 levels3 levels4 levels2 levels4 levels3 Second Fourth Fourth Third First Third Fourth Second Fourth Third -- View this message in context: http://r.789695.n4.nabble.com/Genrating-Ordinal-Responses-in-R-tp4703159p4703244.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Caleberating weights
Hi, It's not clear what wizi is in the constraint Sum(wizi) = Z. If you can provide some data, it may make the problem easier to understand. -- View this message in context: http://r.789695.n4.nabble.com/Caleberating-weights-tp4703226p4703245.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Coverage probability for a Poisson parameter
Hi, Some suggestion about the arguments of the function defined below. Since theta is calculated with the value of lambda1 and lambda2, there is no need to include theta in the argument. Or, your function can be defined as function(lambda1, lambda2, significance.level) cover - function(theta, lambda1, lambda2, significance.level) { s1 - rpois(1,lambda1) s2 - rpois(1,lambda2) theta - lambda2/(lambda1+lambda2) s - s1+s2 z - qnorm(1-0.05/2) k - z^2 pi - s2/s root - ((s2/s)*(1-s2/s)+k/(4*s))^(1/2) low - (s2+k/2)/(s+k)-((z*sqrt(s))/(s+k))*root hig - (s2+k/2)/(s+k)+((z*sqrt(s))/(s+k))*root if (theta = low theta = hig){1} else {0} } -- View this message in context: http://r.789695.n4.nabble.com/Coverage-probability-for-a-Poisson-parameter-tp4702535p4703248.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] lme: Can not find groupData object in a function could this be a scoping problem?
Hi, Unless you defined SS somewhere before you execute data - data.frame(group=c(rep(Cont,SS),rep(Exp,SS)), pre=pre,post=post), SS is not assigned. Maybe it is TS you intended? doit- function(TS,rho,premean,presd,RxEffect) { . . . # Prepare data frames for regression analyses. data - data.frame(group=c(rep(Cont,SS),rep(Exp,SS)), pre=pre,post=post) -- View this message in context: http://r.789695.n4.nabble.com/lme-Can-not-find-groupData-object-in-a-function-could-this-be-a-scoping-problem-tp4703243p4703247.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Use of R for Hypothesis Testing
On 13.02.2015 18:17, Sike Li wrote: Dear Staff There is no staff, only volunteers who answer messages in their spare time. Hello, I am recently trying to learn some functions of R. How would I use R to do T-test, confidence interval calculation, chi-square test and ANOVA? Please re-read the posting guide and start to read basic documentation. Best, Uwe Ligges __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error when I attempt to create a list or a data frame
On 13.02.2015 18:15, Michael Pomeroy wrote: When I try to create a list with three classes of objects: a numeric, boolean, and vector of character data: lst - list(c(1,2),TRUE,c(“a”,“b”,“c”)) I receive this error: Error: unexpected input in lst - list(c(1,2),TRUE,c(“ Do not use directed quotes. Best, Uwe Ligges I receive a similar error when I create a data frame with mixed classes of objects. Thanks ahead of time! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Use of R for Hypothesis Testing
Hi Sike, Start an R session, issue the command help.start() and check the help pages for t.test, chisq.test and aov in the stats package. Jim On Sat, Feb 14, 2015 at 4:17 AM, Sike Li lis...@terpmail.umd.edu wrote: Dear Staff Hello, I am recently trying to learn some functions of R. How would I use R to do T-test, confidence interval calculation, chi-square test and ANOVA? -- Thank you Sike Li (Lydia) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 shifting bars to only overlap in groups
I think maybe it is possible to first produce a blank axis, and then splitting the data frame by the value of *direction. *Then add the goem_bar and goem_errorbar for the blank axis for the first split, then add them for the second half split. This is actually a slit-apply-combine strategy. It would be perfect if we could come up with the way to do that using *d_ply().* I see where you are at when you are saying geom_point. I have adjusted it a bit so that the *direction* factor is also labeled out with *linetype*, simply adding *linetype=direction* in the goem_errorbar function. One problem for this is normally we use bar charts as a standard for this type of statistics, and the comparison is visually more easier using bar charts than the geom_point version. A question about this, though. What determines the vertical axis value for the points? I see they are layered so that they do not overlap although a lot of dots share the same horizontal value: male. Is that handled utterly by a mechanism that is not relevant with the data, but to produce less clattered plot? Thanks so much for your hlep! Here is the code I have tweaked based on yours, adding the dashed line for direction: dat1 - structure(list(gender = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c(male, female ), class = factor), direction = structure(c(1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), .Label = c(up, down), class = factor), condition = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L), .Label = c(c1, c2, c3, c4), class = factor), location = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(east, west), class = factor), t = c(1.78664348823968, 1.045971213672, 1.45271943418506, 1.52433880441405, 0.894240903766416, 1.04200421306615, 0.992602172725307, 1.35686661120166, 1.15664717132331, 1.78519605814623, 1.3131987417228, 1.23649081362245, 1.33657440193627, 1.39069933103098, 1.16990353110185, 1.50384132346169, 0.240063246756554, 0.151918103772423, 1.26918566082989, 1.44462610872269, 0.944676078996681, 0.945358342820427, 0.68274449456263, 0.983609699924918, 1.06442538569853, 0.917922814494952, 1.06681054493614, 0.899670881737641, 0.639091165646195, 1.81227533189609, 1.02711921654525, 2.05244515236416), ci = c(0.199453475099606, 0.0208699634619525, 0.0267762622040696, 0.0719683008799792, 0.0388022593655329, 0.0873965412159785, 0.0828671112758008, 0.556676454332325, 0.109726976194332, 0.237352334670391, 0.202173510668684, 0.104263016807603, 0.0174283081233597, 0.027601059580507, 0.118300511535772, 0.272210060810133, 0.210343075045509, 0.010793003362928, 0.241665829872765, 0.387877941848338, 0.230361471258575, 0.233088662079594, 0.0956745517473407, 0.187969512005399, 0.0041769632082831, 0.26242665290992, 0.297793257986101, 0.14520541873456, 0.123447338902161, 0.10109002280374, 0.332925731545975, 0.434868806611465)), .Names = c(gender, direction, condition, location, t, ci), row.names = c(NA, -32L), class = data.frame) dat1$jit - ifelse( dat1$gender == male, 1, ifelse( dat1$gender == 'female', 2, NA) ) dat1$jit - as.numeric(dat1$jit) dat1$jit - jitter(dat1$jit) x - male y - femaleBegin code ## ab - ggplot(dat1, aes (jit, t)) + geom_point(aes(colour = condition)) + theme(axis.ticks = element_blank()) + scale_x_continuous(breaks=c(1, 2), labels=c(male, female), name=Gender) ab bb - ab + facet_grid(location~.) bb bc - bb + geom_errorbar(data = dat1, aes(ymin=t-ci, ymax=t+ci, colour = condition, linetype = direction), width=.2 ) bc cf - bc + coord_flip() cf End code ### 祝好, He who is worthy to receive his days and nights is worthy to receive* all else* from you (and me). The Prophet, Gibran Kahlil On Sat, Feb 14, 2015 at 1:41 AM, John Kane jrkrid...@inbox.com wrote: Both files came through. The R-help list is picky. For example it will accept cat.txt but not cat.csv. Now I see what you are after. and I must admit I haven't a clue at the moment. I suspect others who know more about ggplot can help. If not there is ggplot2 Google Groups that has a lot of knowledge and you might want to post there. It accepts all kinds of file types. :) On the other hand, I don't like dynamite plots (what you have) and wondered if it was possible to do something with geom_point() instead. It was, in a bit of a half-assed way so I'll pass on my raw code. It's ulgy but works. I
Re: [R] [Question] about plot.xts
It means that xtsExtra has a different version if plot.xts, and that will be the one that gets run when you call that function. If you want to use the one that is defined in xts, you can specify it... xts::plot.xts(...) In the future, don't post in HTML, since this is a plain text only list. We don't see the formatting that you see, so don't delude yourself into thinking that we do. --- 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. On February 14, 2015 9:37:59 PM PST, KWCG HE kwcg2...@gmail.com wrote: Hi All, I am trying to use xts and xtsExtra packages to plot multiple time series on one plot. I got two questions about this package. What's the meaning of *The following object is masked from ‘package:xts’:* when load xts and xtsExtra?* which plot.xts will be available if I local xts first and then xtsExtra?* How to draw multiple lines horizontal legend using legend.pars? Many thanks. Endeavor --- R version 3.1.2 (2014-10-31) -- Pumpkin Helmet Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. library(xts) Loading required package: zoo Attaching package: ‘zoo’ The following objects are masked from ‘package:base’: as.Date, as.Date.numeric library(xtsExtra) Attaching package: ‘xtsExtra’ *The following object is masked from ‘package:xts’:* plot.xts [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.