[R] Plotting a curve for a Holling Type III Functional Response
Hey, So I have a scatter plot and I am trying to plot a curve to fit the data based on a Holling Type III functional response. My function is this: nll2<-function(a,b) { conefun<-(a*DBH^2)/(b^2+DBH^2) nlls2<-dnbinom(x=cones ,size=DBH, mu=conefun,log=TRUE) -sum(nlls) } and my plot is this: plot (DBH,cones) DBH is on the x-axis and cones is on the y-axis. How do I get the curve for my function onto the scatterplot? -- View this message in context: http://r.789695.n4.nabble.com/Plotting-a-curve-for-a-Holling-Type-III-Functional-Response-tp4663556.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] File system issue since upgrading macOS to High Sierra
Hi, Since upgrading macOS High Sierra, R will stop responding, requiring me to force R to quit, when I am trying to open a script using File -> Open Document. I don't have any problems opening files by double-clicking them in Finder. Sometimes R gives me the message in the attached screenshot: Any suggestions? -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] Storing tableGrobs in a list
Hi, I'm trying to generate tableGrobs in a loop, store them in a list so I can use it in a call to gtable_combine(). L1<-list() for (i in seq( ... )) { L1[i] <-tableGrob( ... ) } gtable_combine(L1, along=1) On the assignment inside the loop, I get "number of items to replace is not a multiple of replacement length" which I'm guessing has to do with the tableGrob object not "fitting" in the list but am not sure how to fix it. Thanks in advance for any pointers. [[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] Storing tableGrobs in a list
Thanks for the replies. Wasn't aware that Gmail on Android sent HTML by default, apologies. Storing the tableGrob-s in a list worked but for some reason grid.arrange complains on output from gtable_combine() using lists vs individual tableGrob-s. # works when supplying individual tableGrobs p1<-gtable_combine(p11,p22, along=2) p2<-gtable_combine(p11,p22, along=2) grid.arrange(p1,p2,ncol=2) # breaks when supplying a list of tableGrobs, error from grid.arrange() p1<-gtable_combine(L1,along=2) p2<-gtable_combine(L2,along=2) grid.arrange(p1,p2,ncol=2) Error in gList(list(list(grobs = list(list(label = "status", x = 0.5, : only 'grobs' allowed in "gList" Also tried, still no go p1<-do.call(gtable_combine, list(L1,along=2)) p2<-do.call(gtable_combine, list(L2,along=2)) On Jun 13, 2018, 11:01 PM, at 11:01 PM, Jeff Newmiller wrote: >?`[[` > >and read the discussions of indexing in the Introduction to R document >that comes with R. Also, find a way to predict the number of elements >you will need as making this a habit will pay off big time when you >work with large amounts of data: > >L1<-vector( "list", N ) >for (i in seq.int( N )) { > L1[[i]] <-tableGrob( ... ) >} > >PS Post using your email program "plain text" mode... HTML gets >stripped anyway and that often leads to partial corruption of your >message. Read the Posting Guide. > >On June 13, 2018 4:43:21 PM HST, Stats Student > wrote: >>Hi, I'm trying to generate tableGrobs in a loop, store them in a list >>so I >>can use it in a call to gtable_combine(). >> >>L1<-list() >>for (i in seq( ... )) { >> L1[i] <-tableGrob( ... ) >>} >> >>gtable_combine(L1, along=1) >> >>On the assignment inside the loop, I get "number of items to replace >is >>not >>a multiple of replacement length" which I'm guessing has to do with >the >>tableGrob object not "fitting" in the list but am not sure how to fix >>it. >> >>Thanks in advance for any pointers. >> >> [[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. > >-- >Sent from my phone. Please excuse my brevity. __ 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] Storing tableGrobs in a list
Thanks. The trick was in the do.call() syntax - p1<-do.call(gtable_combine, c(L1, list(along=2))) On Jun 14, 2018, 6:30 PM, at 6:30 PM, Jeff Newmiller wrote: >I don't know gtable_combine well enough to answer based on hand waving. >A reproducible example is more likely to tempt someone to dig a little. > >On June 14, 2018 8:07:19 AM HST, Stats Student > wrote: >>Thanks for the replies. Wasn't aware that Gmail on Android sent HTML >by >>default, apologies. >> >>Storing the tableGrob-s in a list worked but for some reason >>grid.arrange complains on output from gtable_combine() using lists vs >>individual tableGrob-s. >> >># works when supplying individual tableGrobs >> >>p1<-gtable_combine(p11,p22, along=2) >>p2<-gtable_combine(p11,p22, along=2) >>grid.arrange(p1,p2,ncol=2) >> >># breaks when supplying a list of tableGrobs, error from >grid.arrange() >> >>p1<-gtable_combine(L1,along=2) >>p2<-gtable_combine(L2,along=2) >> >>grid.arrange(p1,p2,ncol=2) >> >>Error in gList(list(list(grobs = list(list(label = "status", x = 0.5, >>: >> only 'grobs' allowed in "gList" >> >>Also tried, still no go >> >>p1<-do.call(gtable_combine, list(L1,along=2)) >>p2<-do.call(gtable_combine, list(L2,along=2)) >> >> >> >> >>On Jun 13, 2018, 11:01 PM, at 11:01 PM, Jeff Newmiller >> wrote: >>>?`[[` >>> >>>and read the discussions of indexing in the Introduction to R >document >>>that comes with R. Also, find a way to predict the number of elements >>>you will need as making this a habit will pay off big time when you >>>work with large amounts of data: >>> >>>L1<-vector( "list", N ) >>>for (i in seq.int( N )) { >>> L1[[i]] <-tableGrob( ... ) >>>} >>> >>>PS Post using your email program "plain text" mode... HTML gets >>>stripped anyway and that often leads to partial corruption of your >>>message. Read the Posting Guide. >>> >>>On June 13, 2018 4:43:21 PM HST, Stats Student >>> wrote: >>>>Hi, I'm trying to generate tableGrobs in a loop, store them in a >list >>>>so I >>>>can use it in a call to gtable_combine(). >>>> >>>>L1<-list() >>>>for (i in seq( ... )) { >>>> L1[i] <-tableGrob( ... ) >>>>} >>>> >>>>gtable_combine(L1, along=1) >>>> >>>>On the assignment inside the loop, I get "number of items to replace >>>is >>>>not >>>>a multiple of replacement length" which I'm guessing has to do with >>>the >>>>tableGrob object not "fitting" in the list but am not sure how to >fix >>>>it. >>>> >>>>Thanks in advance for any pointers. >>>> >>>>[[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. >>> >>>-- >>>Sent from my phone. Please excuse my brevity. > >-- >Sent from my phone. Please excuse my brevity. __ 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] Adding lines to the page
Hi, I'm looking for a way to add lines to a report. To be clear, I don't want to add lines to any specific plot, but instead to add line(s) to the page itself - e.g. add a line to the footer area, above the actual footer text. Any thoughts on how to do this? Many thanks. __ 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] Adding lines to the page
Thanks, Jeff. The Task View page was very informative. To answer your question, I'm using ggplot to generate my plots and grid/gridExtra/gtable to place those plots on a page. Considering that there are ways to add text on a page through textGrobs, independent of the plots, I was wondering if there was a similar functionality for adding lines. Also noticed a package called pagenum for adding page numbers. knitr is certainly interesting, but might be an overkill for what I am trying to do (creating basic multipage reports with basic headers, footers). On Jun 27, 2018, 2:07 PM, at 2:07 PM, Jeff Newmiller wrote: >That would depend how you are generating the page... plots alone don't >really have such options. If you don't know what this means then I >suggest you read the Reproducible Research Task View [1]. knitr in >conjunction with LaTeX (Rnw files) is very powerful, but there are many >other tools as well (e.g. bookdown) depending on your preferences. > >[1] https://cran.r-project.org/web/views/ReproducibleResearch.html > >On June 27, 2018 1:53:58 PM PDT, Stats Student > wrote: >>Hi, I'm looking for a way to add lines to a report. To be clear, I >>don't want to add lines to any specific plot, but instead to add >>line(s) to the page itself - e.g. add a line to the footer area, above >>the actual footer text. >> >>Any thoughts on how to do this? Many thanks. >> >>__ >>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. > >-- >Sent from my phone. Please excuse my brevity. __ 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] Adding lines to the page
Didn't know about linesGrob(). Thanks On Wed, Jun 27, 2018, 4:38 PM Bert Gunter wrote: > "Considering that there are ways to add text on a page through textGrobs.." > > ... and the linesGrob() function would do the same for lines, no? > > Cheers, > Bert > > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > On Wed, Jun 27, 2018 at 3:56 PM, Stats Student < > stats.student4...@gmail.com> wrote: > >> Thanks, Jeff. The Task View page was very informative. >> >> To answer your question, I'm using ggplot to generate my plots and >> grid/gridExtra/gtable to place those plots on a page. >> >> Considering that there are ways to add text on a page through textGrobs, >> independent of the plots, I was wondering if there was a similar >> functionality for adding lines. Also noticed a package called pagenum for >> adding page numbers. >> >> knitr is certainly interesting, but might be an overkill for what I am >> trying to do (creating basic multipage reports with basic headers, >> footers). >> >> >> >> >> On Jun 27, 2018, 2:07 PM, at 2:07 PM, Jeff Newmiller < >> jdnew...@dcn.davis.ca.us> wrote: >> >That would depend how you are generating the page... plots alone don't >> >really have such options. If you don't know what this means then I >> >suggest you read the Reproducible Research Task View [1]. knitr in >> >conjunction with LaTeX (Rnw files) is very powerful, but there are many >> >other tools as well (e.g. bookdown) depending on your preferences. >> > >> >[1] https://cran.r-project.org/web/views/ReproducibleResearch.html >> > >> >On June 27, 2018 1:53:58 PM PDT, Stats Student >> > wrote: >> >>Hi, I'm looking for a way to add lines to a report. To be clear, I >> >>don't want to add lines to any specific plot, but instead to add >> >>line(s) to the page itself - e.g. add a line to the footer area, above >> >>the actual footer text. >> >> >> >>Any thoughts on how to do this? Many thanks. >> >> >> >>__ >> >>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. >> > >> >-- >> >Sent from my phone. Please excuse my brevity. >> >> __ >> 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] scale_y_continuous with sec.axis
Hi, I'm using scale_y_continuous with sec.axis and it's doing what I need but I don't understand how it picks which of the two series becomes the secondary. Does anyone have any insight into this? Thanks! __ 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] Question about correlation
Greeting. Dear Mr/Mrs/Miss, OTU ID Health Disease Bacterial 1 0.29 0.34 Bacterial 2 0.25 0.07 Bacterial 3 0.06 0.06 Bacterial 4 0.07 0.09 Bacterial 5 0.02 0.05 Above show the first 6 data sets, may I ask that the reason of R show the error like "Error in cor(data) : 'x' must be numeric" ? And how to solve it? Besides, isn't this data can conduct correlation matrix? Moreover, isn't this data sets can be plot into network? If can, which package should I use? Thank you. Best regards, Kang Chin Yi [[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] Conduct Network Analysis
Greeting. Dear Mr/Mrs/Miss, I want to create a network by using R but I only have a table that contain OTU ID and the abundance value of two samples ONLY. Isn't possible? If can, which package can be used? Greatly appreciated to any suggestions and helps. Thank you. Best regards, Kang Chin Yi [[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] Changing PDF orientation midstream
Hi, I'm wondering whether it is possible to change the orientation of the PDF in the middle of the document. In other words, pages 1,2,3 - portrait, pages 4,5 - landscape, etc. This is how I call it - pdf (file, paper="US") or USr for landscape Thanks! __ 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] Ordering of facet_wrap() panels
Hi, I am generating multiple charts with facet_wrap() and what what I see, R/ggplot sorts the panels by the facet variable. So adding an index to the facet variable (1 - bucket, 2 - bucket, etc) does solve the sorting issue but it's ugly. I also read this post which, if I understand correctly, claims that ggplot should be using the initial ordering of the data for ordering the charts (instead of ordering the data itself). https://mvuorre.github.io/post/2016/order-ggplot-panel-plots/ Wondering if anyone knows how to direct ggplot use the initial sorting of the data to order the panels. Thank you. __ 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] Ordering of facet_wrap() panels
Understood. Will review the docs again. My data is from an external source which, among other things, ensures that it's sorted correctly. I was asking for a way to have ggplot use the ordering in place, instead of re-ordering everything. Apologies if it wasn't clear from the original post. Anyway, if the data is correctly presorted, unique should work ok, I think. On Aug 15, 2018, 9:23 AM, at 9:23 AM, Bert Gunter wrote: >1. Unless there is good reason to keep a reply private, always cc the >list. >This allows more brains, possible corrections, etc. > >2. Have you read ?factor and ?unique ? Always study the docs carefully. >They are generally terse but complete, especially the base docs, and >you >can often find your answers there. > >3. Your "solution" may work in this case, but if I understand correctly >what you're after, won't in general. unique() gives the unique values >in >the order they appear, which may not be the order you want: > >## want ordering to be "a" < "b" < "c" > >> f <- rep(letters[3:1],2) > >> factor(f, levels = unique(f)) >[1] c b a c b a >Levels: c b a ## not your desired order > >Again, please consult the docs and perhaps a tutorial or two as >necessary. > >-- Bert > > > >On Wed, Aug 15, 2018 at 8:22 AM, Stats Student > >wrote: > >> Many thanks, Bert. >> >> I did - >> >> facet_wrap(~factor(var, levels=unique (var)) >> >> And it seems to be working fine. >> Do you see any issues with this? >> >> I'm fairly new to R so want to make sure I'm not doing something >stupid. >> >> Thanks again. >> >> On Wed, Aug 15, 2018, 7:50 AM Bert Gunter >wrote: >> >>> See ?factor. >>> >>> You can either use ?ordered to create an ordered factor to sort the >>> levels as you desire or sort them with factor(). e.g. >>> >>> > f <- factor(letters[3:1]) >>> > f >>> [1] c b a >>> Levels: a b c ## default ordering >>> >>> > f <- factor(f, levels = letters[3:1]) >>> > f >>> [1] c b a >>> Levels: c b a ## explicit ordering >>> >>> Cheers, >>> Bert >>> >>> >>> >>> Bert Gunter >>> >>> "The trouble with having an open mind is that people keep coming >along >>> and sticking things into it." >>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) >>> >>> On Wed, Aug 15, 2018 at 7:21 AM, Stats Student < >>> stats.student4...@gmail.com> wrote: >>> >>>> Hi, I am generating multiple charts with facet_wrap() and what what >I >>>> see, R/ggplot sorts the panels by the facet variable. So adding an >index to >>>> the facet variable (1 - bucket, 2 - bucket, etc) does solve the >sorting >>>> issue but it's ugly. >>>> >>>> I also read this post which, if I understand correctly, claims that >>>> ggplot should be using the initial ordering of the data for >ordering the >>>> charts (instead of ordering the data itself). >>>> >>>> https://mvuorre.github.io/post/2016/order-ggplot-panel-plots/ >>>> >>>> Wondering if anyone knows how to direct ggplot use the initial >sorting >>>> of the data to order the panels. >>>> >>>> Thank you. >>>> >>>> __ >>>> 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.
[R] Survival questions
Hi - I am using the survfit() function to produce Kaplan-Meier survival curves for several different groups. survfit (Surv() ~ cohort, data=d) Everything works fine, but I'd like to do something different. I have a 12 month survival curve (base) and I also have two survival curves based on some experiment that only go out to 3 months. What I would like to do is take the 3 month realized curves and apply the 3+ month hazard from the base curve to those. 1) is this a reasonable approach? (short of building a full-fledged model) 2) is there a standard way of doing this? I was going to read the survival curves, calc the hazard (S(t) / S(t-1)), apply it to the realized (short) curves. Related to that, from the survfit() object, how do I read various curves specific to a particular cohort? Everything appears to be concatenated together but I am guessing there is some way to separate based on particular strata. Thanks in advance. __ 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] Addressing results of modFit() of the FME package
Hello, I don´t manage to address the results I get from modFit(). Would be really nice if you could help me to do so. This is my loop: for (i in 1:10) { CO2 <- CO2.list[[i]] #Beobachtungen Obs <- data.frame("x=t"=numeric(),"y=Respi"=numeric()) Obs <- cbind(CO2[,1],CO2[,3]) colnames(Obs) <- c("x","y") Corg.mg <- CO2$Corg.mg Model<-function(p,x) return(data.frame(x=x, y=(p[1]*p[2]*exp((-p[2])*x))+((Corg.mg-p[1])*p[3]*exp((-p[3]*x) Residuals<-function(p)(Obs[,2]-Model(p, Obs[,1])$y) print(system.time(P <- modFit(f=Residuals, p=c(300, 0.1, 0.002), lower=c(0,0,0), upper=c(500, 5, 1 sP<-summary(P) sP } #sP, gives me the following output. I can address the estimates with P$par but I cannot address Std. Error and Pr(>t). That´s what I would like to do! Parameters: Estimate Std. Error t value Pr(>|t|) [1,] 4.005e+00 2.510e+00 1.595 0.131469 [2,] 1.603e-01 9.442e-02 1.698 0.110100 [3,] 3.647e-04 8.581e-05 4.251 0.000698 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.2427 on 15 degrees of freedom Parameter correlation: [,1] [,2] [,3] [1,] 1. -0.9164 -0.7697 [2,] -0.9164 1. 0.5599 [3,] -0.7697 0.5599 1. Thanks in advance!! -- View this message in context: http://r.789695.n4.nabble.com/Addressing-results-of-modFit-of-the-FME-package-tp4657140.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] help me with holt-winter model
Please help me with this i need to submit my thesis . Thanks In advance -- View this message in context: http://r.789695.n4.nabble.com/help-me-with-holt-winter-model-tp2295552p2298464.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] Please advise acf and pacf in order to determine order of Arima
I have data as below.Please let me know how the ACF and Pacf used to determine the order od arima model. Is there any rules need to be followed to determine order.Please advise > turkey.price.ts Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2001 1.58 1.75 1.63 1.45 1.56 2.07 1.81 1.74 1.54 1.45 0.57 1.15 2002 1.50 1.66 1.34 1.67 1.81 1.60 1.70 1.87 1.47 1.59 0.74 0.82 2003 1.43 1.77 1.47 1.38 1.66 1.66 1.61 1.74 1.62 1.39 0.70 1.07 2004 1.48 1.48 1.50 1.27 1.56 1.61 1.55 1.69 1.49 1.32 0.53 1.03 2005 1.62 1.63 1.40 1.73 1.73 1.80 1.92 1.77 1.71 1.53 0.67 1.09 2006 1.71 1.90 1.68 1.46 1.86 1.85 1.88 1.86 1.62 1.45 0.67 1.18 2007 1.68 1.74 1.70 1.49 1.81 1.96 1.97 1.91 1.89 1.65 0.70 1.17 2008 1.76 1.78 1.53 1.90 > > acf(turkey.price.ts,plot=FALSE) Autocorrelations of series ‘turkey.price.ts’, by lag 0. 0.0833 0.1667 0.2500 0. 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333 1.000 0.465 -0.019 -0.165 -0.145 -0.219 -0.215 -0.122 -0.136 -0.200 -0.016 0.9167 1. 1.0833 1.1667 1.2500 1. 1.4167 1.5000 1.5833 0.368 0.723 0.403 -0.013 -0.187 -0.141 -0.180 -0.226 -0.130 > pacf(turkey.price.ts,plot=FALSE) Partial autocorrelations of series ‘turkey.price.ts’, by lag 0.0833 0.1667 0.2500 0. 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333 0.9167 0.465 -0.300 -0.020 -0.060 -0.218 -0.054 -0.061 -0.211 -0.180 0.098 0.299 1. 1.0833 1.1667 1.2500 1. 1.4167 1.5000 1.5833 0.571 -0.122 -0.077 -0.075 0.119 0.064 -0.149 -0.061 > Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/Please-advise-acf-and-pacf-in-order-to-determine-order-of-Arima-tp2298474p2298474.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] Odp: Help me with prediction in linear model
Thanks Murphy and pikal, I need another help,for fitting first fourier transformation ,i used following thing .Please advise on this beer_monthl has 400+ records EXample: > head(beer_monthly) beer 1 93.2 2 96.0 3 95.2 4 77.1 5 70.9 6 64.8 time<-seq(1956,1995.2,length=length(beer_monthly)) sin.t<-sin(2*pi*time) cos.t<-cos(2*pi*time) beer_fit_fourier=lm(beer_monthly[,1]~poly(time,2)+sin.t+cos.t) #this is not working beer_fit_fourier=lm(beer_monthly[,1]~time+time2+sin.t+cos.t) #it is working #prediction is not workinng tpred_four <- data.frame(time = seq(1995, 1998, length = 20)) predict(beer_fit_fourier, newdata = tpred_four) Is there any way to fit first fourier frequency , Please assist. Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/Help-me-with-prediction-in-linear-model-tp2297313p2300991.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] density plot with frequency units
I would like to create a kernal density plot, but rather than show density units on the vertical axis I would like frequencies. I know histograms do this but I don't want the bars, just the density curve. Thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] density plot with frequency units
Let me ask another way. Is there a way to create a histogram with a fitted line, but without bars? Or, perhaps draw the bars with invisible lines? Thanks. On Tue, Aug 16, 2011 at 7:29 AM, Jeff Newmiller wrote: > This is a nonsensical request. It is like saying you want to plot the speed > of a falling object but you want the units of speed to be meters. > --- > Jeff Newmiller The . . Go Live... > DCN: Basics: ##.#. ##.#. Live Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/Batteries O.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > r student wrote: >> >> I would like to create a kernal density plot, but rather than show >> density units on the vertical axis I would like frequencies. >> >> I know histograms do this but I don't want the bars, just the density >> curve. >> >> >> Thanks! >> >> >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] t-test on a data-frame.
Dear R-helpers, In a data frame I have 100 securities,monthly closing value,from 1995 to present,which I have to 1. Sampling with replacement,make 50 samples of 10 securities each,each sample hence will be a data frame with 10 columns. 2. With uniform probabilty,mark a month from 2000 onwards as a "special" month,t=0. 3. I have to subtract the market index from each column of each sample and then compute the residues. 4. For each data frame of residues I have to compute the statistic ( Eps i0 - mean(Eps it ) ) / var( Eps it ). Here i and t vary over one particular data frame. i0 corresponds to ith security residue on the special month. Basically a t-test involving a frame instead of a vector. 5. Print out a table where the statistic is significant at the 1,5,10% level. Could someone give the broad ideas on doing this ? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help with algorithm
I'm wondering if anyone can give some basic advice about how to approach a specific task in R. I'm new to R but have used SAS for many years, and while I can muscle through a lot of the code details, I'm unsure of a few things. Specific questions: If I have to perform a set of actions on a group of files, should I use a loop (I feel like I've heard people say to avoid looping in R)? How to get means for "by" groups and subset a files based on those (subset highest and lowest groups)? (I can do this in multiple steps* but wonder what the best, "R way" is to do this.) How to draw cutoff lines at specific points on density plots? How to create a matrix of plots? (Take 4 separate plots and put them into a single graphic.) * Get group means, add means back to file, sort by mean, take first and last groups Feel free to excoriate me if I'm asking for too much help. If possible though, a few words of advice (loops are the best way, just use the "main" parameter to combine plots) would be lovely if you can provide. Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with algorithm
Thanks for everyone's suggestions. I think looping is the way to go. I have 50 files on which I need to apply the same procedures, so I'll try and wrap my final code in some sort of loop. > > highest and lowest groups)? (I can do this in multiple steps* but wonder > > what the best, "R way" is to do this.) > > Here is one way to get the means by groups: > > tmp <- with(mtcars, tapply(mpg, cyl, mean)) > ## and now subset by it > subset(mtcars, mtcars$cyl %in% names(c(which.max(tmp), which.min(tmp Looks exactly like what I'd need but, I tried and got a list of variable names followed by "<0 rows> (or 0-length row.names)". If I can get this to work, would I be able to use it for weighted means with "rm.na=TRUE"? Since they're weighted means I've been trying to use the following: f<-by(oh,oh$BYGRP, function(z) weighted.mean(z$VAR1,z$WEIGHT,na.rm=TRUE)) Which seems to work, but need to use these means to subset the highest and lowest groups (to create density plots of). The above produces an object that I'm not entirely sure how to work with (say to merge back onto "oh" so I can subset. > How to draw cutoff lines at specific points on density plots? > plot(density(rnorm(100))) > abline(v = c(-1, 1)) Thanks! Amazing how much easier to do this in R than in SAS. > > How to create a matrix of plots? (Take 4 separate plots and put them into a > > single graphic.) > > This depends a bit on the potential complexity of layouts you need. > See ?par and ?layout Thanks again! Many good suggestions here and from others. > > * Get group means, add means back to file, sort by mean, take first and last > > groups > > dat <- mtcars > dat$gm <- with(mtcars, ave(mpg, cyl, FUN = mean)) I tried, but I think the NAs are giving me trouble. tmp <- oh tmp$GM <- with(oh, ave(FINCP, PUMA, FUN=mean)) summary(tmp$GM) Min. 1st Qu. MedianMean 3rd Qu.Max.NA's 114222 And I need to create weighted means anyway. > Hope this helps, > > Josh > -- > Joshua Wiley > Ph.D. Student, Health Psychology > Programmer Analyst II, ATS Statistical Consulting Group > University of California, Los Angeles > https://joshuawiley.com/ Very helpful. Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] density plot for weighted data
I'm trying to create a density plot using census data, where the weights don't sum to 1. >plot(density(oh$FINCP,weights=oh$PWGTP)) Warning message: In density.default(oh$FINCP, weights = oh$PWGTP) : sum(weights) != 1 -- will not get true density How would I go about doing this? Thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] density plot for weighted data
Like below? plot(density(oh$FINCP,weights=oh$PWGTP/sum(oh$PWGTP))) On Tue, Aug 2, 2011 at 10:06 AM, David Winsemius wrote: > > On Aug 2, 2011, at 12:51 PM, r student wrote: > >> I'm trying to create a density plot using census data, where the >> weights don't sum to 1. >> >> >>> plot(density(oh$FINCP,weights=oh$PWGTP)) >> >> >> Warning message: >> In density.default(oh$FINCP, weights = oh$PWGTP) : >> sum(weights) != 1 -- will not get true density >> >> >> How would I go about doing this? > > Wouldn't you just divide by the sum? > > -- > > David Winsemius, MD > West Hartford, CT > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error with cForest
All -- I have been trying to work with the 'Party' package using R v2.15.1 and have cobbled together a (somewhat) functioning code from examples on the web. I need to run a series of unbiased, conditional, cForest tests on several subsets of data which I have made into a loop. The results ideally will be saved to an output file in matrix form. The two questions regarding the script in question (script below) include: 1). After the cForest prints the initial results the error below is displayed: " Random Forest using Conditional Inference Trees Number of trees: 500 Response: Light Inputs: FormH, FormV, Uratio, Void, Transmis Number of observations: 660 FormH FormV UratioVoidTransmis 2259311332 713202692 4250413991 50551193145 57138 Error in print.default(occupied$Fan, predicted) : invalid 'digits' argument" This error only occurs when I change the dependent variable name from " Fan " (the variable I used to develop and test the script with) to any of the other dependent variables I need to test. All variables being tested are either continuous or categorical. Could anyone provide me with more information about this error and possibly the source in the coding? 2). The results are saving successfully to a file as a list however, I wish to save the data into a matrix that resembles: Subset 1, Subset 2, Subset n, Var Importance:VI.1 VI.2VI.n mse: mse.1 mse.2 mse.n rsq:rsq.1rsq.2rsq.n IV-1:x.1 x.2 x.n IV-2:y.1 y.2 y.n IV-n:n.1 a.2 n.n How could I create output that would append/write sequential results as a new column in the file as opposed to being in list form? Your comments are appreciated -- Jay Script in question: > library(party) > rm(list=ls()) > Dynamic <- read.csv(file="Dynamic_DATA.csv") > set.seed(1851) > ctrl <- cforest_unbiased(ntree=500, mtry=5) > > for (i in 1:4){ ## Climate subset + occupied <- subset(Dynamic, WDOccupancy == 1 & Climate == i, select = c(DataSet:DGI)) + Dynamic.cf <- cforest(Fan ~ FormH + FormV + Uratio + Void + Transmis, data = occupied, control = ctrl) + print(Dynamic.cf) + ## round(varimp(Dynamic.cf), 4) + ## Standard importance values __ + imp=varimp(Dynamic.cf, conditional = TRUE) #use varimp defaults + ## plot(imp) + print(imp) + + ## predict variables _ + predicted=predict(Dynamic.cf,OOB = TRUE) + print(occupied$Fan,predicted) + + residual=occupied$Fan-predicted + mse=mean(residual^2) + rsq=1-mse/var(occupied$Fan) + + ##Correlation between fitted values and original values: + correl <- paste(cor(occupied$Fan,predicted)) + Correlation <-paste("MSE:",mse, "Rsq:",rsq, "Correlation between fitted values and original values:",correl) + print(Correlation) + + ## combine results for output ___ + nam <- paste("Climate =",i, sep=" ") + assign(nam, 1:i) + results <- rbind(nam, mse, rsq, correl) + + ## Writing data to csv file _ + write.table(results, file = "variable importance3.csv", append = TRUE, quote = FALSE, sep = " ", col.names = TRUE, row.names = TRUE,) + write.table(imp, file = "variable importance3.csv", append = TRUE, quote = FALSE, sep = " ", eol = "\r", na = "N/A", row.names = TRUE, col.names = TRUE, qmethod = "double") + } [[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] lme4 2 factor factorial model with random factors
Using lme4 how does one define a 2 factor factorial model with both factors being random? Specifically I am just trying to recreate the results from Montgomery's Design of Experiments book (7th edition), example 13.2. In this example there are 2 random factors and I want to include the interaction in the model as Montgomery tests for significance in the full model first. I've tried several things but cannot recreate the results in R. I would think something like what's given below would work, but it does not. lmer(y ~ (1 | Parts) + (1 | Operators) + (1 | Parts:Operators) ) [[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] LogLikelihood of a Distribution Given Fixed Parameters
I'm trying to figure out if there is a way in R to get the loglikelihood of a distribution fit to a set of data where the parameter values are fixed. For example, I want to simulate data from a given alternate lognormal distribution and then I will fit it to a lognormal distribution with null parameter values to see what the likelihood of the null distribution is given random data from the alternate distribution. I have been using fitdistrplus for other purposes but I cannot use it to fix both parameter values. Here is an example of what I've been working with... nullmu<-1.66 #set null mu altmu<-1.58 #set alt mu sd.log<-0.25 #set common sigma cens.time<-6 #if simulated times are greater than this turn them into right censored times #simulating lognormal data (time) from altnative dist (sim<-rlnorm(n=samplesize, meanlog=altmu, sdlog=sd.log)) #if the time was > cens.time replace time with cens.time (sim[which(sim>cens.time)]<-cens.time) sim #create a variable indicating censoring (cens<-sim) cens[which(sim==cens.time)]<-NA cens #create the data frame to be passed to fitdistcens and fitdist (x<-data.frame(left=sim,right=cens)) #if there is censored data use fitdistcens else use fitdist ifelse(length(which(is.na(cens)))>0, simfit<-fitdistcens(censdata=x, distr="lnorm"), simfit<-fitdist(data=x[,1], distr="lnorm") ) #Now I can get the loglikelihood of the MLE fitted distribution simfit$loglik #I want to get the loglikelihood of the distribution with the null parameterization #This is what I can't get to work #I can't seem to find any function that allows me to set both parameter values #so I can get to loglikelihood of the of the parameterization given the data nulldist<-fitdistcens(censdata=x, distr="lnorm", start=list(meanlog=nullmu, sdlog=sd.log) #Then I want to do a likelihood ratio test between the two distributions pchisq((-2*simfit$loglik--2*nulldist$loglik), df=2, lower.tail=FALSE) [[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] LogLikelihood of a Distribution Given Fixed Parameters
Thanks Rolf. That took care of it. It should be lower=FALSE through right? I want the upper tail because my values are right censored? Regards, Jake On Fri, Apr 25, 2014 at 12:50 AM, Rolf Turner wrote: > > As usual I am too lazy to fight my way through the rather convoluted code > presented, but it seems to me that you just want to calculate a log > likelihood. And that is bog-simple: > > The log likelihood for i.i.d. data is just the sum of log f(y_i) where the > y_i are your observed values and f() is the density function of the > distribution that you have in mind. > > Where there is (right) censoring you take the sum of log f(y_i) over all > the non-censored values and then add k*(1-F(cens.time)) where k is the > number of censored values and F() is the cumulative distribution function > corresponding to f(). > > In your case it would appear that f(y) = dlnorm(y,1.66,0.25) and > F(y) = plnorm(y,1.66,0.25). Note that instead of using 1-F(cens.time) you > can use plnorm(cens.time,1.66,0.25,lower=TRUE) and that instead of taking > logs explicitly you can set log=TRUE in the calls to dlnorm() and plnorm(). > > cheers, > > Rolf Turner > > > On 25/04/14 07:27, Jacob Warren (RIT Student) wrote: > >> I'm trying to figure out if there is a way in R to get the loglikelihood >> of >> a distribution fit to a set of data where the parameter values are fixed. >> For example, I want to simulate data from a given alternate lognormal >> distribution and then I will fit it to a lognormal distribution with null >> parameter values to see what the likelihood of the null distribution is >> given random data from the alternate distribution. >> >> I have been using fitdistrplus for other purposes but I cannot use it to >> fix both parameter values. >> >> Here is an example of what I've been working with... >> >> nullmu<-1.66 #set null mu >> altmu<-1.58 #set alt mu >> sd.log<-0.25 #set common sigma >> cens.time<-6 #if simulated times are greater than this turn them into >> right >> censored times >> >> #simulating lognormal data (time) from altnative dist >> (sim<-rlnorm(n=samplesize, meanlog=altmu, sdlog=sd.log)) >> #if the time was > cens.time replace time with cens.time >> (sim[which(sim>cens.time)]<-cens.time) >> sim >> >> #create a variable indicating censoring >> (cens<-sim) >> cens[which(sim==cens.time)]<-NA >> cens >> >> #create the data frame to be passed to fitdistcens and fitdist >> (x<-data.frame(left=sim,right=cens)) >> >> >> #if there is censored data use fitdistcens else use fitdist >> ifelse(length(which(is.na(cens)))>0, >> simfit<-fitdistcens(censdata=x, distr="lnorm"), >> simfit<-fitdist(data=x[,1], distr="lnorm") >> ) >> >> #Now I can get the loglikelihood of the MLE fitted distribution >> simfit$loglik >> >> #I want to get the loglikelihood of the distribution with the null >> parameterization >> #This is what I can't get to work >> #I can't seem to find any function that allows me to set both parameter >> values >> #so I can get to loglikelihood of the of the parameterization given the >> data >> nulldist<-fitdistcens(censdata=x, distr="lnorm", >> start=list(meanlog=nullmu, >> sdlog=sd.log) >> >> #Then I want to do a likelihood ratio test between the two distributions >> pchisq((-2*simfit$loglik--2*nulldist$loglik), df=2, lower.tail=FALSE) >> > > [[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] Unbalanced Design Power Analysis
I have an unbalanced design I would like to run a power analysis on. What I have been able to find has pointed me to using the pwr.f2.test function as described below. My problem is that I don't know how to appropriately define the numerator and demoninator df. If someone can help here is some more info about my design. It is an unbalanced 2^3 x 3 design where the factor with 3 levels is a random effect. So say there are factors A, B, C with 2 levels and D with 3 levels A will have 77 observations at level -1 and 19 at 1 B will have 67 at -1 and 29 at 1 C will have 57 at -1 and 39 at 1 D will have 32 at -1, 0, and 1 General Linear Model Function: pwr.f2.test Arguments: u: Numerator degrees of freedom v: Denominator degrees of freedom f2: Effect Size sig.level: Significance level power: Power of test __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Need help for R install
Dear R committee: I am Renzhi, Ph.D student in computer science in the University of Missouri. I have one question for you. I try to install R in the linux server, but I don't have the root permission, is there any way to install the R locally? Thank you very much for helping me. Renzhi Cao Graduate Research Assistant Department of Computer Science University of Missouri-Columbia Columbia, MO 65211 Cell: 573-825-8874 Email : rc...@mail.missouri.edu<mailto:rc...@mail.missouri.edu> http://home.ustc.edu.cn/~ahjxcrz [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help With Permutations
I have a problem with permutations functions in R I just started using R so maybe it is an easy question I need to obtain all the 9.somthingExp 157 permutations that can be given from the number from 1 to 100 I wrote the following commands: > library(gregmisc) >options(expressions=1e5) cmat <- combinations(300,2) dim(cmat) # 44850 by 2 >permutations(n=100, r=100) Unfortunately at a certain point (after few minutes) I get the following Error: Error: cannot allocate vector of size 609.1 Mb What can I do? Thanks Fabio [[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] error in data.farme--duplicate row.names error
Michael, Thanks for your response. I tried table(table(Bmat)) and it gave me the following error: [ Error in table(Bmat) : object 'Bmat' not found] FYI-- "values" contains 16,383 observations ranging from 0 to less than 1. Lisa -Original Message- From: Michael Dewey [mailto:li...@dewey.myzen.co.uk] Sent: Thursday, May 19, 2016 11:05 AM To: Rees, Lisa Marie (MU-Student); r-help@r-project.org Subject: Re: [R] error in data.farme--duplicate row.names error Dear Lisa What does Bmat contain? Perhaps try table(table(Bmat)) and see if any entries are greater than unity. On 19/05/2016 15:16, Rees, Lisa Marie (MU-Student) wrote: > I'm using the "GameTheory" package--- DefineGame(14,values) and values is > equal to 16,383 observations. > > I keep getting the following error- > [Error in data.frame(rep(0, 2^n - 1), row.names = Bmat) : > duplicate row.names: 1, 11, 111, 12, 112, 1112, 2, 13, 113, > 1113, 3, 1213, 11213, 111213, 213, 14, 114, 1114, 4, 1214, > 11214, 111214, 214, 1314, 11314, 111314, 314, 121314, 1121314, > 11121314, 21314] > > What can I do to fix this issue? I would greatly appreciate any help. > > Thank you. > > > > [[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. > -- Michael http://www.dewey.myzen.co.uk/home.html __ 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 in data.farme--duplicate row.names error
Don, Thank you for your helpful response. At this point, I do believe it is a package error and I have contacted the developer. Thanks, Lisa -Original Message- From: MacQueen, Don [mailto:macque...@llnl.gov] Sent: Thursday, May 19, 2016 4:27 PM To: Rees, Lisa Marie (MU-Student); r-help@r-project.org Subject: Re: [R] error in data.farme--duplicate row.names error You will probably have to contact the maintainer of the package, since the error appears to be generated inside the package's function. Immediately after the error, type traceback() The results might give you a clue. Or they might not! There might be some requirements on the second argument of the DefineGame() function. Check the help page for DefineGame and see if the object you supplied, value, meets those requirements. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 5/19/16, 7:16 AM, "R-help on behalf of Rees, Lisa Marie (MU-Student)" wrote: >I'm using the "GameTheory" package--- DefineGame(14,values) and values >is equal to 16,383 observations. > >I keep getting the following error- >[Error in data.frame(rep(0, 2^n - 1), row.names = Bmat) : > duplicate row.names: 1, 11, 111, 12, 112, 1112, 2, 13, 113, 1113, >3, 1213, 11213, 111213, 213, 14, 114, 1114, 4, 1214, 11214, >111214, 214, 1314, 11314, 111314, 314, 121314, 1121314, >11121314, 21314] > >What can I do to fix this issue? I would greatly appreciate any help. > >Thank you. > > > > [[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.
[R] GGplot annotate by facet
Hi, I have a dataframe which I need to plot in ggplot2 it looks like this :- head(nodelta_firstexon) Value Type Histone 1 0.06 high H3K27ac 2 0.12 low H3K27ac 4 0.04 high H3K27me3 5 0.16 low H3K27me3 7 0.02 high H3K36me3 8 0.13 low H3K36me3 I have another data frame with p-v alues that looks like this :- head(mypval_df) Histone count pvalues 1 H3K9ac 0 0.000 2 H3K27me3 0 0.000 3 H3K36me3 1000 1.000 4 H3K4me3 583 0.583 5 H3K4me1 882 0.882 6 H3K27ac 970 0.970 This is how I plot the first dataframe using ggplot p <- qplot(factor(Value),data=nodelta_firstexon,geom="bar",fill=factor(Type))+facet_wrap(~Histone) Next I need to annotate p-values (p <= mypval_df$pvalues) to each facet using the mypval_df. I can't seem to find an example on how to do it. Would appreciate any help. Regards Saad [[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] Visualizing and clustering one half of a symmetric matrix
Hi all, I have a distance matrix (symmetric) which looks somewhat like this (only a small portion shown) ENSG0101413 ENSG0176884 ENSG0185532 ENSG0106829 ENSG0101413 1.000 1.000 1.000 1.000 ENSG0176884 0.328 0.258 0.260 0.390 ENSG0185532 1.000 1.000 1.000 1.000 ENSG0106829 0.684 0.443 0.531 0.701 These distances are custom measures that I need to cluster. Since it's a symmetric matrix I only need to consider one half triangle of the matrix. So I do something like this :- newmat <- ensembl_copygosimmat newmat[upper.tri(ensembl_copygosimmat)] <- NA Then I wanted to visualize how the lower triangle looked using pheatmap which does hierarchical clustering itself. library(pheatmap) pheatmap(newmat) But since there are NA values in the matrix (in the upper half) it always throws an error. I was wondering what would be the ideal way to visualize as well as cluster such a matrix. Regards Saad [[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] Visualizing and clustering one half of a symmetric matrix
I do want to cluster it and only plot the lower half of the matrix. From: Peter Langfelder Sent: Thursday, September 15, 2016 11:33:13 PM To: Khan, Saad M. (MU-Student) Cc: r-help@R-project.org Subject: Re: [R] Visualizing and clustering one half of a symmetric matrix Do not set the upper (or lower) triangle to NA. Simply supply the full matrix to pheatmap. I am not an expert on pheatmap but looking at the manual you should supply clustering_distance_rows = "none", clustering_distance_cols = "none" or something like that to make pheatmap interpret the matrix as a distance matrix. Read carefully through the help on pheatmap to make sure the function plots what you want it to plot. HTH, Peter On Thu, Sep 15, 2016 at 7:38 PM, Khan, Saad M. (MU-Student) wrote: > Hi all, > > I have a distance matrix (symmetric) which looks somewhat like this (only a > small portion shown) > > ENSG0101413 ENSG0176884 ENSG0185532 > ENSG0106829 > ENSG0101413 1.000 1.000 1.000 > 1.000 > ENSG0176884 0.328 0.258 0.260 > 0.390 > ENSG0185532 1.000 1.000 1.000 > 1.000 > ENSG0106829 0.684 0.443 0.531 > 0.701 > > These distances are custom measures that I need to cluster. Since it's a > symmetric matrix I only need to consider one half triangle of the matrix. So > I do something like this :- > > newmat <- ensembl_copygosimmat > newmat[upper.tri(ensembl_copygosimmat)] <- NA > > Then I wanted to visualize how the lower triangle looked using pheatmap which > does hierarchical clustering itself. > > library(pheatmap) > pheatmap(newmat) > > But since there are NA values in the matrix (in the upper half) it always > throws an error. I was wondering what would be the ideal way to visualize as > well as cluster such a matrix. > > Regards > Saad > > [[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. [[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 in data.farme--duplicate row.names error
I'm using the "GameTheory" package--- DefineGame(14,values) and values is equal to 16,383 observations. I keep getting the following error- [Error in data.frame(rep(0, 2^n - 1), row.names = Bmat) : duplicate row.names: 1, 11, 111, 12, 112, 1112, 2, 13, 113, 1113, 3, 1213, 11213, 111213, 213, 14, 114, 1114, 4, 1214, 11214, 111214, 214, 1314, 11314, 111314, 314, 121314, 1121314, 11121314, 21314] What can I do to fix this issue? I would greatly appreciate any help. Thank you. [[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] (no subject)
What is plot.new? How can I fix this data or add plot.new so it works? > library(maps) > library(splancs) > area = 6*4 > lambda = 1.5 > N = rpois(1,lambda*area) > u = runif(N,-2,4) > v = runif(N,0,4) > plot(u,v,asp=1) > h = chull(u,v) > h = c(h,h[1]) > plot(u[h],v[h],"1",asp=1) Error in plot.xy(xy, type, ...) : invalid plot type '1' > plot(u[h],v[h],"l",asp=1) > points(u,v) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet > pts=as.points(u,v) > pointmap(pts) > hullpoly=as.points(u[h],v[h]) > polymap(hullpolly,add=TRUE) Error in xy.coords(x, y) : object 'hullpolly' not found > help(polymap) > help(plot.net) No documentation for 'plot.net' in specified packages and libraries: you could try '??plot.net' > help(plot.new) > plot(u[h],v[h],"l",asp=1) > plot.new(u,v) Error in plot.new(u, v) : unused argument(s) (u, v) > plot.new() > points(u,v) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet > plot.new(u,v) Error in plot.new(u, v) : unused argument(s) (u, v) > plot.new(xy.coords(x,y)) Error in plot.new(xy.coords(x, y)) : unused argument(s) (xy.coords(x, y)) > plot.new(uv.coords(u,v)) Error in plot.new(uv.coords(u, v)) : unused argument(s) (uv.coords(u, v)) > plot.new <- function() + {} > { } NULL > plot.new <- function() + { } > { } NULL > { for } Error: unexpected '}' in "{ for }" > area = 60*20 > lambda = 2 > N = rpois(1,lambda*area) > u = runif(N,20,40) > v = runif(N,-10,10) > plot(u,v,asp=1) > > plot(u,v,asp=1) > u = runif(N,20,40) > v = runif(N,-10,10) > plot(u,v,asp=1) > > plot(u,v,asp=1) > u = runif(N,20,40) > v = runif(N,-10,10) > plot(u,v,asp=1) > u = runif(N,20,40) > v = runif(N,-10,10) > plot(u,v,asp=1) > h = chull(u,v) > h = c(h,h[1]) > plot(u[h],v[h],"l",asp=1) > points(u,v) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet > pts=as.points(u,v) > pointmap(pts) > hullpoly=as.points(u[h],v[h]) > polymap(hullpolly,add=TRUE) Error in xy.coords(x, y) : object 'hullpolly' not found No help files found matching hullpoly using fuzzy matching > pointmap(as.points(hullpoly), add=TRUE) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet > hullpoly=as.points(u[h],v[h]) > polymap(hullpoly$poly, add=TRUE) Error in hullpoly$poly : $ operator is invalid for atomic vectors > polymap(hullpoly,add=TRUE) Error in polygon(poly, ...) : plot.new has not been called yet > plot.new() NULL > par(new=TRUE) Warning message: In par(new = TRUE) : calling par(new=TRUE) with no plot > plot.new() NULL > par(new=TRUE) Warning message: In par(new = TRUE) : calling par(new=TRUE) with no plot > new.u=runif(50,20,40) > new.v=ruinf(50,-10,10) Error: could not find function "ruinf" > new.v=runif(50,-10,10) > pts.in=pip(as.points(new.u,new.v),hullpoly,out=FALSE) > pointmap(pts.in,col="red",add=TRUE) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet [[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] (no subject)
What is plot.new? and how can i get it to work so i can load other data? > library(splancs) > area = 6*4 > lambda = 1.5 > N = rpois(1,lambda*area) > u = runif(N,-2,4) > v = runif(N,0,4) > plot(u,v,asp=1) > h = chull(u,v) > h = c(h,h[1]) > plot(u[h],v[h],"1",asp=1) Error in plot.xy(xy, type, ...) : invalid plot type '1' > plot(u[h],v[h],"l",asp=1) > points(u,v) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet > pts=as.points(u,v) > pointmap(pts) > hullpoly=as.points(u[h],v[h]) > polymap(hullpolly,add=TRUE) Error in xy.coords(x, y) : object 'hullpolly' not found > help(polymap) > help(plot.net) No documentation for 'plot.net' in specified packages and libraries: you could try '??plot.net' > help(plot.new) > plot(u[h],v[h],"l",asp=1) > plot.new(u,v) Error in plot.new(u, v) : unused argument(s) (u, v) > plot.new() > points(u,v) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet > plot.new(u,v) Error in plot.new(u, v) : unused argument(s) (u, v) > plot.new(xy.coords(x,y)) Error in plot.new(xy.coords(x, y)) : unused argument(s) (xy.coords(x, y)) > plot.new(uv.coords(u,v)) Error in plot.new(uv.coords(u, v)) : unused argument(s) (uv.coords(u, v)) > plot.new <- function() + {} > { } NULL > plot.new <- function() + { } > { } NULL > { for } Error: unexpected '}' in "{ for }" > area = 60*20 > lambda = 2 > N = rpois(1,lambda*area) > u = runif(N,20,40) > v = runif(N,-10,10) > plot(u,v,asp=1) > > plot(u,v,asp=1) > u = runif(N,20,40) > v = runif(N,-10,10) > plot(u,v,asp=1) > > plot(u,v,asp=1) > u = runif(N,20,40) > v = runif(N,-10,10) > plot(u,v,asp=1) > u = runif(N,20,40) > v = runif(N,-10,10) > plot(u,v,asp=1) > h = chull(u,v) > h = c(h,h[1]) > plot(u[h],v[h],"l",asp=1) > points(u,v) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet > pts=as.points(u,v) > pointmap(pts) > hullpoly=as.points(u[h],v[h]) > polymap(hullpolly,add=TRUE) Error in xy.coords(x, y) : object 'hullpolly' not found No help files found matching ‘hullpoly’ using fuzzy matching > pointmap(as.points(hullpoly), add=TRUE) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet > hullpoly=as.points(u[h],v[h]) > polymap(hullpoly$poly, add=TRUE) Error in hullpoly$poly : $ operator is invalid for atomic vectors > polymap(hullpoly,add=TRUE) Error in polygon(poly, ...) : plot.new has not been called yet > plot.new() NULL > par(new=TRUE) Warning message: In par(new = TRUE) : calling par(new=TRUE) with no plot > plot.new() NULL > par(new=TRUE) Warning message: In par(new = TRUE) : calling par(new=TRUE) with no plot > new.u=runif(50,20,40) > new.v=ruinf(50,-10,10) Error: could not find function "ruinf" > new.v=runif(50,-10,10) > pts.in=pip(as.points(new.u,new.v),hullpoly,out=FALSE) > pointmap(pts.in,col="red",add=TRUE) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Moran's I test- Ordinal Logistic Regression Model
Hi, I am trying to do a Moran's I test on an ordinal logistic regression model. I have a simple spatial weights matrix listed below I would like to use. Y= 10 0 0 0 0 0 0 0 01 1 0 0 0 0 1 1 01 1 0 0 0 0 1 1 00 0 1 1 1 1 0 0 00 0 1 1 1 1 0 0 00 0 1 1 1 1 0 0 00 0 1 1 1 1 0 0 01 1 0 0 0 0 1 1 00 1 0 0 0 0 1 1 I try to run the test as follows- moran.test(order$resid, y). It then gives me an error- "Error in moran.test(resid(order), y) : y is not a listw object" Can I transform my matrix into a listw object or use some other test where I can use my simple matrix to perform the test? Also, is using $resid for the ordinal logistic regression the proper way to run the moran's I test? Thanks for any help you can provide me. Lisa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Optimizing with constraints using alabama
Hi, I am testing code that is working successfully using constrOptim. I am replacing constrOptim with other solvers to compare benefits and performance. My belief was that, like constrOptim, auglag in the alabama package would eliminate beta vectors that failed the constraints prior to calling the objective function. These betas are not only not in the solution space but also cause chaos for my objective function. I can see via debugging that hin is working correctly, but I am finding that these beta vectors are being passed to the objective function. I am not sure if this is due to my ineptness or if it is doing so as planned. The auglag documentation talks about applying penalties, so I assume it has examined the vector coming out of hin. I would be pleased to have input from those more knowledgeable than me. If this is by design is there a flag variable available to be examined by my objective function. Currently, I am calling hin again within my objective function - certainly not an optimum solution. Thanks, Roland DePratti Graduate Student Central Connecticut State University Data Science Program Here is my inequality constraint logic: X (constraint matrix) = 1 2 3 4 partyDem 1 -1 0 0 00 2 -1 0 0 0 -1 30 0 0 -10 40 0 0 -1 -1 50 -1 0 00 60 -1 0 0 -1 70 0 -1 00 80 0 -1 0 -1 90 0 0 -10 10 0 0 0 -1 -1 11 -1 0 0 00 12 -1 0 0 0 -1 13 0 -1 0 00 14 0 -1 0 0 -1 15 0 0 -1 00 16 0 0 -1 0 -1 17 -1 1 0 00 18 -1 1 0 00 19 0 -1 1 00 20 0 -1 1 00 21 0 0 -1 10 22 0 0 -1 10 hin <- function(par,X,Xa1,XaJ,Xaj1,Xaj2) { out <- X %*% par return(out) } [[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.