Re: [R] Problem in Starting R Server - object of type 'closure' is not subsettable
On Tue, Nov 27, 2012 at 6:33 AM, Manoj G mano...@isim.net.in wrote: Hi All, I am trying to start R Server to run some Java Script in my local machine using the library, 'Rook'. I use Windows 7. And my codes are following, library(Rook) myD3dir - 'D:\\STUDIES\\Java script\\d3-master' s - Rhttpd$new s$start(quiet=TRUE) Have you read help(Rhttpd)? s - Rhttpd$new() s$start(quiet=TRUE) - there is a subtle difference between that and what you did! Can you spot it!? Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] install the ggplot2 package
Has one try to install the ggplot2 package recently? I tried to install it on my new system and had trouble: I tried a different CRAN mirror but didn't work library(ggplot2) Error in loadNamespace(i, c(lib.loc, .libPaths())) : there is no package called ‘stringr’ In addition: Warning message: package ‘ggplot2’ was built under R version 2.15.2 Error: package/namespace load failed for ‘ggplot2’ -- View this message in context: http://r.789695.n4.nabble.com/install-the-ggplot2-package-tp4650935.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] install the ggplot2 package
Hello, Probably you should upgrade your version of R and install the package 'stringr'. To not miss dependencies, try 'install.packages(ggplot2, dependencies=TRUE)'. Regards, Pascal Le 12/11/27 17:30, Jonsson a écrit : Has one try to install the ggplot2 package recently? I tried to install it on my new system and had trouble: I tried a different CRAN mirror but didn't work library(ggplot2) Error in loadNamespace(i, c(lib.loc, .libPaths())) : there is no package called ‘stringr’ In addition: Warning message: package ‘ggplot2’ was built under R version 2.15.2 Error: package/namespace load failed for ‘ggplot2’ -- View this message in context: http://r.789695.n4.nabble.com/install-the-ggplot2-package-tp4650935.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cosine curve fit
Le 26/11/12 18:19, dysonsphere a écrit : does anybody have a suggestion as to how to use R to fit some date to a cosine function and then have some output statistics that will evaluate the fit? You could take a look at the package phenology. It fits several periodic functions (cosine) onto timeseries of counts. I don't know what you want exactly and so I don't know if it can be on some help. In case it does not what you look for, we could discuss as I develop this package. A common alternative is to use fourrier transforms. Sincerely Marc -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Anova
Hi everyone, I am new to this forum and also new to statistics and I would appreciated it if someone would take some time to answer my question. I am analyzing companies in regard to their leverage. I categorized the companies into 3 groups: small, mid and large. For the group small, I have 55 debt multiples, for mid 42 and for large 72. (Unfortunately I can not provide my data because it is confidential.) I am now trying to find out whether the mean debt multiples are significantly different for the 3 different groups. For this reason I calculated an anova table with the aov function and to display the results for each pair I did the tukey.hsd function. Now my question: Am I allowed to use these functions given that my data is unbalanced? Can use I read several times that aov is only valid for balanced data? If not, is there another function that I can use? Thank you very much for your answers. Call: aov(formula = Debt.Ebitdax ~ Company.Size, data = Anetdebtx2003) Terms: Company.Size Residuals Sum of Squares 302.3089 926.2174 Deg. of Freedom 2 166 Residual standard error: 2.362123 Estimated effects may be unbalanced summary(Anovanetdebtx2003) Df Sum Sq Mean Sq F value Pr(F) Company.Size 2 302.3 151.15 27.09 6.58e-11 *** Residuals 166 926.2 5.58 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 TukeyHSD(Anovanetdebtx2003) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = Debt.Ebitdax ~ Company.Size, data = Anetdebtx2003) $Company.Size diff lwr upr p adj Mid Market Buyout-Large Buyout -1.446292 -2.530922 -0.3616617 0.0054123 Small Buyout-Large Buyout -3.112143 -4.112545 -2.1117420 0.000 Small Buyout-Mid Market Buyout -1.665852 -2.810574 -0.5211300 0.0021037 -- View this message in context: http://r.789695.n4.nabble.com/Anova-tp4650940.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] Problem installing knitr 0.5 or higher in Ubuntu
Hi, I am using Rstudio in Ubuntu . While installing R from the terminal I got the version R 2.13.1 . But the problem is that knitr 0.5 requires higher versions. So is there any way to get the latest version of R in ubuntu (or 2.13.1 is the maximum I can get)? In case the higher R version is not available can anybody please help me how do I use the knitr Html option in R studio. Thanks in advance. -Atanu -- View this message in context: http://r.789695.n4.nabble.com/Problem-installing-knitr-0-5-or-higher-in-Ubuntu-tp4650941.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] sum per day
Hello, I have a data frame somewhat like this one: myframe - data.frame (Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012 11:00, 25.09.2012 09:00, 25.09.2012 10:00, 25.09.2012 11:00), Hunger=c(1,1,1,2,2,1) ) myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp), %d.%m.%Y %H:%M), tz=GMT) myframe2 - cbind (myframe,myframestime) myframe2$Timestamp - NULL myframe2 Now I want to get the sum of Hunger for each day. In the end I want something which looks like the following dataframe: myoutcome - data.frame(Timestamp=c(24.09.2012, 25.09.2012), sumHunger=c(3, 5)) Does anyone know how to do that? That would be very helpful and to all people who are willing to help me: Thank you in advance! Best regards, Tagmarie -- View this message in context: http://r.789695.n4.nabble.com/sum-per-day-tp4650937.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem in Starting R Server - object of type 'closure' is not subsettable
Thank you so much Barry for pointing out my mistake. Manoj G -- View this message in context: http://r.789695.n4.nabble.com/Problem-in-Starting-R-Server-object-of-type-closure-is-not-subsettable-tp4650931p4650938.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 R
On 11/26/2012 09:38 PM, alanaro...@sapo.pt wrote: Goodmorning, I'moneafazrtrbhoquhasa variablefactorcomtwoNivesCandH.Queoaatravésdlinear regressionrelationshipetrehaSaerifthe variablespthiedoseogmerparawanttheHtothatanddouCrespctinteRaficthat showsthe two curvesHandCLIRand Selecionar tudo Thank you Ana C. Rocha Rua Hi Ana, I'm afraid that I cannot make much sense at all out of this. The best thing I can suggest is that you contact the Brazil R Users group. http://leg.est.ufpr.br/doku.php/software:rbr Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sum per day
Hello, Try aggregate(Hunger ~ cut(myframe2$myframestime, day), data = myframe2, FUN = sum) Hope this helps, Rui Barradas Em 27-11-2012 09:13, Tagmarie escreveu: Hello, I have a data frame somewhat like this one: myframe - data.frame (Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012 11:00, 25.09.2012 09:00, 25.09.2012 10:00, 25.09.2012 11:00), Hunger=c(1,1,1,2,2,1) ) myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp), %d.%m.%Y %H:%M), tz=GMT) myframe2 - cbind (myframe,myframestime) myframe2$Timestamp - NULL myframe2 Now I want to get the sum of Hunger for each day. In the end I want something which looks like the following dataframe: myoutcome - data.frame(Timestamp=c(24.09.2012, 25.09.2012), sumHunger=c(3, 5)) Does anyone know how to do that? That would be very helpful and to all people who are willing to help me: Thank you in advance! Best regards, Tagmarie -- View this message in context: http://r.789695.n4.nabble.com/sum-per-day-tp4650937.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] order.max specification problem in the ar.ols function
Hello I am facing a curious problem.I have a time series data with which i want to fit auto-regressive model of order p, where p runs from 1:9.I am using a for loop which will fit an AR(p) model for each value of p using the *ar.ols* function. I am using the following code for ( p in 1:9){ a=ar.ols (x=data.ts, order.max=p, demean=T, intercept=T) } Specifying the *order.max* to be p, it gives me a fitted AR model of order exactly p, though it may not be the best model. The code works fine except for p=4,5, in which cases it fits an AR (3) model to the data. I don't seem to understand what is the problem.Also is there any alternative way by which i can fit an AR(p) model where p is specified by the user? Any help in this matter will be of immense help. Thank you. Soham Chakraborty -- View this message in context: http://r.789695.n4.nabble.com/order-max-specification-problem-in-the-ar-ols-function-tp4650942.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] R strange behaviour when building huge concatenation
Hello, That instruction gave me no problems. I've tried it with and without the useless end semi-colon and all went well. Something to do with your R session? Try it in a new session to see if it works. Hope this helps, Rui Barradas Em 26-11-2012 21:24, angeloimm escreveu: Any idea on the reason why the instruction p1x-c(2, 1, 0, 0, 0, 7, 1, 0, 2, 0, 5, 0, 0, 0, 0, 0, 10, 1, 3, 0, 2, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 12, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 1, 0, 1, 0, 4, 0, 1, 0, 0, 0, 2, 0, 0, 3, 0, 0, 1, 0, 1, 0, 0, 0, 3, 0, 0, 1, 0, 0, 0, 7, 0, 10, 0, 0, 1, 6, 0, 0, 0, 0, 0, 2, 4, 1, 5, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 4, 3, 0, 1, 2, 0, 1, 2, 0, 2, 1, 1, 0, 5, 2, 7, 2, 0, 4, 13, 0, 4, 4, 0, 0, 1, 0, 1, 29, 0, 3, 0, 0, 1, 0, 10, 0, 0, 13, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 6, 8, 0, 0, 0, 1, 0, 4, 0, 2, 3, 3, 0, 0, 0, 0, 0, 6, 0, 1, 0, 0, 2, 0, 2, 2, 0, 0, 1, 0, 1, 0, 0, 7, 0, 0, 0, 2, 0, 4, 0, 1, 1, 0, 0, 0, 0, 0, 2, 0, 1, 1, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 5, 0, 0, 2, 0, 1, 2, 0, 0, 1, 0, 1, 0, 5, 0, 0, 1, 2, 0, 1, 0, 0, 1, 2, 1, 0, 1, 0, 1, 0, 3, 1, 13, 0, 0, 0, 0, 0, 3, 3, 1, 0, 0, 3, 0, 5, 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0, 0, 2, 1, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 3, 2, 0, 0, 0, 1, 0, 0, 0, 4, 0, 1, 3, 0, 0, 0, 0, 0, 0, 3, 1, 0, 1, 1, 2, 0, 2, 0, 0, 0, 3, 0, 1, 0, 1, 0, 9, 0, 0, 4, 0, 2, 0, 5, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 4, 1, 0, 0, 1, 5, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 3, 0, 0, 2, 0, 14, 4, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 3, 0, 2, 0, 0, 1, 1, 6, 1, 6, 0, 1, 2, 0, 0, 2, 1, 0, 2, 1, 0, 1, 0, 2, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 4, 0, 1, 0, 0, 5, 0, 2, 0, 1, 0, 5, 0, 1, 2, 0, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 3, 0, 4, 0, 1, 0, 0, 3, 1, 0, 2, 0, 2, 1, 0, 0, 0, 4, 0, 0, 0, 26, 1, 6, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 1, 2, 0, 1, 0, 0, 0, 14, 0, 1, 0, 2, 4, 0, 1, 6,
Re: [R] Problem installing knitr 0.5 or higher in Ubuntu
Hello, http://cran.at.r-project.org/bin/linux/ubuntu/README.html Regards, Pascal Le 27/11/2012 19:27, ATANU a écrit : Hi, I am using Rstudio in Ubuntu . While installing R from the terminal I got the version R 2.13.1 . But the problem is that knitr 0.5 requires higher versions. So is there any way to get the latest version of R in ubuntu (or 2.13.1 is the maximum I can get)? In case the higher R version is not available can anybody please help me how do I use the knitr Html option in R studio. Thanks in advance. -Atanu -- View this message in context: http://r.789695.n4.nabble.com/Problem-installing-knitr-0-5-or-higher-in-Ubuntu-tp4650941.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem installing knitr 0.5 or higher in Ubuntu
On 27-11-2012, at 11:27, ATANU wrote: Hi, I am using Rstudio in Ubuntu . While installing R from the terminal I got the version R 2.13.1 . But the problem is that knitr 0.5 requires higher versions. So is there any way to get the latest version of R in ubuntu (or 2.13.1 is the maximum I can get)? In case the higher R version is not available can anybody please help me how do I use the knitr Html option in R studio. You haven't told us which version of Ubuntu you are using. See http://cran.r-project.org/bin/linux/ubuntu/ You should first uninstall your current R. Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem installing knitr 0.5 or higher in Ubuntu
Hello, How did you install R? I've installed it from the terminal and got the latest version, R 2.15.2 The commands I've used were sudo apt-get update sudo apt-get install r-base sudo apt-get install rbase-dev Hope this helps, Rui Barradas Em 27-11-2012 10:27, ATANU escreveu: Hi, I am using Rstudio in Ubuntu . While installing R from the terminal I got the version R 2.13.1 . But the problem is that knitr 0.5 requires higher versions. So is there any way to get the latest version of R in ubuntu (or 2.13.1 is the maximum I can get)? In case the higher R version is not available can anybody please help me how do I use the knitr Html option in R studio. Thanks in advance. -Atanu -- View this message in context: http://r.789695.n4.nabble.com/Problem-installing-knitr-0-5-or-higher-in-Ubuntu-tp4650941.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with graphics in gamm4 library
I would approach something like this using predict(fit41$gam,...) (see ?predict.gam) to produce the data needed for the plots. Another possibility is to use s(Time,trt,bs=fs) (but see ?factor.smooth.interaction first). Note that gamm4 does not have a correlation argument, because lme4 does not provide correlation structures, so corARH1() is just ignored (there is no error or warning produced because gamm4 does have a '...' argument!). best, Simon On 27/11/12 00:07, MurphFL wrote: My problem is relatively straight forward, but I cannot seem to find a way to make it work. I have a RCBD with repeated measurements over time. I have created a fit using the gamm4 package. My model is: fit4a - gamm4(Rate ~ s(Time,by=trt,bs=cr)+trt,data=qual.11.dat, random=~(1|block),correlation=corARH1()) What I would like to create is plots with the X-axis being time, the Y-axis being the fitted Rates for each individual treatment with the smoothed curves overlayed on the plot. Every idea I have had to do this has resulted in some errors, and I have reached my wits end. Can anyone steer me in the right direction? -- View this message in context: http://r.789695.n4.nabble.com/Help-with-graphics-in-gamm4-library-tp4650908.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. -- Simon Wood, Mathematical Science, University of Bath BA2 7AY UK +44 (0)1225 386603 http://people.bath.ac.uk/sw283 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in Random Effect Panel
up -- View this message in context: http://r.789695.n4.nabble.com/Error-in-Random-Effect-Panel-Negative-variance-tp4650654p4650948.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] Effect of each term in the accuracy of Nonlinear multivariate regression fitting equation
Dear all, I have a set of data with 4 inputs (independent variables) and one output (dependent variable). I want to perform a regression analysis in order to fit these data to a regression model, however due to the non-linearity of the model I do not have a clue which equation to use. I am thinking of starting with a very general equation including ^3 terms and interactions between the variables however this will lead to a very long equation. Is there a way to assess the effect of each term to the accuracy of the regression model in order to discard the terms with the least importance? Something like a sensitivity analysis of the effect of each term to the accuracy regression model. I know one possible solution to my problem is simply 'trial and error' however before going down that road I want to check if there is an easier way. e.g. Let's say I have four input variables A B C and D, one output 'JIM' and let z1, z2, ... be the coefficients of the terms of the equation. The regression will be something like that: Result = nls(JIM ~ z1*A + z2*B + z3*A*B^2 + z4*C*D^3 + z5*A^2*B^2 ... ) Is there a way to assess the contribution of each term (z1*A, z3*A*B^3 etc) to the accuracy of the regression model? Thanks a lot -- View this message in context: http://r.789695.n4.nabble.com/Effect-of-each-term-in-the-accuracy-of-Nonlinear-multivariate-regression-fitting-equation-tp4650949.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to input a string without quote
Wow, you are so lazy... But sometimes R is just designed for lazy guys... ## f = function(a) { s = substitute(a) as.character(s) } ## Yihui Cheers, Yihui, nearly 4 years after your post this still works like a charm. ps: of course I am not lazy, I simply want to avoid error prone input! ;) -- View this message in context: http://r.789695.n4.nabble.com/how-to-input-a-string-without-quote-tp872607p4650954.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] question about A2R
DID YOU SOLVE THE PROBLEM? -- View this message in context: http://r.789695.n4.nabble.com/question-about-A2R-tp4640539p4650952.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] order.max specification problem in the ar.ols function
Hello, Just set argument aic = FALSE. From the help page: |aic| Logical flag. If |TRUE| then the Akaike Information Criterion is used to choose the order of the autoregressive model. If |FALSE|, the model of order |order.max| is fitted. Hope this helps, Rui Barradas Em 27-11-2012 10:36, soham chakraborty escreveu: Hello I am facing a curious problem.I have a time series data with which i want to fit auto-regressive model of order p, where p runs from 1:9.I am using a for loop which will fit an AR(p) model for each value of p using the *ar.ols* function. I am using the following code for ( p in 1:9){ a=ar.ols (x=data.ts, order.max=p, demean=T, intercept=T) } Specifying the *order.max* to be p, it gives me a fitted AR model of order exactly p, though it may not be the best model. The code works fine except for p=4,5, in which cases it fits an AR (3) model to the data. I don't seem to understand what is the problem.Also is there any alternative way by which i can fit an AR(p) model where p is specified by the user? Any help in this matter will be of immense help. Thank you. Soham Chakraborty -- View this message in context: http://r.789695.n4.nabble.com/order-max-specification-problem-in-the-ar-ols-function-tp4650942.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Anova
Hi, You can use the car package and choose Type-III test. Also, have a look at the package easyanova. Regards, José José Iparraguirre Chief Economist Age UK -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of humming-bird Sent: 27 November 2012 10:12 To: r-help@r-project.org Subject: [R] Anova Hi everyone, I am new to this forum and also new to statistics and I would appreciated it if someone would take some time to answer my question. I am analyzing companies in regard to their leverage. I categorized the companies into 3 groups: small, mid and large. For the group small, I have 55 debt multiples, for mid 42 and for large 72. (Unfortunately I can not provide my data because it is confidential.) I am now trying to find out whether the mean debt multiples are significantly different for the 3 different groups. For this reason I calculated an anova table with the aov function and to display the results for each pair I did the tukey.hsd function. Now my question: Am I allowed to use these functions given that my data is unbalanced? Can use I read several times that aov is only valid for balanced data? If not, is there another function that I can use? Thank you very much for your answers. Call: aov(formula = Debt.Ebitdax ~ Company.Size, data = Anetdebtx2003) Terms: Company.Size Residuals Sum of Squares 302.3089 926.2174 Deg. of Freedom 2 166 Residual standard error: 2.362123 Estimated effects may be unbalanced summary(Anovanetdebtx2003) Df Sum Sq Mean Sq F value Pr(F) Company.Size 2 302.3 151.15 27.09 6.58e-11 *** Residuals 166 926.2 5.58 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 TukeyHSD(Anovanetdebtx2003) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = Debt.Ebitdax ~ Company.Size, data = Anetdebtx2003) $Company.Size diff lwr upr p adj Mid Market Buyout-Large Buyout -1.446292 -2.530922 -0.3616617 0.0054123 Small Buyout-Large Buyout -3.112143 -4.112545 -2.1117420 0.000 Small Buyout-Mid Market Buyout -1.665852 -2.810574 -0.5211300 0.0021037 -- View this message in context: http://r.789695.n4.nabble.com/Anova-tp4650940.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. A Star for Christmas Kick start the festive season by attending one of Age UK’s Carol Concerts, A Star for Christmas. Taking place at Manchester Cathedral on Saturday 1 December and London’s St Pancras Church (opposite Euston Station) on Thursday 6 December, they will feature special musical performances, readings by your favourite celebrities and carols, followed by mince pies and wine. Tickets are priced at £20 full price/ £10 concessions. For more information, please visit http://www.ageuk.org.uk/astarforchristmas or contact the Fundraising Events Team on 020 303 31725. Age UK Improving later life www.ageuk.org.uk --- Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798). Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA. For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health cash plans customers respectively. Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and regulated by the Financial Services Authority. -- This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you receive a message in error, please advise the sender and delete immediately. Except where this email is sent in the usual course of our business, any opinions expressed in this email are those of the author and do not necessarily reflect the opinions of Age UK or its subsidiaries and associated companies. Age UK monitors all e-mail transmissions passing through its network and may block or modify mails which are deemed to be unsuitable. Age Concern England (charity number 261794) and Help the Aged (charity number 272786) and their trading and other associated companies merged on 1st April 2009. Together they have formed the Age UK Group, dedicated to improving the lives of people in later life. The three national Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help the Aged in these nations to form three registered charities: Age Scotland, Age NI, Age
Re: [R] Help on function please
Andras, What do you want your code to do? Give us a little explanation with your code. When I try to run your code, I get Error: could not find function genoud. Either supply the code for the functions included in your code, or tell us what packages we need to run it. Jean Andras Farkas motyoc...@yahoo.com wrote on 11/26/2012 02:43:25 PM: Dear All, I could use a bit of help here, this function is hard to figure out (for me at least) I have the following so far: PKindex-data.frame(Subject=c(1),time=c(1,2,3,4,6,10,12),conc=c(32, 28,25,22,18,14,11)) Dose-200 Tinf -0.5 defun- function(time, y, parms) { dCpdt - -parms[kel] * y[1] list(dCpdt) } modfun - function(time,kel, Vd) { out - lsoda(((Dose/Tinf)*(1/(kel*Vd)))*(1-exp(-kel*time)),c (0,time),defun,parms=c(kel=kel,Vd=Vd),rtol=1e-3,atol=1e-5) out[-1,2] } objfun - function(par) { out - modfun(PKindex$time, par[1], par[2]) gift - which( PKindex$conc != 0 ) sum((PKindex$conc[gift]-out[gift])^2) } gen-genoud (objfun,nvars=2,max=FALSE,pop.size=30,max.generations=100,wait.generations=100,starting.value=c (0.7, 60),BFGS=FALSE,print.level=0,boundary.enforcement=2,Domains=matrix(c (0.01,0.01,100,100),2,2),MemoryMatrix=TRUE) but get the following: Error in lsoda(((Dose/Tinf) * (1/(kel * Vd))) * (1 - exp(-kel * time)), : The number of derivatives returned by func() (1must equal the length of the initial conditions vector (7) i figured that having the time parameter in the equation screws things up, but do not now how to fix it bc I do not understand the warning message. your help is greatly apreciated, Sincerely, Andras [[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] loop with date
Hello, I tried to construct my very first loop today and completly failed :-( Maybe someone can help me? I have a dataframe somewhat like this one: myframe - data.frame (Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012 11:00, 25.09.2012 09:00, 25.09.2012 10:00, 25.09.2012 11:00), Speed=c(1,1,2,5,1,6)) myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp), %d.%m.%Y %H:%M), tz=GMT) myframe2 - cbind (myframe,myframestime) myframe2$Timestamp - NULL myframe2 I want to construct a loop for every day, i.e. for each day I want to do some calculations. (I know in the example it would be easier to do it differently, my real data are little more complex). And BTW: Thanks for helping me earlier today with that other problem :-) -- View this message in context: http://r.789695.n4.nabble.com/loop-with-date-tp4650961.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] error of runing R in R 2.15.2 w/o graphes generated
It works for me. See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for some suggestions on how to report the problem in more detail. Your sessionInfo() is probably an absolute necessity here. Good luck John Kane Kingston ON Canada -Original Message- From: dtustud...@hotmail.com Sent: Mon, 26 Nov 2012 22:27:27 -0700 To: r-help@r-project.org Subject: [R] error of runing R in R 2.15.2 w/o graphes generated Hi, I have installed R 2.15.2 on windows 7. http://cran.cnr.berkeley.edu/ I tried to run some simple graph code: http://www.harding.edu/fmccown/r/ But, no graphs are presented or poped up. Any help will be appreciated. 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. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] loop with date
On Tuesday, November 27, 2012, Tagmarie wrote: Hello, I tried to construct my very first loop today and completly failed :-( Maybe someone can help me? I have a dataframe somewhat like this one: myframe - data.frame (Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012 11:00, 25.09.2012 09:00, 25.09.2012 10:00, 25.09.2012 11:00), Speed=c(1,1,2,5,1,6)) myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp), %d.%m.%Y %H:%M), tz=GMT) myframe2 - cbind (myframe,myframestime) myframe2$Timestamp - NULL myframe2 Where's the loopy bit that fails? Cheers, MW I want to construct a loop for every day, i.e. for each day I want to do some calculations. (I know in the example it would be easier to do it differently, my real data are little more complex). And BTW: Thanks for helping me earlier today with that other problem :-) -- View this message in context: http://r.789695.n4.nabble.com/loop-with-date-tp4650961.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org javascript:; mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Effect of each term in the accuracy of Nonlinear multivariate regression fitting equation
In this context, linear model means linear in the _coefficients_ not (necessarily) linear in the predictors, so your model: JIM ~ z1*A + z2*B + z3*A*B^2 + z4*C*D^3 + z5*A^2*B^2 ... is a linear model (in z1, z2, ...). So you don't need to use nls, lm is probably favourite. You can use all the techniques around for evaluating linear models; anova.lm might give you a start. KJ On 27/11/2012 11:40, dsfakianakis wrote: Dear all, I have a set of data with 4 inputs (independent variables) and one output (dependent variable). I want to perform a regression analysis in order to fit these data to a regression model, however due to the non-linearity of the model I do not have a clue which equation to use. I am thinking of starting with a very general equation including ^3 terms and interactions between the variables however this will lead to a very long equation. Is there a way to assess the effect of each term to the accuracy of the regression model in order to discard the terms with the least importance? Something like a sensitivity analysis of the effect of each term to the accuracy regression model. I know one possible solution to my problem is simply 'trial and error' however before going down that road I want to check if there is an easier way. e.g. Let's say I have four input variables A B C and D, one output 'JIM' and let z1, z2, ... be the coefficients of the terms of the equation. The regression will be something like that: Result = nls(JIM ~ z1*A + z2*B + z3*A*B^2 + z4*C*D^3 + z5*A^2*B^2 ... ) Is there a way to assess the contribution of each term (z1*A, z3*A*B^3 etc) to the accuracy of the regression model? Thanks a lot -- View this message in context: http://r.789695.n4.nabble.com/Effect-of-each-term-in-the-accuracy-of-Nonlinear-multivariate-regression-fitting-equation-tp4650949.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] R strange behaviour when building huge concatenation
No idea. It seems fine to me. Perhaps a bit more information would be useful expecially your sessionInfo() See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for some suggestions on forming questions. John Kane Kingston ON Canada -Original Message- From: angelo...@gmail.com Sent: Mon, 26 Nov 2012 13:24:28 -0800 (PST) To: r-help@r-project.org Subject: Re: [R] R strange behaviour when building huge concatenation Any idea on the reason why the instruction p1x-c(2, 1, 0, 0, 0, 7, 1, 0, 2, 0, 5, 0, 0, 0, 0, 0, 10, 1, 3, 0, 2, 0, 0, 0,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0, 1, 5, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 3, 0, 0, 2, 0, 14, 4, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 3, 0, 2, 0, 0, 1, 1, 6, 1, 6, 0, 1, 2, 0, 0, 2, 1, 0, 2,
Re: [R] Effect of each term in the accuracy of Nonlinear multivariate regression fitting equation
On Nov 27, 2012, at 7:44 AM, Keith Jewell wrote: In this context, linear model means linear in the _coefficients_ not (necessarily) linear in the predictors, so your model: JIM ~ z1*A + z2*B + z3*A*B^2 + z4*C*D^3 + z5*A^2*B^2 ... is a linear model (in z1, z2, ...). So you don't need to use nls, lm is probably favourite. You can use all the techniques around for evaluating linear models; anova.lm might give you a start. The additional R coding tip would be the I() function, lm(JIM ~ B + A*I(B^2) + I(C*D^3) + I(A^2*B^2) + ... Note that A and I(B^2) would also get estimates because of the way * is interpreted in formulas. If the * is inside the I() function that interpretation is not expanded. In the linear models context it might be wiser to forego this approach and instead use regression splines. -- David. KJ On 27/11/2012 11:40, dsfakianakis wrote: Dear all, I have a set of data with 4 inputs (independent variables) and one output (dependent variable). I want to perform a regression analysis in order to fit these data to a regression model, however due to the non- linearity of the model I do not have a clue which equation to use. I am thinking of starting with a very general equation including ^3 terms and interactions between the variables however this will lead to a very long equation. Is there a way to assess the effect of each term to the accuracy of the regression model in order to discard the terms with the least importance? Something like a sensitivity analysis of the effect of each term to the accuracy regression model. I know one possible solution to my problem is simply 'trial and error' however before going down that road I want to check if there is an easier way. e.g. Let's say I have four input variables A B C and D, one output 'JIM' and let z1, z2, ... be the coefficients of the terms of the equation. The regression will be something like that: Result = nls(JIM ~ z1*A + z2*B + z3*A*B^2 + z4*C*D^3 + z5*A^2*B^2 ... ) Is there a way to assess the contribution of each term (z1*A, z3*A*B^3 etc) to the accuracy of the regression model? Thanks a lot -- View this message in context: http://r.789695.n4.nabble.com/Effect-of-each-term-in-the-accuracy-of-Nonlinear-multivariate-regression-fitting-equation-tp4650949.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. David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Anova
Now my question: Am I allowed to use these functions given that my data is unbalanced? Unusually, Yes, assuming all the other requisite assumptions are reasonably well satisfied. One-way ANOVA interpretation is not much affected by imbalance because (among other things) with only one factor there is no 'model order' dependence or hypothesis separation to worry about. You don't need to use alternate sum-of-squares calculations (eg type II and III as in car) because types I, II and III sums of squares are all the same in a one-way case. In a two-factor or higher analysis it's a (very) different story. However, one-way anova is still adversely affected by failures in homogeneity of variance, non-normality etc. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop with date
Here is an example of an approach: myframe - data.frame (Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, + 24.09.2012 11:00, +25.09.2012 09:00, 25.09.2012 10:00, + 25.09.2012 11:00), + Speed=c(1,1,2,5,1,6)) myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp), + %d.%m.%Y %H:%M), tz=GMT) myframe2 - cbind (myframe,myframestime) myframe2$Timestamp - NULL myframe2 Speedmyframestime 1 1 2012-09-24 09:00:00 2 1 2012-09-24 10:00:00 3 2 2012-09-24 11:00:00 4 5 2012-09-25 09:00:00 5 1 2012-09-25 10:00:00 6 6 2012-09-25 11:00:00 # split the dataframe into days' and then find average of Speed (for example) tapply(myframe2$Speed, cut(myframe2$myframestime, 'day'), mean) 2012-09-24 2012-09-25 1.33 4.00 On Tue, Nov 27, 2012 at 9:02 AM, Tagmarie ramga...@gmx.net wrote: Hello, I tried to construct my very first loop today and completly failed :-( Maybe someone can help me? I have a dataframe somewhat like this one: myframe - data.frame (Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012 11:00, 25.09.2012 09:00, 25.09.2012 10:00, 25.09.2012 11:00), Speed=c(1,1,2,5,1,6)) myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp), %d.%m.%Y %H:%M), tz=GMT) myframe2 - cbind (myframe,myframestime) myframe2$Timestamp - NULL myframe2 I want to construct a loop for every day, i.e. for each day I want to do some calculations. (I know in the example it would be easier to do it differently, my real data are little more complex). And BTW: Thanks for helping me earlier today with that other problem :-) -- View this message in context: http://r.789695.n4.nabble.com/loop-with-date-tp4650961.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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] order.max specification problem in the ar.ols function
Thank you very much for the advice.It works that way. Soham Chakraborty -- View this message in context: http://r.789695.n4.nabble.com/order-max-specification-problem-in-the-ar-ols-function-tp4650942p4650957.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] sum per day
HI, Try this: library(plyr) res-ddply(myframe2,.(Timestamp=as.Date(myframe2$myframestime)),function(x) sum(x$Hunger)) names(res)[2]-sumHunger res[,1]-format(res[,1],%d.%m.%Y) res # Timestamp sumHunger #1 24.09.2012 3 #2 25.09.2012 5 A.K. - Original Message - From: Tagmarie ramga...@gmx.net To: r-help@r-project.org Cc: Sent: Tuesday, November 27, 2012 4:13 AM Subject: [R] sum per day Hello, I have a data frame somewhat like this one: myframe - data.frame (Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012 11:00, 25.09.2012 09:00, 25.09.2012 10:00, 25.09.2012 11:00), Hunger=c(1,1,1,2,2,1) ) myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp), %d.%m.%Y %H:%M), tz=GMT) myframe2 - cbind (myframe,myframestime) myframe2$Timestamp - NULL myframe2 Now I want to get the sum of Hunger for each day. In the end I want something which looks like the following dataframe: myoutcome - data.frame(Timestamp=c(24.09.2012, 25.09.2012), sumHunger=c(3, 5)) Does anyone know how to do that? That would be very helpful and to all people who are willing to help me: Thank you in advance! Best regards, Tagmarie -- View this message in context: http://r.789695.n4.nabble.com/sum-per-day-tp4650937.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop with date
HI, If you want to do daily mean, sum etc. you could try ?tapply(), ?ave(), ?aggregate(), ?ddply() etc. For e.g. ave(myframe2$Speed,as.Date(myframe2$myframestime),FUN=sum) #[1] 4 4 4 12 12 12 tapply(myframe2$Speed,as.Date(myframe2$myframestime),FUN=mean) #2012-09-24 2012-09-25 # 1.33 4.00 It is better to show the complex data as an example using dput() A.K. - Original Message - From: Tagmarie ramga...@gmx.net To: r-help@r-project.org Cc: Sent: Tuesday, November 27, 2012 9:02 AM Subject: [R] loop with date Hello, I tried to construct my very first loop today and completly failed :-( Maybe someone can help me? I have a dataframe somewhat like this one: myframe - data.frame (Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012 11:00, 25.09.2012 09:00, 25.09.2012 10:00, 25.09.2012 11:00), Speed=c(1,1,2,5,1,6)) myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp), %d.%m.%Y %H:%M), tz=GMT) myframe2 - cbind (myframe,myframestime) myframe2$Timestamp - NULL myframe2 I want to construct a loop for every day, i.e. for each day I want to do some calculations. (I know in the example it would be easier to do it differently, my real data are little more complex). And BTW: Thanks for helping me earlier today with that other problem :-) -- View this message in context: http://r.789695.n4.nabble.com/loop-with-date-tp4650961.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Variance component estimation in glmmPQL
Hi all, I've been attempting to fit a logistic glmm using glmmPQL in order to estimate variance components for a score test, where the model is of the form logit(mu) = X*a+ Z1*b1 + Z2*b2. Z1 and Z2 are actually reduced rank square root matrices of the assumed covariance structure (up to a constant) of random effects c1 and c2, respectively, such that b1 ~ N(0,sig.1^2*I) and c1 ~ N(0,sig.1^2*K1) , where K1 = Z1*t(Z1), and c1 = Z1*b1. The model form I've been using is just the following: m-glmmPQL(y~1,random=list(f=pdBlocked(list(pdIdnot(~Z.1-1),pdIdnot(~Z.2-1 ,family=binomial(link=logit)) I've been extracting the variance components using VarCorr(), but I've noticed that the reported variances associated with my random effects are not even close to the values I get if I evaluate their variances empirically (eg var(random.effects(m.12)). I know that's not how they're actually estimated, but there may be a whole order of magnitude difference in the values. Below is an example under R 2.14 on a linux machine: library(MASS) library(mgcv) library(boot) set.seed(1234) G.1-matrix(rnorm(5000,0,0.25),nrow=100) G.2-matrix(rnorm(5000,0,0.25),nrow=100) K.1-G.1%*%t(G.1) K.2-G.2%*%t(G.2) Z.1-mroot(K.1,method=svd) Z.2-mroot(K.2,method=svd) b.1-matrix(rnorm(ncol(Z.1),0,0.25),ncol=1) b.2-matrix(rnorm(ncol(Z.2),0,0.50),ncol=1) p-inv.logit(Z.1%*%b.1+Z.2%*%b.2) y-rbinom(100,1,p) f-rep(1,100) m.fit-glmmPQL(y~1,random=list(f=pdBlocked(list(pdIdent(~Z.1-1),pdIdent(~Z.2-1, family=binomial(link=logit)) VarCorr(m.fit) var(as.numeric(random.effects(m.fit))[1:ncol(Z.1)]) var(as.numeric(random.effects(m.fit))[-c(1:ncol(Z.1))]) From the above, VarCorr() results in variance component estimates of sig.1^2 = 0.444 and sig.2^2 = 0.2778, whereas the empirical estimates are sig.1^2 = 0.2060 and sig.1^2 = 0.097. I know variance component estimation in general is a little shaky, but my simulations suggest that VarCorr() is extracting values that are way too large on a consistent basis. I'm largely assuming I'm misinterpreting something here, just can't figure out what. -Nick -- View this message in context: http://r.789695.n4.nabble.com/Variance-component-estimation-in-glmmPQL-tp4650964.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] R strange behaviour when building huge concatenation
Hello John It seems correct to me too but in my R console it seems to not be working Here there is what I did: i copied the statement on one row (leaving and removing the final useless semi colomn) i tried to execute it in the R console (in order to open my R console I simply opened a terminal window on my ubuntu machine and I typed R) when I click enter the inserted statement doesn't not run...I simply see the cursor on a new line and this new line starts with + Here there is a little stack of what I see on my terminal: , 1, 1, 2, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 17, 2, 2, 0, 2, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 1, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 7, 0, 0, 1, 0, 0, 3, 0, 0, 2, 4, 0, 1, 0, 0, 0, 0, 2, 1, 0, 4, 2, 0, 0, 1, 3, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 1, 0, 1, 1, 3, 3, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 0, 0, 1, 1, 0, 2, 0, 2, 0, 3, 0, 4, 0, 1, 1, 0, 0, 1, 0, 3, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0, 6, 0, 0, 0, 0, 3, 0, 0, 0, 2, 5, 0, 1, 0, 0, 1, 0, 1, 0, 0, 2, 0, 1, 2, 0, 0, 7, 0, 0, 2, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 8, 0, 0, 5, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 3, 0, 2, 0, 0, 0, 2, 1, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 2, 0, 0, 1, 0, 1, 2, 0, 0, 1, 0, 2, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9, 3, 0, 0, 0, 0, 0, 0, 3, 0, 0, 2, 0, 1, 1, 1, 0, 0, 0, 2, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 4, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0, 1, 0, 0, 6, 0, 0, 0, 0, 1, 0, 0, 2, 6, 0, 1, 0, 0, 0, 0, 2, 0, 7, 0, 1, 2, 1, 1, 1, 0, 0, 1, 5, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 5, 1, 0, 1, 2, 0, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 7, 1, 2, 0, 0, 0, 5, 0, 4, 0)) + + + + + Each time i click enter i go on a new line starting with + Then if i start in tying some character I get an error like this: + + + q + + q Errore: unexpected symbol in: q Sometimes this error (Errore: unexpected symbol in:) appears in the statement execution Here there are my sessionInfo() result: sessionInfo() R version 2.14.1 (2011-12-22) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=it_IT.UTF-8 LC_NUMERIC=C [3] LC_TIME=it_IT.UTF-8LC_COLLATE=it_IT.UTF-8 [5] LC_MONETARY=it_IT.UTF-8LC_MESSAGES=it_IT.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base I really don't know why this happensabove all because it seems to me a very very simple statement... Thank to all you for the support -- View this message in context: http://r.789695.n4.nabble.com/R-strange-behaviour-when-building-huge-concatenation-tp4650817p4650970.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] Problems with nls
Hi all, I am encountering the same problem when I use nls to estimate the Bass diffusion model. I used similar code in the previous replies and it works with the data in this original post. However, I got an error when I use my own data. Error in nls(formula = Bass.Model, start = c(p = 0.03, q = 0.4, m = max(CuSale)), : step factor 0.000488281 reduced below 'minFactor' of 0.000976563 Here is my code: Laptop_sale - c(1405, 1863,2027,2669,2938,5275,6595,6943,8621,10905,12420,22400,32380,31600,34900,43163,47838,47592) CuSale - Laptop_sale time - seq_along(Laptop_sale) Bass.Model - Laptop_sale ~ m * ((p + q)^2/p) * (exp(-(p + q) * time)/((q / p) * exp(-(p + q) * time) + 1)^2) Bass.Fit - nls(formula = Bass.Model, start = c(p = 0.03, q = 0.4, m = max(CuSale)), trace = TRUE) Can someone help me to figure out what the problem is? Thank you very much. -- View this message in context: http://r.789695.n4.nabble.com/Problems-with-nls-tp3600409p4650971.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] confidence intervals with glmmPQL
Hi - Thanks for the reply. I provided answers below. Sally Sally_roman sroman at umassd.edu writes: Hi - I am using R version 2.13.0. I have run several GLMMs using the glmmPQL function to model the proportion of fish caught in one net to the total caught in both nets by length. I started with a polynomial regression full model with three length terms: l, l^2, and l^3 (l=length). The length terms and intercept were the fixed effects and the random effect was a paired haul (n=18). m1-glmmPQL(fixed=Proportion~1+Length+second+third,random=~1|Pair, family=binomial,data=species,verbose=T,niter=2, weight=(Experimental+Control)) Why did you set niter=2? That seems like a bad idea (the default is 10; I can imagine increasing it if there are warnings that the fit hasn't converged, but I don't see why you would decrease it). I set niter=2 after I ran the models with the default. All models converged within 2 iterations. For the majority of the models, I ended up with a constant model with no length effect. This isn't quite clear: did you do some kind of stepwise model reduction or AIC-based model selection? I used a step wise backward selection for length terms and terms were removed if they were not significant. The issue I am having is with the confidence intervals that were calculated. For two models the CIs are not symmetrical around the mean proportion from the model. The CIs for the other constant models are symmetrical around the mean. I was wondering if anyone has an idea why this would be or if anyone has any suggestions. Thanks Sally There's not enough detail here to answer. How did you get your confidence intervals? A reproducible example would be helpful. If m1 is the result of a glmmPQL fit, then confint(m1) gives odd results (because it calls confint.default, which doesn't really know what to do with the results of the fit); intervals(m1) might be more what you're looking for. #subsample of data PairSpecies Length ExperimentalControl Proportion second third 2 Monkfish23 0 1 0 529 12167 2 Monkfish27 0 1 0 729 19683 7 Monkfish27 0 2 0 729 19683 8 Monkfish27 0 1 0 729 19683 14 Monkfish28 1 0 1 784 21952 13 Monkfish29 0 1 0 841 24389 14 Monkfish29 0 1 0 841 24389 1 Monkfish30 0 1 0 900 27000 5 Monkfish30 0 2 0 900 27000 18 Monkfish30 1 0 1 900 27000 4 Monkfish31 1 0 1 961 29791 5 Monkfish31 0 1 0 961 29791 11 Monkfish31 0 1 0 961 29791 2 Monkfish32 0 1 0 102432768 11 Monkfish32 0 1 0 102432768 12 Monkfish32 0 1 0 102432768 18 Monkfish32 1 1 0.5 102432768 4 Monkfish34 0 1 0 115639304 17 Monkfish34 0 1 0 115639304 18 Monkfish34 0 1 0 115639304 18 Monkfish35 0 1 0 122542875 1 Monkfish37 0 1 0 136950653 2 Monkfish40 1 0 1 160064000 14 Monkfish40 0 1 0 160064000 18 Monkfish40 1 0 1 160064000 This is my model code #Models #Select trip t-t1 #select species species-subset(t,Species==Monkfish) #define polynomials #2nd order poly second-species$Length^2 #3rd order poly third-species$Length^3 #combine species,second third species-cbind(species,second,third) #backward selection #full model m1-glmmPQL(fixed=Proportion~1+Length+second+third,random=~1|Pair,family=binomial,data=species,verbose=T,niter=2,weight=(Experimental+Control)) summary(m1) #2nd order m2-update(m1, . ~. -third) summary(m2) #linear m3-update(m2, . ~. -second) summary(m3) #constant m4-update(m3, . ~. -Length) summary(m4) I used some code that was passed to me from a colleague who got it from someone else. I tried to go through the code to understand it, but got stuck on a couple of areas. I did not hear back from the original person who wrote the code. Here is the code for a constant model - #CIs get.sel.and.conf.band.catch=function(parm,varm,l.min,l.max,n=200){ lgt-seq(l.min,l.max,length=n) X=sapply(1:length(parm),function(i){lgt^(i-1)}) reg.line=X%*%parm se=apply(X,1,function(x,varm){sqrt(t(x)%*%varm%*%x)},varm)
[R] in par(mfrow=c(1, 2)), how to keep one half plot static and the other half changing
Hi, I'm trying to plot something in the following way and would like if you could help: I'd like in a same plot window, two plots are shown, the left one is a bird-view plot of the whole data, the right half keep changing, i.e., different plots will be shown up on request, so that when I select/click on some where in the left plot, the right plot will be the corresponding plot. What I did is: par(mfrow=c(1,2)) plot(x, y) while(1) { ... pxy - locator(1, type=p) #select data point (dx,dy) based on pxy for a new plot .. plot(dx,dy) } I ended up with the left plot is overwritten by plot(dx,dy). Is there anyway to keep the left side intact while changing plots on the right side? Thanks a lot! Baoqiang __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] binning by frequency
Hello, I'm not sure I ubderstand but, h - hist(b1,brea=100) which.max(h$counts) # max frequency findInterval(b1, h$breaks) Hope this helps, Rui Barradas Em 27-11-2012 14:59, Santosh escreveu: Dear Rxperts, is there way to identify intervals from continuous data (having some kind of a pattern) and then pick the value of most frequency? a1 - round(rnorm(50,mean=0,0.1),2) a2 - round(rnorm(50,mean=1,0.2),1) a3 - round(rnorm(50,mean=5,1),0) a4 - round(rnorm(50,mean=14,4),0) a5 - round(rnorm(50,mean=30,8),0) b1 - rbind(a1,a2,a3,a4,a5) hist(b1,brea=100) # shows intervals and values with varying frequency. unlike the mean values of a1 a5 above, I don't know the nominal values. I would like an algorithm to identify intervals and pick the value with most frequency. I tried cut, split and was not successful. Any suggestions/tips are highly welcome. Thanks and regards, Santosh [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] best HDF5 package: h5r or rhdf5?
What is the current best package for manipulating HDF5 data files? I tried hdf5 a long time ago, but I ran into memory problems. h5r is on CRAN now, and rhdf5 is part of bioconductor. Ideally, I'd like to read simple vectors or tables, either the entire thing or a subset of rows. I don't need much writing support, but it would be nice. Compression is a must, though. Thanks, Johann [[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] glm convergence warning
It could be that for some levels of your independent factor variables (WS, SS), the response is either all zeroes or all ones. Or, for your continuous independent variables (DV, DS), there is a clean break between the zeroes and ones. For example, if all the CIDs are one when DS = 18 but all of the CIDs are zero when DS =20, then there is no single best fit for a logistic model to that relation, the curve could be straight up steep, or gradual and shallow. Do you get convergence if you fit these subset models? glm(CID ~ WS, data=kimu, family=binomial) glm(CID ~ SS, data=kimu, family=binomial) glm(CID ~ DV, data=kimu, family=binomial) glm(CID ~ DS, data=kimu, family=binomial) Can you see the problem when you plot the data? attach(kimu) plot(WS, CID) plot(SS, CID) plot(DV, CID) plot(DS, CID) Jean Anne Schaefer annelsch...@gmail.com wrote on 11/26/2012 08:46:26 PM: Hello, When I run the following glm model: modelresult=glm(CID~WS+SS+DV+DS, data=kimu, family=binomial) I get the following warning messages: 1: glm.fit: algorithm did not converge 2: glm.fit: fitted probabilities numerically 0 or 1 occurred What I am trying to do is model my response variable (CID: correct bird identification) as a function of the predictor variables weather state (WS), sea state (SS), distance from the vessel (DV) and duration of the sighting (DS). I defined both sea state and weather state as factors with three levels (0, 1, or 2). Distance of the vessel values are 100, 80, 60, 40, and 20. Duration of the sighting ranges from 0 to 58 seconds. The output R is giving me is: Deviance Residuals: Min 1Q Median 3Q Max -3.562e-05 -2.100e-08 2.100e-08 2.100e-08 3.632e-05 Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept) -2.000e+02 1.067e+06 0.0001.000 WSf1 7.744e+01 9.086e+04 0.0010.999 WSf2 1.285e+01 6.199e+04 0.0001.000 SSf1-1.042e+02 1.683e+05 -0.0011.000 SSf2-1.859e+02 1.432e+05 -0.0010.999 DV 6.770e-01 9.394e+03 0.0001.000 DS 9.822e+00 1.884e+04 0.0011.000 What do the warning messages mean? Can I still use coefficient estimates and standard error values? Thank you! [[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] Accumulate objects in list after try()
Create an empty list called result before you run the loop. Then store the results of the loop in the list. For example: result - vector(mode=list, length=1000) for(i in 1:1000){ result[[i]] - try(harvest(i)) } Jean mdvaan mathijsdev...@gmail.com wrote on 11/27/2012 12:09:38 AM: Hi, I have written a function harvest and I would like to run the function for each value in a vector c(1:1000). The function returns 4 list objects (obj_1, obj_3, obj_3, obj_4) using the following code at the end of the function: return(list(obj_1 = obj_1, obj_2 = obj_2, obj_3 = obj_3, obj_4 = obj_4)). Since I am connecting with the web in the function and the connection sometimes fails causing errors to occur, I invoke the function as follows: for(i in 1:1000){ result - try(harvest(i)); if(class(result) == try-error) next; } Everything works well accept for the fact that result only stores obj_1, obj_2, obj_3, obj_4 for the last i in the loop. How do I store obj_1, obj_2, obj_3, obj_4 for the first i in the first 4 elements of result, the objects for the second i in the next 4 elements, etc? Thank you very much. [[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 optimization problem
Jorge, First of all, I really do think that questions such as these should be posted directly to R-help. More people will then see it with a greater chance of getting useful replies. I am subscribed to R-help so will see posts. I have cc'ed this reply to R-help so that you may get more answers than I can give you. I know absolutely nothing about transportation problems. For comments see inline. On 27-11-2012, at 00:24, Jorge I Velez wrote: Dear Dr. Hasselman, Please receive my apologies in advance for contacting you directly, but I have seen your replies in R-help and just thought that, perhaps, you could give me a hand. I am facing an optimization problem and unfortunately can not find a way to get around. I will try to explain myself as good as I can. Let us consider an optimization problem in which it is of interest to distribute resources from 2 to 3 points. The costs associated are as follows: Destination From 12 3 Total 1 13 4 300 2 32 3 200 Total150 250 100 500 If X_i (i = 1, 2, ..., 6) is the cost of shipping X units from/to the ith combination (i.e., i = 1 means from shipping from point 1 to destination 1; i = 2 from point 1 to destination 2 and so on), the formulation in R would be as follows: This description is confusing. So x4 means shipping from point to destination 4 (you only have 3 destinations)? require(lpSolve) f - matrix(c(1, 3, 4, 3, 2, 3), ncol = 3, byrow = TRUE) row.rhs - c(300, 200) col.rhs - c(150, 250, 100) row.signs - rep(==, length(row.rhs)) col.signs - rep(==, length(col.rhs)) D - lp.transport(f, min, row.signs, row.rhs, col.signs, col.rhs) D$solution So far so good until this point. However, in addition to spend *all* the resources as above, in my application I would like to set up a couple of more constraints as follows. # row and column constraints x1 + x2 + x3 == 300# row 1 x4 + x5 + x6== 200# row 2 x1 + x4 == 150# col 1 x2 + x5 == 250# col 2 x3 + x6== 100# col 3 x1 + x2 + x3 + x4 + x5 + x6 == 500# all available But these constraints are already satisfied in the solution. Now, if w is a vector representing some constants (the length of w is the number of destinations from which we ship stuff), I would like to include the following three constraints, where r is fixed and known: I don't understand the number of destinations from which we ship stuff. Shouldn't from be to? w1*x1 + w2*x4 == r# col 1 w1*x2 + w2*x5 == r# col 2 w3*x3 + w6*x6 == r# col 3 vector w is length 6 but you only have three destinations (from the initial description) I don't understand what you are doing here. Another constraint that I would like to impose is that, by column, the number of X_i's greater than zero should be at least two. Furthermore, the maximization function should not be the coefficients in the f matrix, but the standard deviation of g = c(l1, l2, l3) where l1 = w1*x1 + w2*x4 l2 = w1*x2 + w2*x5 l3 = w3*x3 + w6*x6 How does this relate to your previous formula? In my application I have up to 100 columns and 50 rows and I am able to include all the constraints but not the number of zeros neither the new function to optimize. Could you please give some advice me on how to do both? I have been reading a bit on quadratic programing as the function to optimize is the standard deviation, but I do not really know how to set up the constraints, let alone the complete problem. From this description I gather that you want to optimize (minimize?) the standard deviations, perhaps a weighted sum? Thank you very much in advance for any help you can provide me. There is far too much unclear about your problem to give any sensible advice, assuming that I have any. Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop with date
Ok, sorry, I thought the more complex details might be confusing and nobody might answer. Here is something which looks more like my real dataframe and also what I want to do with it: That's my data frame: myframe - data.frame (Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012 11:00, 25.09.2012 09:00, 25.09.2012 10:00, 25.09.2012 11:00), Hunger=c(1,1,2,5,1,6) , Longitude=c(8.91617, 8.92700, 8.92711, 8.92722, 8.92733, 8.92744), Latitude=c(54.5485, 54.5410, 54.5412, 54.5413, 54.5414, 54.5424) , AnimalID= c(rep(Ernie))) head(myframe) myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp), %d.%m.%Y %H:%M), tz=GMT) myframe2 - cbind (myframe,myframestime) myframe2$Timestamp - NULL myframesxy - project(cbind(myframe2$Longitude,myframe2$Latitude),+proj=utm +zone=32 +ellps=WGS84) colnames(myframesxy) - c(Long, Lat) myframe3 - cbind(myframe2, myframesxy) myframe3$Longitude - NULL myframe3$Latitude - NULL myframe3 And here is what I want to do with it (make an ltraj element, calculate the brownian bridge homerange and get the kernel area of it - I take the 95 level): library(adehabitatHR) myframe3ltraj - as.ltraj(myframesxy,myframestime, id=myframe3$AnimalID) myframeLiker - liker (myframe3ltraj, sig2=18, rangesig1=c(1,10) ) myframeLiker MyframeBB - kernelbb(myframe3ltraj, sig1=4.6036, sig2=18) kernel.area(MyframeBB, unout=c(km2)) With the only difference that I don't want to calculate the homerange for the complete time but for each day. I could use subset and do it for every day by hand. But I'd have to do it for three month and then again for several animals. So I thought using a loop for each animal to get the results by date would be much faster. Does anybody have any idea? -- View this message in context: http://r.789695.n4.nabble.com/loop-with-date-tp4650961p4650983.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] aggregate() runs out of memory
* Steve Lianoglou znvyvatyvfg.ubarl...@tznvy.pbz [2012-11-26 19:47:25 -0500]: On Monday, November 26, 2012, Sam Steingold wrote: [snip] there is precisely one country for each id. i.e., unique(country) is the same as country[1]. thanks a lot for the suggestion! R result - f[, list(min=min(delay), max=max(delay), count=.N,country=country[1L]), by=share.id] And is it performant? acceptable. It just occurred to me that this is even better: R setkeyv(f, c(share.id, delay)) R result - f[, list(min=delay[1L], max=delay[.N], count=.N, country=country[1L]), by=share.id] this assumes that delays are sorted (like in my example) which, in reality, they are not. thanks for your help! -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://honestreporting.com http://americancensorship.org http://memri.org http://www.memritv.org Illiterate? Write today, for free help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] install the ggplot2 package
I did upgrade but that did not solve the problem -- View this message in context: http://r.789695.n4.nabble.com/install-the-ggplot2-package-tp4650935p4650985.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] calling c function from R
Hello I want to call C function from R. I follow the instruction below using the example of foo.c http://www.stat.umn.edu/~charlie/rc/ I saved the foo.c in my work directory. Then I entered the command R CMD SHLIB foo.c , I got the following message Error: unexpected symbol in R CMD How did it go wrong? Thanks! Regards Shangru Li [[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] error of installing a R package on Win 7
Hi, I am trying to run R 2.15.2 on Win 7. I am trying to run some example R code of the book :Portfolio Optimization with R/Rmetrics I was told that : To install all packages required for the examples of this ebook we recommendthat you install the bundle package ebookPortfolio. This can be done with the following commands in the R environment. If there is no binary package for your operating system, you can install the package from source with the argument type = source. install.packages(ebookPortfolio,repos = c(http://pkg.rmetrics.org,http://cran.r-project.org;),type = getOption(pkgType)) I got : Warning: unable to access index for repository http://pkg.rmetrics.org/src/contribWarning: package ebookPortfolio is not available (for R version 2.15.2)Warning: unable to access index for repository http://pkg.rmetrics.org/bin/windows/contrib/2.15 Is this an error ? I am a new user of R. How to handle it ? How to install ebookPortfolio package ? Any help will be appreciated. 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.
[R] R.dll problem during loading the package lme4
Greetings, I am using R 2.14.1 and while loading package lme4 I am getting the error message: the procedure entry point R_Check_class_etc could not be located in the dynamic link library R.dll. Could anybody help me on this? Thanks and Regards, Roy -- View this message in context: http://r.789695.n4.nabble.com/R-dll-problem-during-loading-the-package-lme4-tp4650982.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] Stuck trying to modify a function
Hi, I have the following data: Path_Number - 5 ID.Path - c(1:Path_Number) # Make vector of ID's. No_of_X - sample(50:550, length(ID.Path), replace=TRUE) # X - split(sample(1:1, sum(No_of_X), replace=TRUE), rep(ID.Path, No_of_X)) Y - lapply(X,function(x) sample(x, round(runif(1, min=10, max=50 X and Y are both lists, and I've made the following function to work on that data as part of a simulation I'm building: Mutate-function(x){ l-0 for(i in x){ l2-0 l-l+1 for(i in x[[l]]){ l2-l2+1 if(runif(1) 0.9) ifelse(runif(1) 0.5, x[[l]][l2] - x[[l]][l2]+1, x[[l]][l2] - x[[l]][l2]-1) } } return(x) } I call this with Effectors-Mutate(X) The function is designed to alter the values of each element in X by either + or - 1 (50:50 chance wether + or -). However Y, elements of which are a subset of the corresponding elements of X, need to be consistent i.e. if a value in X is changed, and that value is part of the Y subset, then the value in Y also needs to be changed. however, since Y is a smaller subset it will not be indexed the same. My idea was to include in the function an if statement that checks if Y contains the value to be changed, removes it, and then after the value in X is changed, put the new value in Y. I attempted this with: Mutate-function(x,y){ l-0 for(i in x){ l2-0 l-l+1 for(i in x[[l]]){ l2-l2+1 if(runif(1) 0.9){ if(x[[l]][l2] %in% y[[l]] == TRUE){ y[[l]]-[which(y[[l]]!=x[[l]][l2])] if(runif(1) 0.5){ x[[l]][l2] - x[[l]][l2]+1 y[[l]]-append(x[[l]][l2]) }else{ x[[l]][l2] - x[[l]][l2]-1 y[[l]]-append(x[[l]][l2]) } } ifelse(runif(1) 0.5, x[[l]][l2] - x[[l]][l2]+1, x[[l]][l2] - x[[l]][l2]-1) } } } return(list(x,y)) } Bit of an eyesore so I've put the altered stuff in bold. I've basically taken what the ifelse statement does in the first function, (which is still there and run if Y does not contain the X value being altered) and broken it down into an if and an else segment with multiple operations in curly braces to accommodate the extra actions needed to alter Y as well as X. This was all I could think of to keep changes between the two in sync, however this does not work when I try to load the function into workspace: Error: unexpected '}' in } I hope someone can point out what it is I've done that isn't working, or a better way to do this. Best Wishes, Ben W. UEA (ENV) The Sainsbury Laboratory. [[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] interactions in GAMs
Hi all, I wonder if it's possible to include a double interaction in a GAM formula. Example: If I do this: mod=gam(energy~s(size, *by=color, by=sex*, k=5) + temperature, ...) I get the interaction betwen size*color and size*sex. But I need size*color*sex, being size a smoother. I've created a new variable (colorsex) which combines all the level of both color (2 levels) and sex (2 level), so that I have a new variable with 4 level. In this case I can do: mod=gam(energy~s(size, *by=colorsex*, k=5) + temperature, ...) What do you think of this approach? In this case, should I also include colorsex (or color*sex) in the parametric term *even if it's not significant*(as it's the case)? Many thanks David -- View this message in context: http://r.789695.n4.nabble.com/interactions-in-GAMs-tp4650987.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] binning by frequency
You might find the binning function in the sm package helpful here. --Mark Lamias From: Santosh santosh2...@gmail.com To: r-help r-help@r-project.org Sent: Tuesday, November 27, 2012 9:59 AM Subject: [R] binning by frequency Dear Rxperts, is there way to identify intervals from continuous data (having some kind of a pattern) and then pick the value of most frequency? a1 - round(rnorm(50,mean=0,0.1),2) a2 - round(rnorm(50,mean=1,0.2),1) a3 - round(rnorm(50,mean=5,1),0) a4 - round(rnorm(50,mean=14,4),0) a5 - round(rnorm(50,mean=30,8),0) b1 - rbind(a1,a2,a3,a4,a5) hist(b1,brea=100) # shows intervals and values with varying frequency. unlike the mean values of a1 a5 above, I don't know the nominal values. I would like an algorithm to identify intervals and pick the value with most frequency. I tried cut, split and was not successful. Any suggestions/tips are highly welcome. Thanks and regards, Santosh [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] interactions in GAMs
David, I think that the colorsex approach is the right one, and colorsex should initially be included as a main effect, because the smooths are centred for factor by variables (see e.g. ?gam.models). Whether you then choose to drop this main effect, as it appears to be non-significant, is a matter of taste (I would tend to leave it in). best, Simon On 27/11/12 16:42, chirleu wrote: Hi all, I wonder if it's possible to include a double interaction in a GAM formula. Example: If I do this: mod=gam(energy~s(size, *by=color, by=sex*, k=5) + temperature, ...) I get the interaction betwen size*color and size*sex. But I need size*color*sex, being size a smoother. I've created a new variable (colorsex) which combines all the level of both color (2 levels) and sex (2 level), so that I have a new variable with 4 level. In this case I can do: mod=gam(energy~s(size, *by=colorsex*, k=5) + temperature, ...) What do you think of this approach? In this case, should I also include colorsex (or color*sex) in the parametric term *even if it's not significant*(as it's the case)? Many thanks David -- View this message in context: http://r.789695.n4.nabble.com/interactions-in-GAMs-tp4650987.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. -- Simon Wood, Mathematical Science, University of Bath BA2 7AY UK +44 (0)1225 386603 http://people.bath.ac.uk/sw283 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using cumsum with 'group by' ?
On Nov 27, 2012, at 14:30 , TheRealJimShady wrote: Thanks everyone for your help. All good now. Once I'd got the data I ended up doing this (replaced with real column names rather than the fakes before). microaeth_data$date-as.Date(microaeth_data$date_time,format=%Y-%m-%d %H:%M:%S) dat2-microaeth_data[order(microaeth_data[,13],microaeth_data[,14]),] dat2$cumsum-ave(dat2$bc,list(dat2$person_id,dat2$date),FUN=cumsum) If someone can be bothered I'd appreciate a breakdown of the final line of code so that I understood what I did, but no problem if not. OK. ave() is originally designed to replace observations by their per-group average. It works by splitting the input vector into groups according to one or more factors, performing FUN on each group, and putting the result back in the original positions. The default for FUN is mean, but it doesn't need to be a scalar function; it also works with a FUN that returns a vector the same length as the input, such as FUN=cumsum. The specification does not seem to allow a list() of grouping factors. It does work, but as it is unauthorised, it might not keep working. Elaborating on the help page example: attach(warpbreaks) ave(breaks,wool,tension) [1] 44.6 44.6 44.6 44.6 44.6 44.6 44.6 44.6 [9] 44.6 24.0 24.0 24.0 24.0 24.0 24.0 24.0 [17] 24.0 24.0 24.6 24.6 24.6 24.6 24.6 24.6 [25] 24.6 24.6 24.6 28.2 28.2 28.2 28.2 28.2 [33] 28.2 28.2 28.2 28.2 28.8 28.8 28.8 28.8 [41] 28.8 28.8 28.8 28.8 28.8 18.8 18.8 18.8 [49] 18.8 18.8 18.8 18.8 18.8 18.8 ave(breaks,wool,tension, FUN=sum) [1] 401 401 401 401 401 401 401 401 401 216 216 216 216 216 216 216 216 216 221 [20] 221 221 221 221 221 221 221 221 254 254 254 254 254 254 254 254 254 259 259 [39] 259 259 259 259 259 259 259 169 169 169 169 169 169 169 169 169 ave(breaks,wool,tension, FUN=cumsum) [1] 26 56 110 135 205 257 308 334 401 18 39 68 85 97 115 150 180 216 36 [20] 57 81 99 109 152 180 195 221 27 41 70 89 118 149 190 210 254 42 68 [39] 87 103 142 170 191 230 259 20 41 65 82 95 110 125 141 169 ave(breaks,list(wool,tension), FUN=cumsum) # not actually supposed to work [1] 26 56 110 135 205 257 308 334 401 18 39 68 85 97 115 150 180 216 36 [20] 57 81 99 109 152 180 195 221 27 41 70 89 118 149 190 210 254 42 68 [39] 87 103 142 170 191 230 259 20 41 65 82 95 110 125 141 169 Thanks James On 23 November 2012 20:06, arun kirshna [via R] ml-node+s789695n4650584...@n4.nabble.com wrote: HI, If that is the case, this should work: dat1-read.table(text= id, x, date 1, 5, 2012-06-05 12:01 1, 10,2012-06-05 12:02 1, 45,2012-06-05 12:03 2, 5, 2012-06-05 12:01 2, 3, 2012-06-05 12:03 2, 2, 2012-06-05 12:05 3, 5, 2012-06-05 12:03 3, 5, 2012-06-05 12:04 3, 8, 2012-06-05 12:05 1, 5, 2012-06-08 13:01 1, 9, 2012-06-08 13:02 1, 3, 2012-06-08 13:03 2, 0, 2012-06-08 13:15 2, 1, 2012-06-08 13:18 2, 8, 2012-06-08 13:20 2, 4, 2012-06-08 13:21 3, 6, 2012-06-08 13:15 3, 2, 2012-06-08 13:16 3, 7, 2012-06-08 13:17 3, 2, 2012-06-08 13:18 ,sep=,,header=TRUE,stringsAsFactors=FALSE) dat1$date-as.Date(dat1$date,format=%Y-%m-%d %H:%M) dat2-dat1[order(dat1[,1],dat1[,3]),] dat2$Cumsum-ave(dat2$x,list(dat2$id,dat2$date),FUN=cumsum) head(dat2) # id x date Cumsum #1 1 5 2012-06-05 5 #2 1 10 2012-06-05 15 #3 1 45 2012-06-05 60 #10 1 5 2012-06-08 5 #11 1 9 2012-06-08 14 #12 1 3 2012-06-08 17 #or with(dat2,aggregate(x,by=list(id=id,date=date),cumsum)) # id datex #1 1 2012-06-055, 15, 60 #2 2 2012-06-05 5, 8, 10 #3 3 2012-06-055, 10, 18 #4 1 2012-06-085, 14, 17 #5 2 2012-06-08 0, 1, 9, 13 #6 3 2012-06-08 6, 8, 15, 17 A.K. - Original Message - From: TheRealJimShady [hidden email] To: [hidden email] Cc: Sent: Friday, November 23, 2012 6:04 AM Subject: Re: [R] Using cumsum with 'group by' ? Hi Arun everyone, Thank you very much for your helpful suggestions. I've been working through them, but have realised that my data is a little more complicated than I said and that the solutions you've kindly provided don't work. The problem is that there is more than one day of data for each person. It looks like this: id x date 1 5 2012-06-05 12:01 1 102012-06-05 12:02 1
[R] Concordant und Discordant Paars of Logistic Regression
Hallo there, can anymore show me how to get results about konkordant und diskordant paars (Sommer-D, Gudman-Krustal-Gama, Kendall-Tau-a) within a logistic regression) in R? Thanks a lot. MT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R strange behaviour when building huge concatenation
You probably hit a buffer limit in X11/xterm on your ubuntu machine with copy and paste. I get that behavior with Putty using your vector or when pasting (long) commands into Putty. If you really prefer copy and paste for this vector then try something like eval(parse(text=scan(clipboard, what=))) Read 2357 items head(p1x) [1] 2 1 0 0 0 7 tail(p1x) [1] 0 0 5 0 4 0 Otherwise you can save your code and source() the file. There is also ESS (Emacs Speaks Statistics) and friends if you want to avoid copy/paste approach. BTW you can use Ctrl-C to get back to command prompt in your R console rather than typing q in your output below. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of angeloimm Sent: Tuesday, November 27, 2012 9:04 AM To: r-help@r-project.org Subject: Re: [R] R strange behaviour when building huge concatenation Hello John It seems correct to me too but in my R console it seems to not be working Here there is what I did: i copied the statement on one row (leaving and removing the final useless semi colomn) i tried to execute it in the R console (in order to open my R console I simply opened a terminal window on my ubuntu machine and I typed R) when I click enter the inserted statement doesn't not run...I simply see the cursor on a new line and this new line starts with + Here there is a little stack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, 0, 0, 2, 0, 7, 0, 1, 2, 1, 1, 1, 0, 0, 1, 5, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 5, 1, 0, 1, 2, 0, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 7, 1, 2, 0, 0, 0, 5, 0, 4, 0)) + + + + + Each time i click enter i go on a new line starting with + Then if i start in tying some character I get an error like this: + + + q + + q Errore: unexpected symbol in: q Sometimes this error (Errore: unexpected symbol in:) appears in the statement execution Here there are my sessionInfo() result: sessionInfo() R version 2.14.1 (2011-12-22) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=it_IT.UTF-8 LC_NUMERIC=C [3] LC_TIME=it_IT.UTF-8LC_COLLATE=it_IT.UTF-8 [5] LC_MONETARY=it_IT.UTF-8LC_MESSAGES=it_IT.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base I really don't know why this happensabove all because it seems to me a very very simple statement... Thank to all you for the support -- View this message in context: http://r.789695.n4.nabble.com/R-strange- behaviour-when-building-huge-concatenation-tp4650817p4650970.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with graphics in gamm4 library
Thank you so much! I really appreciate the rapid response, and I was able to solve my issues with this advice! -- View this message in context: http://r.789695.n4.nabble.com/Help-with-graphics-in-gamm4-library-tp4650908p4650993.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] Fitting and plotting a coxph with survfit, package(surv)
Hi Dear R-users I have a database with 18000 observations and 20 variables. I am running cox regression on five variables and trying to use survfit to plot the survival based on a specific variable without success. Lets say I have the following coxph: library(survival) fit - coxph(Surv(futime, fustat) ~ age + rx, data = ovarian) fit what I am trying to do is plot a survival comparing objects based on rx. Using this plot(survfit(fit, newdata=data.frame(rx =c(1:2), age=c(60)), xscale=365.25, xlab = Years, ylab=Survival)) I get the survival for patients at 60, but is there an option to get a survfit for the patients regardless of the value in variable age? Thanks in advance Maziar Mohaddes M.D. Gothenburg, Sweden [[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] calling c function from R
On 27-11-2012, at 17:21, Li Shangru wrote: Hello I want to call C function from R. I follow the instruction below using the example of foo.c http://www.stat.umn.edu/~charlie/rc/ I saved the foo.c in my work directory. Then I entered the command R CMD SHLIB foo.c , I got the following message Error: unexpected symbol in R CMD How did it go wrong? Thanks! Not how but why? The message is given by R when the syntax is wrong. You didn't do what you were supposed to do according to the instructions. The command R CMD SHLIB foo.c should be executed outside of R. Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] loop command to matrix
Dear UseRs,Extremely sorry for a basic question. I have a matrix of 19 rows and 365 columns. what i want to do is the following...First i want to leave out column number 1 and want to calculate the row wise mean of the remaining columns, which will obviously give me 365 values in one column, and then subtracting these values from the column i left out i.e. col=1 then i want to leave out column 2 and calculate the row wise mean of the remaining columns which includes column 1 too and then subtracting these values from the column i left out i.e. col=2.and then continuing this process the last column. i know a kind of manual way of doing things but its extremely long and laborious.Is there any loop command or shorter way?? thanks in advanceregardseliza [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R strange behaviour when building huge concatenation
Le mardi 27 novembre 2012 à 07:04 -0800, angeloimm a écrit : Hello John It seems correct to me too but in my R console it seems to not be working Here there is what I did: i copied the statement on one row (leaving and removing the final useless semi colomn) i tried to execute it in the R console (in order to open my R console I simply opened a terminal window on my ubuntu machine and I typed R) when I click enter the inserted statement doesn't not run...I simply see the cursor on a new line and this new line starts with + Are you aware that this usually means R is waiting for the end of the command, e.g. because a closing parenthesis is missing? Here there is a little stack of what I see on my terminal: , 1, 1, 2, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 17, 2, 2, 0, 2, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 1, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 7, 0, 0, 1, 0, 0, 3, 0, 0, 2, 4, 0, 1, 0, 0, 0, 0, 2, 1, 0, 4, 2, 0, 0, 1, 3, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 1, 0, 1, 1, 3, 3, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 0, 0, 1, 1, 0, 2, 0, 2, 0, 3, 0, 4, 0, 1, 1, 0, 0, 1, 0, 3, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0, 6, 0, 0, 0, 0, 3, 0, 0, 0, 2, 5, 0, 1, 0, 0, 1, 0, 1, 0, 0, 2, 0, 1, 2, 0, 0, 7, 0, 0, 2, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 8, 0, 0, 5, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 3, 0, 2, 0, 0, 0, 2, 1, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 2, 0, 0, 1, 0, 1, 2, 0, 0, 1, 0, 2, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9, 3, 0, 0, 0, 0, 0, 0, 3, 0, 0, 2, 0, 1, 1, 1, 0, 0, 0, 2, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 4, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0, 1, 0, 0, 6, 0, 0, 0, 0, 1, 0, 0, 2, 6, 0, 1, 0, 0, 0, 0, 2, 0, 7, 0, 1, 2, 1, 1, 1, 0, 0, 1, 5, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 5, 1, 0, 1, 2, 0, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 7, 1, 2, 0, 0, 0, 5, 0, 4, 0)) This command is not the same as the one you posted, it ends with two parentheses... Could you post a whole copy/paste of the output, including the beginning of the command? Have you tried copying the exact contents of the command from your e-mail and check it still produces the errors on your machine? I think you should split the command in two parts, check if they work separately. If one of them does not work, split it again, until you identify either a problematic, possibly invisible char, or a length limit... My two cents + + + + + Each time i click enter i go on a new line starting with + Then if i start in tying some character I get an error like this: + + + q + + q Errore: unexpected symbol in: q Sometimes this error (Errore: unexpected symbol in:) appears in the statement execution Here there are my sessionInfo() result: sessionInfo() R version 2.14.1 (2011-12-22) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=it_IT.UTF-8 LC_NUMERIC=C [3] LC_TIME=it_IT.UTF-8LC_COLLATE=it_IT.UTF-8 [5] LC_MONETARY=it_IT.UTF-8LC_MESSAGES=it_IT.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base I really don't know why this happensabove all because it seems to me a very very simple statement... Thank to all you for the support -- View this message in context: http://r.789695.n4.nabble.com/R-strange-behaviour-when-building-huge-concatenation-tp4650817p4650970.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aggregate() runs out of memory
Hi, On Tue, Nov 27, 2012 at 11:29 AM, Sam Steingold s...@gnu.org wrote: * Steve Lianoglou znvyvatyvfg.ubarl...@tznvy.pbz [2012-11-26 19:47:25 -0500]: [snip] It just occurred to me that this is even better: R setkeyv(f, c(share.id, delay)) R result - f[, list(min=delay[1L], max=delay[.N], count=.N, country=country[1L]), by=share.id] this assumes that delays are sorted (like in my example) which, in reality, they are not. thanks for your help! When you include delay in the call to `setkeyv` as I did above, it sorts low to high w/in each share.id group. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Some questions about chron package..
Hello, I have questions while reviewing chron package(e.g.,chron.R). 1. What is the differences between 3 kinds of function definition ? 1) name lt;- function(... 2) 'name' lt;- function(... 3) name lt;- function(... Do you know Why author used various kinds of definitions ? Is there no functional differences between them ? 2. I don't understand the meaning of the below code: as.chron lt;- function(x, ...) UseMethod(as.chron) as.chron.default lt;- function (x, format, ...) { Could you let me know what is role of UseMethod(as.chron) ? 3. In the following code, chron lt;- function(dates. = NULL, times. = NULL, format = c(dates = m/d/y, times = h:m:s), out.format, origin.) 'dates', 'origin' and 'times' has dot(.) as at the end of word. Do you know the meaning of dots ? 4. Could you introduce me some books on S/R language, especially for understanding of generic functions ? Some interesting packages such as quantmod, xts, zoo, etc., are seems to be coded using generic functions(UseMethod(..)). But I can't easily understand the code. Thanks in advance, [[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] loop command to matrix
Hello, Try x - matrix(1:18, ncol = 6) sapply(seq_len(ncol(x)), function(i) x[, i] - rowMeans(x[, -i])) Hope this helps, Rui Barradas Em 27-11-2012 17:51, eliza botto escreveu: Dear UseRs,Extremely sorry for a basic question. I have a matrix of 19 rows and 365 columns. what i want to do is the following...First i want to leave out column number 1 and want to calculate the row wise mean of the remaining columns, which will obviously give me 365 values in one column, and then subtracting these values from the column i left out i.e. col=1 then i want to leave out column 2 and calculate the row wise mean of the remaining columns which includes column 1 too and then subtracting these values from the column i left out i.e. col=2.and then continuing this process the last column. i know a kind of manual way of doing things but its extremely long and laborious.Is there any loop command or shorter way?? thanks in advanceregardseliza [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop command to matrix
thanks rui!! how can it be that you advise something and it doesn't work :) eliza Date: Tue, 27 Nov 2012 18:14:41 + From: ruipbarra...@sapo.pt To: eliza_bo...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] loop command to matrix Hello, Try x - matrix(1:18, ncol = 6) sapply(seq_len(ncol(x)), function(i) x[, i] - rowMeans(x[, -i])) Hope this helps, Rui Barradas Em 27-11-2012 17:51, eliza botto escreveu: Dear UseRs,Extremely sorry for a basic question. I have a matrix of 19 rows and 365 columns. what i want to do is the following...First i want to leave out column number 1 and want to calculate the row wise mean of the remaining columns, which will obviously give me 365 values in one column, and then subtracting these values from the column i left out i.e. col=1 then i want to leave out column 2 and calculate the row wise mean of the remaining columns which includes column 1 too and then subtracting these values from the column i left out i.e. col=2.and then continuing this process the last column. i know a kind of manual way of doing things but its extremely long and laborious.Is there any loop command or shorter way?? thanks in advanceregardseliza [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop with date
Sorry again, project is part of the rgdal package. Tagmarie -- View this message in context: http://r.789695.n4.nabble.com/loop-with-date-tp4650961p4651005.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] loop command to matrix
HI, May be this helps you: set.seed(5) mat1-matrix(sample(1:400,80,replace=TRUE),ncol=8,nrow=10) split(mat1,col(mat1)) t(do.call(rbind,lapply(lapply(split(mat1,col(mat1)),function(x) cbind(matrix(x,ncol=1),mat1)),function(x){ res1-rowMeans(t(apply(x,1,function(x) x[!(duplicated(x)|duplicated(x,fromLast=TRUE))]))) res-x[,1]-res1 res}))) # 1 2 3 4 5 6 # [1,] -163.0 -129.8571429 152.42857 -52.14286 118.142857 -79.57143 # [2,] 105.14286 16.000 121.14286 -181.71429 -100.571429 50.28571 # [3,] 162.14286 -111.000 -160.14286 -130.42857 121.00 164.42857 # [4,] -123.71429 2.000 -150.0 -239.14286 -9.428571 192.85714 [5,] -146.42857 -73.2857143 -130.42857 -187.57143 230.714286 233.0 # [6,] 57.28571 -171.2857143 -44.42857 -41.0 -12.428571 -89.0 # [7,] 19.14286 -44.8571429 -23.14286 50.0 125.428571 -105.42857 # [8,] 115.71429 152.2857143 187.71429 19.71429 -222.571429 -136.85714 # [9,] 184.85714 0.8571429 -187.71429 -70.0 110.571429 -162.57143 #[10,] -189.85714 143.8571429 195.28571 -59.57143 49.00 -178.42857 7 8 # [1,] 30.14286 123.85714 # [2,] -129.14286 118.85714 # [3,] 139.28571 -185.28571 # [4,] 198.57143 128.85714 # [5,] 257.0 -183.0 # [6,] 144.14286 156.71429 ## [7,] 183.71429 -204.85714 # [8,] -182.57143 66.57143 # [9,] 173.42857 -49.42857 #[10,] 137.0 -97.28571 A.K. - Original Message - From: eliza botto eliza_bo...@hotmail.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Tuesday, November 27, 2012 12:51 PM Subject: [R] loop command to matrix Dear UseRs,Extremely sorry for a basic question. I have a matrix of 19 rows and 365 columns. what i want to do is the following...First i want to leave out column number 1 and want to calculate the row wise mean of the remaining columns, which will obviously give me 365 values in one column, and then subtracting these values from the column i left out i.e. col=1 then i want to leave out column 2 and calculate the row wise mean of the remaining columns which includes column 1 too and then subtracting these values from the column i left out i.e. col=2.and then continuing this process the last column. i know a kind of manual way of doing things but its extremely long and laborious.Is there any loop command or shorter way?? thanks in advanceregardseliza [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aggregate() runs out of memory
* Steve Lianoglou znvyvatyvfg.ubarl...@tznvy.pbz [2012-11-27 12:53:23 -0500]: On Tue, Nov 27, 2012 at 11:29 AM, Sam Steingold s...@gnu.org wrote: * Steve Lianoglou znvyvatyvfg.ubarl...@tznvy.pbz [2012-11-26 19:47:25 -0500]: [snip] It just occurred to me that this is even better: R setkeyv(f, c(share.id, delay)) R result - f[, list(min=delay[1L], max=delay[.N], count=.N, country=country[1L]), by=share.id] this assumes that delays are sorted (like in my example) which, in reality, they are not. When you include delay in the call to `setkeyv` as I did above, it sorts low to high w/in each share.id group. Ah, but then I would have to _sort_ (~n*log(n)) by delay within each ID group, while all I care about is min/max (~n). thanks again! -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://think-israel.org http://truepeace.org http://thereligionofpeace.com http://mideasttruth.com http://www.memritv.org If You Want Breakfast In Bed, Sleep In the Kitchen. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] GLM Coding Issue
Dear all,   I am having a recurring problem when I attempt to conduct a GLM. Here is what I am attempting (with fake data): First, I created a txt file, changed the directory in R (to the proper folder containing the file) and loaded the file: #avoid-read.table(avoid.txt,header=TRUE);avoid # treatment feeding avoid noavoid #1  control nofeed    1    357 #2  control   feed    2    292 #3  control    sat    4    186 #4     proc nofeed   15    291 #5     proc   feed   25    288 #6     proc    sat   17    140 #7      mag nofeed   87    224 #8      mag   feed   34    229 #9      mag    sat   46    151 I then try to attach(avoid) the data, but continue to get an error message ( The following object(s) are masked _by_ .GlobalEnv :), so to fix this, I do the following: #newavoid-avoid #newavoid               (does this do anything?) Lastly, I have several GLM's I wanted to conduct. Please see the following: #model1-glm(cbind(avoid, noavoid)~treatment,data=,family=binomial) #model2=glm(cbind(avoid, noavoid)~feeding, familiy=binomial) #model3=glm(cbind(avoid, noavoid)~treatment+feeding, familiy=binomial) After running model1, I receive the error message Error in model.frame.default(formula = cbind(avoid, noavoid) ~ treatment, :  invalid type (list) for variable 'cbind(avoid, noavoid)'. It would be greatly appreciated if somebody can help me with my coding, as you can see I am a novice but doing my best to learn. I figured if I can get model1 to run, I should be able to figure out the rest of my models. Kind Regards! [[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] Error: R could not find listDescription
Hi, I am running R on Win 7. I got error for listDescription(fPortfolio) Error: could not find function listDescription What do I need to install for solving this ? Any help will be appreciated. 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.
[R] Books for fully understanding internal logics on some packages(quantmod, xts, zoo and chron)
Hello, I'm very interested in using financial time series data, but I'm a beginner of R programming. I'd like to fully understand internal logics on several time-series related packages such as quantmod, xts, zoo, chron, etc. So, I read some books, 'R Cookbook' and 'Art of R Programming' and another simple tutorials. But I still can't understand grammars of the packages codes. Could you recommend some other books or educational materials about S/R language ? Thanks in advance, [[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: R could not find listDescription
Hello, There are two packages with a function listDescription, package fBasics and package fUtilities. You probably need to install one of them, which I can tell. install.packages('fUtilities') # for instance, run this only once library(fUtilities) # load it into R session Hope this helps, Rui Barradas Em 27-11-2012 19:37, Jack Bryan escreveu: Hi, I am running R on Win 7. I got error for listDescription(fPortfolio) Error: could not find function listDescription What do I need to install for solving this ? Any help will be appreciated. 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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: R could not find listDescription
Where did you get the document that tells you to use that code? Does it also tell you to load particular packages? www.rseek.org turns up a listDescription() function in the fBasics package, but that isn't necessarily the one you need for whatever application you're pursuing. Sarah On Tue, Nov 27, 2012 at 2:37 PM, Jack Bryan dtustud...@hotmail.com wrote: Hi, I am running R on Win 7. I got error for listDescription(fPortfolio) Error: could not find function listDescription What do I need to install for solving this ? Any help will be appreciated. Thanks -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error: R could not find listDescription
Hi, Thanks for your reply. I am trying to run R 2.15.2 on Win 7. I am trying to run some example R code of the book :Portfolio Optimization with R/Rmetrics fPortfolio package is included in ebookPortfolio. From the book, I was told that : To install all packages required for the examples of this ebook we recommendthat you install the bundle package ebookPortfolio. This can be done with the following commands in the R environment. If there is no binary package for your operating system, you can install the package from source with the argument type = source. install.packages(ebookPortfolio,repos = c(http://pkg.rmetrics.org,http://cran.r-project.org;),type = getOption(pkgType)) I got : Warning: unable to access index for repository http://pkg.rmetrics.org/src/contribWarning: package ebookPortfolio is not available (for R version 2.15.2)Warning: unable to access index for repository http://pkg.rmetrics.org/bin/windows/contrib/2.15 Is this an error ? I am a new user of R. How to handle it ? How to install ebookPortfolio package ? Any help will be appreciated. Thanks Date: Tue, 27 Nov 2012 14:46:53 -0500 Subject: Re: [R] Error: R could not find listDescription From: sarah.gos...@gmail.com To: dtustud...@hotmail.com CC: r-help@r-project.org Where did you get the document that tells you to use that code? Does it also tell you to load particular packages? www.rseek.org turns up a listDescription() function in the fBasics package, but that isn't necessarily the one you need for whatever application you're pursuing. Sarah On Tue, Nov 27, 2012 at 2:37 PM, Jack Bryan dtustud...@hotmail.com wrote: Hi, I am running R on Win 7. I got error for listDescription(fPortfolio) Error: could not find function listDescription What do I need to install for solving this ? Any help will be appreciated. Thanks -- Sarah Goslee http://www.functionaldiversity.org [[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] binning by frequency
Thanks for your response. Was wondering if there are any R functions/packages to perform optimal binning of continuous data. Thanks, again. Santosh. On Tue, Nov 27, 2012 at 9:09 AM, Mark Lamias mlam...@yahoo.com wrote: You might find the binning function in the sm package helpful here. --Mark Lamias -- *From:* Santosh santosh2...@gmail.com *To:* r-help r-help@r-project.org *Sent:* Tuesday, November 27, 2012 9:59 AM *Subject:* [R] binning by frequency Dear Rxperts, is there way to identify intervals from continuous data (having some kind of a pattern) and then pick the value of most frequency? a1 - round(rnorm(50,mean=0,0.1),2) a2 - round(rnorm(50,mean=1,0.2),1) a3 - round(rnorm(50,mean=5,1),0) a4 - round(rnorm(50,mean=14,4),0) a5 - round(rnorm(50,mean=30,8),0) b1 - rbind(a1,a2,a3,a4,a5) hist(b1,brea=100) # shows intervals and values with varying frequency. unlike the mean values of a1 a5 above, I don't know the nominal values. I would like an algorithm to identify intervals and pick the value with most frequency. I tried cut, split and was not successful. Any suggestions/tips are highly welcome. Thanks and regards, Santosh [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Some questions about chron package..
Hello, Inline. Em 27-11-2012 18:06, 박상규 escreveu: Hello, I have questions while reviewing chron package(e.g.,chron.R). 1. What is the differences between 3 kinds of function definition ? 1) name lt;- function(... 2) 'name' lt;- function(... 3) name lt;- function(... Do you know Why author used various kinds of definitions ? Is there no functional differences between them ? Not that I know of. 2. I don't understand the meaning of the below code: as.chron lt;- function(x, ...) UseMethod(as.chron) as.chron.default lt;- function (x, format, ...) { Could you let me know what is role of UseMethod(as.chron) ? It creates a generic function named as.chron. The next instruction creates the default method for that function. 3. In the following code, chron lt;- function(dates. = NULL, times. = NULL, format = c(dates = m/d/y, times = h:m:s), out.format, origin.) 'dates', 'origin' and 'times' has dot(.) as at the end of word. Do you know the meaning of dots ? I am not sure but I believe the programmer is trying to have arguments with names not conflicting with classes dates and times, or other objects or arguments. 4. Could you introduce me some books on S/R language, especially for understanding of generic functions ? Some interesting packages such as quantmod, xts, zoo, etc., are seems to be coded using generic functions(UseMethod(..)). But I can't easily understand the code. Try this. f - function(x) UseMethod(f) f.default - function(x) print('x' is not of class 'matrix') f.matrix - function(x) print('x' is of class 'matrix') f(1) f(a) f(matrix(1, ncol=1)) f(list(1, 2, 3)) The S3 object oriented programming system is documented in many places, it dispatches based on the class of the first argument so in the third case it's f.matrix that is called and in the others, f.default. But you need only to call f(args) (no suffix). Common examples are print(), summary() and plot(). Any of these functions is generic and methods for each class can and are written to them. You can see which methods there are by running the command methods(print) # 174 in R 2.15.2, new session The syntax for these methods is function.class. Then you can call function that the S3 system will find the appropriate method, if any, or will default to function.default. (Like in as.chron.default) There are free books on CRAN, read them. And google S3 R Programming. Hope this helps, Rui Barradas Thanks in advance, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error: R could not find listDescription
The website given no longer exists. The usual first approach is to contact the author of the books to ask if there's a new location. You could also try installing fPortfolio directly from CRAN: install.packages(fPortfolio) Sarah On Tue, Nov 27, 2012 at 2:57 PM, Jack Bryan dtustud...@hotmail.com wrote: Hi, Thanks for your reply. I am trying to run R 2.15.2 on Win 7. I am trying to run some example R code of the book :Portfolio Optimization with R/Rmetrics fPortfolio package is included in ebookPortfolio. From the book, I was told that : To install all packages required for the examples of this ebook we recommendthat you install the bundle package ebookPortfolio. This can be done with the following commands in the R environment. If there is no binary package for your operating system, you can install the package from source with the argument type = source. install.packages(ebookPortfolio,repos = c(http://pkg.rmetrics.org,http://cran.r-project.org;),type = getOption(pkgType)) I got : Warning: unable to access index for repository http://pkg.rmetrics.org/src/contribWarning: package ‘ebookPortfolio’ is not available (for R version 2.15.2)Warning: unable to access index for repository http://pkg.rmetrics.org/bin/windows/contrib/2.15 Is this an error ? I am a new user of R. How to handle it ? How to install ebookPortfolio package ? Any help will be appreciated. Thanks Date: Tue, 27 Nov 2012 14:46:53 -0500 Subject: Re: [R] Error: R could not find listDescription From: sarah.gos...@gmail.com To: dtustud...@hotmail.com CC: r-help@r-project.org Where did you get the document that tells you to use that code? Does it also tell you to load particular packages? www.rseek.org turns up a listDescription() function in the fBasics package, but that isn't necessarily the one you need for whatever application you're pursuing. Sarah On Tue, Nov 27, 2012 at 2:37 PM, Jack Bryan dtustud...@hotmail.com wrote: Hi, I am running R on Win 7. I got error for listDescription(fPortfolio) Error: could not find function listDescription What do I need to install for solving this ? Any help will be appreciated. Thanks -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error: R could not find listDescription
Hello, Inline. Em 27-11-2012 19:44, Rui Barradas escreveu: Hello, There are two packages with a function listDescription, package fBasics and package fUtilities. You probably need to install one of them, which I can tell. Sorry, it's obviously can't Rui Barradas install.packages('fUtilities') # for instance, run this only once library(fUtilities) # load it into R session Hope this helps, Rui Barradas Em 27-11-2012 19:37, Jack Bryan escreveu: Hi, I am running R on Win 7. I got error for listDescription(fPortfolio) Error: could not find function listDescription What do I need to install for solving this ? Any help will be appreciated. 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] binning by frequency
You might look at the 'mdlp' function in the 'discretization' package. (SPSS has a procedure called 'optimal binning' that uses the 'minimum description length principle' to do the binning.) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh Sent: Tuesday, November 27, 2012 11:59 AM To: r-help Subject: Re: [R] binning by frequency Thanks for your response. Was wondering if there are any R functions/packages to perform optimal binning of continuous data. Thanks, again. Santosh. On Tue, Nov 27, 2012 at 9:09 AM, Mark Lamias mlam...@yahoo.com wrote: You might find the binning function in the sm package helpful here. --Mark Lamias -- *From:* Santosh santosh2...@gmail.com *To:* r-help r-help@r-project.org *Sent:* Tuesday, November 27, 2012 9:59 AM *Subject:* [R] binning by frequency Dear Rxperts, is there way to identify intervals from continuous data (having some kind of a pattern) and then pick the value of most frequency? a1 - round(rnorm(50,mean=0,0.1),2) a2 - round(rnorm(50,mean=1,0.2),1) a3 - round(rnorm(50,mean=5,1),0) a4 - round(rnorm(50,mean=14,4),0) a5 - round(rnorm(50,mean=30,8),0) b1 - rbind(a1,a2,a3,a4,a5) hist(b1,brea=100) # shows intervals and values with varying frequency. unlike the mean values of a1 a5 above, I don't know the nominal values. I would like an algorithm to identify intervals and pick the value with most frequency. I tried cut, split and was not successful. Any suggestions/tips are highly welcome. Thanks and regards, Santosh [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error: R could not find listDescription
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Sarah Goslee Sent: Tuesday, November 27, 2012 12:10 PM To: Jack Bryan Cc: r help Subject: Re: [R] Error: R could not find listDescription The website given no longer exists. The usual first approach is to contact the author of the books to ask if there's a new location. You could also try installing fPortfolio directly from CRAN: install.packages(fPortfolio) Sarah On Tue, Nov 27, 2012 at 2:57 PM, Jack Bryan dtustud...@hotmail.com wrote: Hi, Thanks for your reply. I am trying to run R 2.15.2 on Win 7. I am trying to run some example R code of the book :Portfolio Optimization with R/Rmetrics fPortfolio package is included in ebookPortfolio. From the book, I was told that : To install all packages required for the examples of this ebook we recommendthat you install the bundle package ebookPortfolio. This can be done with the following commands in the R environment. If there is no binary package for your operating system, you can install the package from source with the argument type = source. install.packages(ebookPortfolio,repos = c(http://pkg.rmetrics.org,http://cran.r-project.org;),type = getOption(pkgType)) I got : Warning: unable to access index for repository http://pkg.rmetrics.org/src/contribWarning: package ‘ebookPortfolio’ is not available (for R version 2.15.2)Warning: unable to access index for repository http://pkg.rmetrics.org/bin/windows/contrib/2.15 Is this an error ? I am a new user of R. How to handle it ? How to install ebookPortfolio package ? Any help will be appreciated. Thanks Date: Tue, 27 Nov 2012 14:46:53 -0500 Subject: Re: [R] Error: R could not find listDescription From: sarah.gos...@gmail.com To: dtustud...@hotmail.com CC: r-help@r-project.org Where did you get the document that tells you to use that code? Does it also tell you to load particular packages? www.rseek.org turns up a listDescription() function in the fBasics package, but that isn't necessarily the one you need for whatever application you're pursuing. Sarah On Tue, Nov 27, 2012 at 2:37 PM, Jack Bryan dtustud...@hotmail.com wrote: Hi, I am running R on Win 7. I got error for listDescription(fPortfolio) Error: could not find function listDescription What do I need to install for solving this ? Any help will be appreciated. Thanks -- Sarah Goslee http://www.functionaldiversity.org The website/URL below explains how to install the Rmetrics software from your local CRAN repository. https://wiki.rmetrics.org/install_rmetrics It seemed to work ok for me. Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Books for fully understanding internal logics on some packages(quantmod, xts, zoo and chron)
One place to look would be the archives of the r-sig-finance list. A blog post with suggestions on how to achieve that is: http://www.portfolioprobe.com/2012/01/19/how-to-search-the-r-sig-finance-archives/ Pat On 27/11/2012 19:41, 박상규 wrote: Hello, I'm very interested in using financial time series data, but I'm a beginner of R programming. I'd like to fully understand internal logics on several time-series related packages such as quantmod, xts, zoo, chron, etc. So, I read some books, 'R Cookbook' and 'Art of R Programming' and another simple tutorials. But I still can't understand grammars of the packages codes. Could you recommend some other books or educational materials about S/R language ? Thanks in advance, [[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. -- Patrick Burns pbu...@pburns.seanet.com twitter: @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno') __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with svyglm
I colud not, even without attach the dataset. The thing is, when I use this On Fri, Nov 23, 2012 at 5:56 PM, David Winsemius dwinsem...@comcast.netwrote: On Nov 23, 2012, at 12:08 PM, Pablo Menese wrote: I have this problem. test - svydesign(id=~1,weights=~peso) logit - svyglm(bach ~ job2 + mujer + egp4 + programa + delay + mdeo + str + evprivate, family=binomial,design=test) then appear: Error in svyglm.survey.design(bach ~ job2 + mujer + egp4 + programa + : all variables must be in design= argument I don't know what this mean... I suspect you have attach()-ed your dataset and are expecting regression functions to be aware of your column names. That expectation doesn't always get fulfilled since the authrs of regression packages are expecting dataframe arguments to be supplied. You may want to detach the dataset and use data= arguments in svydesign(). You should forget that you ever heard about the function attach(). -- David Winsemius, MD Alameda, CA, USA [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with svyglm
Sorry, it send it alone... When I use it: logit - glm(bach ~ egp4 + programa, weight=wst7, family=quasibinomial(linklogit)) I reach the same betas that in STATA, but the hypothesis test, the t value, and the std. error is different. I think that the solution can't be so far from 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.
Re: [R] Problems with weight
I can't ... I don't know why but I can't When I use it: logit - glm(bach ~ egp4 + programa, weight=wst7, family=quasibinomial(linklogit)) I reach the same betas that in STATA, but the hypothesis test, the t value, and the std. error is different. I think that the solution can't be so far from this... On Fri, Nov 23, 2012 at 9:49 PM, Anthony Damico ajdam...@gmail.com wrote: from your stata output, it looks like you need to use the survey package in R for step-by-step instructions about how to do this (and comparisons to stata), see http://journal.r-project.org/archive/2009-2/RJournal_2009-2_Damico.pdf once you're ready to run the regression, use svyglm() instead of glm() and drop the weights argument (since it will already be part of the survey design) :) On Fri, Nov 23, 2012 at 3:13 PM, Pablo Menese pmen...@gmail.com wrote: Until a weeks ago I used stata for everything. Now I'm learning R and trying to move. But, in this stage I'm testing R trying to do the same things than I used to do in stata whit the same outputs. I have a problem with the logit, applying weights. in stata I have this output . svy: logit bach job2 mujer i.egp4 programa delay mdeo i.str evprivate (running logit on estimation sample) Survey: Logistic regression Number of strata = 1 Number of obs = 248 Number of PSUs = 248 Population size= 5290.1639 Design df = 247 F( 11,237)= 4.39 Prob F =0. Linearized bach Coef. Std. Err. tPt [95% Conf. Interval] job2 -.4437446 .4385934-1.01 0.313-1.307605.4201154 mujer1.070595 .4169919 2.57 0.011 .24928121.891908 egp4 2-.4839342.539808-0.90 0.371-1.547148.5792796 3-1.288947 .5347344-2.41 0.017-2.342168 -.2357263 4-.8569793 .5106425-1.68 0.095-1.862748.1487898 programa.9694352 .5677642 1.71 0.089-.14884152.087712 delay -1.552582 .5714967-2.72 0.007-2.678211-.426954 mdeo -.7938904 .3727571-2.13 0.034-1.528078 -.0597025 str 2-1.122691 .5731879-1.96 0.051 -2.25165.0062682 3-2.056682 .6350485-3.24 0.001-3.307483 -.8058812 evprivate -1.962431 .5674143-3.46 0.001-3.080018 -.8448431 _cons2.308699 .7274924 3.17 0.002 .87581873.741578 the best that i get in R was: glm(formula = bach ~ job2 + mujer + egp4 + programa + delay + mdeo + str + evprivate, family = quasibinomial(link = logit), weights = wst7) Deviance Residuals: Min1QMedian3Q Max -12.5951 -3.9034 -0.94123.8268 11.2750 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 2.3087 0.7173 3.218 0.00147 ** job2-0.4437 0.4355 -1.019 0.30926 mujer1.0706 0.3558 3.009 0.00290 ** egp4intermediate (iii, iv) -0.4839 0.4946 -0.978 0.32890 egp4skilled manual workers -1.2889 0.5268 -2.447 0.01514 * egp4working class -0.8570 0.4625 -1.853 0.06514 . programa 0.9694 0.4951 1.958 0.05141 . delay -1.5526 0.4878 -3.183 0.00166 ** mdeo-0.7939 0.4207 -1.887 0.06037 . strest. ii -1.1227 0.4809 -2.334 0.02042 * strestr. iii-2.0567 0.5134 -4.006 8.28e-05 *** evprivate -1.9624 0.6490 -3.024 0.00277 ** --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 (Dispersion parameter for quasibinomial family taken to be 23.14436) Null deviance: 7318.5 on 246 degrees of freedom Residual deviance: 5692.8 on 235 degrees of freedom (103 observations deleted due to missingness) AIC: NA Number of Fisher Scoring iterations: 6 Warning message: In summary.glm(logit) : observations with zero weight not used for calculating dispersion this has the same betas but the hypothesis test has differents values... HELP [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Stuck trying to modify a function
Le mardi 27 novembre 2012 à 16:45 +, Benjamin Ward (ENV) a écrit : Hi, I have the following data: Path_Number - 5 ID.Path - c(1:Path_Number) # Make vector of ID's. No_of_X - sample(50:550, length(ID.Path), replace=TRUE) # X - split(sample(1:1, sum(No_of_X), replace=TRUE), rep(ID.Path, No_of_X)) Y - lapply(X,function(x) sample(x, round(runif(1, min=10, max=50 X and Y are both lists, and I've made the following function to work on that data as part of a simulation I'm building: Mutate-function(x){ l-0 for(i in x){ l2-0 l-l+1 for(i in x[[l]]){ l2-l2+1 if(runif(1) 0.9) ifelse(runif(1) 0.5, x[[l]][l2] - x[[l]][l2]+1, x[[l]][l2] - x[[l]][l2]-1) } } return(x) } I call this with Effectors-Mutate(X) The function is designed to alter the values of each element in X by either + or - 1 (50:50 chance wether + or -). However Y, elements of which are a subset of the corresponding elements of X, need to be consistent i.e. if a value in X is changed, and that value is part of the Y subset, then the value in Y also needs to be changed. however, since Y is a smaller subset it will not be indexed the same. My idea was to include in the function an if statement that checks if Y contains the value to be changed, removes it, and then after the value in X is changed, put the new value in Y. I attempted this with: You should really read about vectorizing operations: you can most likely get the same results in R using only a few lines, with a much better performance. runif(length(x)) will directly give you a vector of the needed length, and you can add or subtract 1 from x in one line: new.x - ifelse(runif(length(x)) .5, x + 1, x - 1) y[match(x, y, nomatch=0)] - new.x y - ifelse(y %in% x, new.x[match(y, x)], y) x - new.x This is of course a proof of concept, I'm not sure this is really what you asked for. See below for some debugging of your code. Mutate-function(x,y){ l-0 for(i in x){ l2-0 l-l+1 for(i in x[[l]]){ l2-l2+1 if(runif(1) 0.9){ if(x[[l]][l2] %in% y[[l]] == TRUE){ y[[l]]-[which(y[[l]]!=x[[l]][l2])] Bug is here: ^ You should specify an object to index. if(runif(1) 0.5){ x[[l]][l2] - x[[l]][l2]+1 y[[l]]-append(x[[l]][l2]) }else{ x[[l]][l2] - x[[l]][l2]-1 y[[l]]-append(x[[l]][l2]) } } ifelse(runif(1) 0.5, x[[l]][l2] - x[[l]][l2]+1, x[[l]][l2] - x[[l]][l2]-1) } } } return(list(x,y)) } Bit of an eyesore so I've put the altered stuff in bold. I've basically taken what the ifelse statement does in the first function, (which is still there and run if Y does not contain the X value being altered) and broken it down into an if and an else segment with multiple operations in curly braces to accommodate the extra actions needed to alter Y as well as X. This was all I could think of to keep changes between the two in sync, however this does not work when I try to load the function into workspace: Error: unexpected '}' in } You should have copied the full output. This is only the last error message: once an error happens, the whole syntax is broken and every bracket can trigger an error. Only by looking at the first error you can understand what's the problem. Regards I hope someone can point out what it is I've done that isn't working, or a better way to do this. Best Wishes, Ben W. UEA (ENV) The Sainsbury Laboratory. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with weight
Le mardi 27 novembre 2012 à 18:33 -0300, Pablo Menese a écrit : I can't ... I don't know why but I can't When I use it: logit - glm(bach ~ egp4 + programa, weight=wst7, family=quasibinomial(linklogit)) You were advised to use svyglm(), not glm(). It's usually considered polite to read carefully the anwsers you get to your questions... Regards I reach the same betas that in STATA, but the hypothesis test, the t value, and the std. error is different. I think that the solution can't be so far from this... On Fri, Nov 23, 2012 at 9:49 PM, Anthony Damico ajdam...@gmail.com wrote: from your stata output, it looks like you need to use the survey package in R for step-by-step instructions about how to do this (and comparisons to stata), see http://journal.r-project.org/archive/2009-2/RJournal_2009-2_Damico.pdf once you're ready to run the regression, use svyglm() instead of glm() and drop the weights argument (since it will already be part of the survey design) :) On Fri, Nov 23, 2012 at 3:13 PM, Pablo Menese pmen...@gmail.com wrote: Until a weeks ago I used stata for everything. Now I'm learning R and trying to move. But, in this stage I'm testing R trying to do the same things than I used to do in stata whit the same outputs. I have a problem with the logit, applying weights. in stata I have this output . svy: logit bach job2 mujer i.egp4 programa delay mdeo i.str evprivate (running logit on estimation sample) Survey: Logistic regression Number of strata = 1 Number of obs = 248 Number of PSUs = 248 Population size= 5290.1639 Design df = 247 F( 11,237)= 4.39 Prob F =0. Linearized bach Coef. Std. Err. tPt [95% Conf. Interval] job2 -.4437446 .4385934-1.01 0.313-1.307605.4201154 mujer1.070595 .4169919 2.57 0.011 .24928121.891908 egp4 2-.4839342.539808-0.90 0.371-1.547148.5792796 3-1.288947 .5347344-2.41 0.017-2.342168 -.2357263 4-.8569793 .5106425-1.68 0.095-1.862748.1487898 programa.9694352 .5677642 1.71 0.089-.14884152.087712 delay -1.552582 .5714967-2.72 0.007-2.678211-.426954 mdeo -.7938904 .3727571-2.13 0.034-1.528078 -.0597025 str 2-1.122691 .5731879-1.96 0.051 -2.25165.0062682 3-2.056682 .6350485-3.24 0.001-3.307483 -.8058812 evprivate -1.962431 .5674143-3.46 0.001-3.080018 -.8448431 _cons2.308699 .7274924 3.17 0.002 .87581873.741578 the best that i get in R was: glm(formula = bach ~ job2 + mujer + egp4 + programa + delay + mdeo + str + evprivate, family = quasibinomial(link = logit), weights = wst7) Deviance Residuals: Min1QMedian3Q Max -12.5951 -3.9034 -0.94123.8268 11.2750 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 2.3087 0.7173 3.218 0.00147 ** job2-0.4437 0.4355 -1.019 0.30926 mujer1.0706 0.3558 3.009 0.00290 ** egp4intermediate (iii, iv) -0.4839 0.4946 -0.978 0.32890 egp4skilled manual workers -1.2889 0.5268 -2.447 0.01514 * egp4working class -0.8570 0.4625 -1.853 0.06514 . programa 0.9694 0.4951 1.958 0.05141 . delay -1.5526 0.4878 -3.183 0.00166 ** mdeo-0.7939 0.4207 -1.887 0.06037 . strest. ii -1.1227 0.4809 -2.334 0.02042 * strestr. iii-2.0567 0.5134 -4.006 8.28e-05 *** evprivate -1.9624 0.6490 -3.024 0.00277 ** --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 (Dispersion parameter for quasibinomial family taken to be 23.14436) Null deviance: 7318.5 on 246 degrees of freedom Residual deviance: 5692.8 on 235 degrees of freedom (103 observations deleted due to missingness) AIC: NA Number of Fisher Scoring iterations: 6 Warning message: In summary.glm(logit) : observations with zero weight not used for calculating dispersion this has the same betas but the hypothesis test has differents values... HELP [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __
Re: [R] Stuck trying to modify a function
Ben, You can use the sample() function to randomly add -1, 0, or 1 to each observation, and control for the probability of mutation at the same time. Then you can use the match() function to make sure that any mutations in X are carried through to Y in the same way. I wrote the function to do each list element separately. So a gene in X[[1] and Y[[1]] will be mutated in the same way, but the same gene in X[[2]] and Y[[2]] may be mutated in a different way. Not sure if that is what you want. Mutate - function(x, y, prob.mutate=0.9) { ux - unique(c(x, y)) new.ux - ux + sample(c(-1, 0, 1), size=length(ux), replace=TRUE, prob=c(prob.mutate/2, 1-prob.mutate, prob.mutate/2)) new.x - new.ux[match(x, ux)] new.y - new.ux[match(y, ux)] list(xm=new.x, ym=new.y) } Effectors - lapply(seq(X), function(i) Mutate(X[[i]], Y[[i]])) Jean Benjamin Ward (ENV) b.w...@uea.ac.uk wrote on 11/27/2012 10:45:23 AM: Hi, I have the following data: Path_Number - 5 ID.Path - c(1:Path_Number) # Make vector of ID's. No_of_X - sample(50:550, length(ID.Path), replace=TRUE) # X - split(sample(1:1, sum(No_of_X), replace=TRUE), rep(ID.Path,No_of_X)) Y - lapply(X,function(x) sample(x, round(runif(1, min=10, max=50 X and Y are both lists, and I've made the following function to work on that data as part of a simulation I'm building: Mutate-function(x){ l-0 for(i in x){ l2-0 l-l+1 for(i in x[[l]]){ l2-l2+1 if(runif(1) 0.9) ifelse(runif(1) 0.5, x[[l]][l2] - x[[l]] [l2]+1, x[[l]][l2] - x[[l]][l2]-1) } } return(x) } I call this with Effectors-Mutate(X) The function is designed to alter the values of each element in X by either + or - 1 (50:50 chance wether + or -). However Y, elements of which are a subset of the corresponding elements of X, need to be consistent i.e. if a value in X is changed, and that value is part of the Y subset, then the value in Y also needs to be changed. however, since Y is a smaller subset it will not be indexed the same. My idea was to include in the function an if statement that checks if Y contains the value to be changed, removes it, and then after the value in X is changed, put the new value in Y. I attemptedthis with: Mutate-function(x,y){ l-0 for(i in x){ l2-0 l-l+1 for(i in x[[l]]){ l2-l2+1 if(runif(1) 0.9){ if(x[[l]][l2] %in% y[[l]] == TRUE){ y[[l]]-[which(y[[l]]!=x[[l]][l2])] if(runif(1) 0.5){ x[[l]][l2] - x[[l]][l2]+1 y[[l]]-append(x[[l]][l2]) }else{ x[[l]][l2] - x[[l]][l2]-1 y[[l]]-append(x[[l]][l2]) } } ifelse(runif(1) 0.5, x[[l]][l2] - x[[l]][l2]+1, x[[l]][l2] - x[[l]][l2]-1) } } } return(list(x,y)) } Bit of an eyesore so I've put the altered stuff in bold. I've basically taken what the ifelse statement does in the first function, (which is still there and run if Y does not contain the X value being altered) and broken it down into an if and an else segment with multiple operations in curly braces to accommodate the extra actions needed to alter Y as well as X. This was all I could think of to keep changes between the two in sync, however this does not work when I try to load the function into workspace: Error: unexpected '}' in } I hope someone can point out what it is I've done that isn't working, or a better way to do this. Best Wishes, Ben W. UEA (ENV) The Sainsbury Laboratory. [[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] Some questions about chron package..
1. I am not aware of a difference, and don't know why the various forms were used. 2. That handles identifying the correct function to call based on the types of arguments supplied when the function was called. Read about the S4 object-oriented programming features to learn about method dispatch. 3. It has no syntactic effect. Using periods in parameter names may make it less likely to be the same as names defined by the user, but only if the user cooperates by avoiding that naming convention. 4. There is some quite good documentation supplied with R. You can also look on CRAN (http://www.r-project.org/doc/bib/R-publications.html). Please read the posting guide, and post in plain text. --- 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. 박상규 birdfir...@naver.com wrote: Hello, I have questions while reviewing chron package(e.g.,chron.R). 1. What is the differences between 3 kinds of function definition ? 1) name lt;- function(... 2) 'name' lt;- function(... 3) name lt;- function(... Do you know Why author used various kinds of definitions ? Is there no functional differences between them ? 2. I don't understand the meaning of the below code: as.chron lt;- function(x, ...) UseMethod(as.chron) as.chron.default lt;- function (x, format, ...) { Could you let me know what is role of UseMethod(as.chron) ? 3. In the following code, chron lt;- function(dates. = NULL, times. = NULL, format = c(dates = m/d/y, times = h:m:s), out.format, origin.) 'dates', 'origin' and 'times' has dot(.) as at the end of word. Do you know the meaning of dots ? 4. Could you introduce me some books on S/R language, especially for understanding of generic functions ? Some interesting packages such as quantmod, xts, zoo, etc., are seems to be coded using generic functions(UseMethod(..)). But I can't easily understand the code. Thanks in advance, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Finding values in one column and
All - I have a data frame data.a ID valueA valueB 6 12 12 17 15 14 58 18 16 98 11 12 73 19 20 84 19 14 58 20 14 24 11 12 81 15 16 21 15 14 62 14 12 67 13 14 78 13 17 35 10 13 13 11 15 14 17 18 85 16 15 35 13 9 18 15 16 and a data frame data.b ID valueA valueB 6 84 21 78 14 I'd like to have R find the data.b$ID in data.a$ID and insert the corresponding data.a$valueA and data.a$valueB into the appropriate columns in data.b. How can I do this? Thanks for you help. SR Steven H. Ranney __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R strange behaviour when building huge concatenation
I am currently getting the very strange results that if I paste your orginal data from your first message into my R terminal I get the same errors you do. By the way that ; is not needed in R. If I paste the same data into Rstudo, either into the editor or the console it works fine. If I paste the data into gedit and send it to the console it works fine but if I paste it into the gedita console I get your error messages again. A quick try, pasting it into an R buffer in EMACS seems to work just fine. I have no idea what is happening unless jagat.k.sheth is correct and we are hitting a buffer limit of some kind. I'd suggest getting a decent editor and going with it. Working directly in an R terminal is enough to drive most people crazy. Any of the editiors/ides mentioned above are good with different strengtsts etc. At a guess, Rstudio is the easiest to install and get running on Ubuntu, gedit is pretty easy but you need to install the r gedit plug-in. EMACS as far as I can tell is very good and very powerful but I have not used it enough to really comment on it. In any case one way or the other they can read in the data. I'd also suggest not even 'thinking' about writing a vector statement that long. It would be much easier to do something like write the numbers in a column in a spreadsheet and import from there. There are various ways to do this but the simplist would be to just save the file as a csv file and import it using read.table or read.csv. I'm sorry that I cannot be of more help. Perhaps one of the R gurus can comment on the possible buffer problem. John Kane Kingston ON Canada -Original Message- From: angelo...@gmail.com Sent: Tue, 27 Nov 2012 07:04:13 -0800 (PST) To: r-help@r-project.org Subject: Re: [R] R strange behaviour when building huge concatenation Hello John It seems correct to me too but in my R console it seems to not be working Here there is what I did: i copied the statement on one row (leaving and removing the final useless semi colomn) i tried to execute it in the R console (in order to open my R console I simply opened a terminal window on my ubuntu machine and I typed R) when I click enter the inserted statement doesn't not run...I simply see the cursor on a new line and this new line starts with + Here there is a little stack of what I see on my terminal: , 1, 1, 2, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 17, 2, 2, 0, 2, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 1, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 7, 0, 0, 1, 0, 0, 3, 0, 0, 2, 4, 0, 1, 0, 0, 0, 0, 2, 1, 0, 4, 2, 0, 0, 1, 3, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 1, 0, 1, 1, 3, 3, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 0, 0, 1, 1, 0, 2, 0, 2, 0, 3, 0, 4, 0, 1, 1, 0, 0, 1, 0, 3, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0, 6, 0, 0, 0, 0, 3, 0, 0, 0, 2, 5, 0, 1, 0, 0, 1, 0, 1, 0, 0, 2, 0, 1, 2, 0, 0, 7, 0, 0, 2, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 8, 0, 0, 5, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 3, 0, 2, 0, 0, 0, 2, 1, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 2, 0, 0, 1, 0, 1, 2, 0, 0, 1, 0, 2, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9, 3, 0, 0, 0, 0, 0, 0, 3, 0, 0, 2, 0, 1, 1, 1, 0, 0, 0, 2, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 4, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0, 1, 0, 0, 6, 0, 0, 0, 0, 1, 0, 0, 2, 6, 0, 1, 0, 0, 0, 0, 2, 0, 7, 0, 1, 2, 1, 1, 1, 0, 0, 1, 5, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 5, 1, 0, 1, 2, 0, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 7, 1, 2, 0, 0, 0, 5, 0, 4, 0)) + + + + + Each time i click enter i go on a new line starting with + Then if i start in tying some character I get an error like this: + + + q + + q Errore: unexpected symbol in: q Sometimes this error (Errore: unexpected symbol in:) appears in the statement execution Here there are my sessionInfo() result: sessionInfo() R version 2.14.1 (2011-12-22) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=it_IT.UTF-8 LC_NUMERIC=C [3] LC_TIME=it_IT.UTF-8LC_COLLATE=it_IT.UTF-8 [5] LC_MONETARY=it_IT.UTF-8LC_MESSAGES=it_IT.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base I really don't know why this happensabove all because it seems to me a very very simple statement... Thank to all you for the support -- View this message in context: http://r.789695.n4.nabble.com/R-strange-behaviour-when-building-huge-concatenation-tp4650817p4650970.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
Re: [R] Finding values in one column and
Have a look at ?merge John Kane Kingston ON Canada -Original Message- From: steven.ran...@gmail.com Sent: Tue, 27 Nov 2012 15:17:58 -0700 To: r-help@r-project.org Subject: [R] Finding values in one column and All - I have a data frame data.a IDvalueA valueB 6 12 12 1715 14 5818 16 9811 12 7319 20 8419 14 5820 14 2411 12 8115 16 2115 14 6214 12 6713 14 7813 17 3510 13 1311 15 1417 18 8516 15 3513 9 1815 16 and a data frame data.b IDvalueA valueB 6 84 21 78 14 I'd like to have R find the data.b$ID in data.a$ID and insert the corresponding data.a$valueA and data.a$valueB into the appropriate columns in data.b. How can I do this? Thanks for you help. SR Steven H. Ranney __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Publish your photos in seconds for FREE TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Finding values in one column and
Thanks. Soon after I posted this question, I discovered merge(). Steven H. Ranney On Tue, Nov 27, 2012 at 3:26 PM, John Kane jrkrid...@inbox.com wrote: Have a look at ?merge John Kane Kingston ON Canada -Original Message- From: steven.ran...@gmail.com Sent: Tue, 27 Nov 2012 15:17:58 -0700 To: r-help@r-project.org Subject: [R] Finding values in one column and All - I have a data frame data.a IDvalueA valueB 6 12 12 1715 14 5818 16 9811 12 7319 20 8419 14 5820 14 2411 12 8115 16 2115 14 6214 12 6713 14 7813 17 3510 13 1311 15 1417 18 8516 15 3513 9 1815 16 and a data frame data.b IDvalueA valueB 6 84 21 78 14 I'd like to have R find the data.b$ID in data.a$ID and insert the corresponding data.a$valueA and data.a$valueB into the appropriate columns in data.b. How can I do this? Thanks for you help. SR Steven H. Ranney __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Publish your photos in seconds for FREE TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] GLM Coding Issue
Hi, Comments inline: On Tue, Nov 27, 2012 at 1:00 PM, Craig P O'Connell coconne...@umassd.edu wrote: Dear all, I am having a recurring problem when I attempt to conduct a GLM. Here is what I am attempting (with fake data): First, I created a txt file, changed the directory in R (to the proper folder containing the file) and loaded the file: #avoid-read.table(avoid.txt,header=TRUE);avoid # treatment feeding avoid noavoid #1 control nofeed 1 357 #2 controlfeed 2 292 #3 control sat 4 186 #4 proc nofeed15 291 #5 procfeed25 288 #6 proc sat17 140 #7 mag nofeed87 224 #8 magfeed34 229 #9 mag sat46 151 I then try to attach(avoid) the data, but continue to get an error message ( The following object(s) are masked _by_ .GlobalEnv :), so to fix this, I do the following: #newavoid-avoid #newavoid(does this do anything?) It essentially makes a copy of `avoid` to `newavoid` -- what did you want it to do? That having been said, a good rule of thumb is to never use `attach`, so let's avoid it for now. Lastly, I have several GLM's I wanted to conduct. Please see the following: #model1-glm(cbind(avoid, noavoid)~treatment,data=,family=binomial) #model2=glm(cbind(avoid, noavoid)~feeding, familiy=binomial) #model3=glm(cbind(avoid, noavoid)~treatment+feeding, familiy=binomial) `cbind`-ing doesn't make much sense here. What is your target (y) variable here? are you trying to predict `avoid` or `noavoid` status? Let's assume you were predicting `noavoid` from just `treatment` and `feeding` (I guess you have more data (rows) than you show), you would build a model like so: R model - glm(noavoid ~ treatment + feeding, binomial, avoid) Or to be explicit about the parameters: R model - glm(noavoid ~ treatment + feeding, family=binomial, data=avoid) It would be greatly appreciated if somebody can help me with my coding, as you can see I am a novice but doing my best to learn. I figured if I can get model1 to run, I should be able to figure out the rest of my models. Since you're just getting started, maybe it would be helpful for people writing documentation/tutorials/whatever what needs to be explained better. For instance, I'm curious why you thought to `cbind` in your first glm call, which was: model1-glm(cbind(avoid, noavoid)~treatment,data=,family=binomial) What did you think `cbind`-ing was accomplishing for you? Is there an example somewhere that's doing that as the first parameter to a `glm` call? Also, why just have `data=nothing`? I'm not criticizing, just trying to better understand. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Finding values in one column and
Hi, Try ?merge(), ?join() from library(plyr) data.a-read.table(text= ID valueA valueB 6 12 12 17 15 14 58 18 16 98 11 12 73 19 20 84 19 14 58 20 14 24 11 12 81 15 16 21 15 14 62 14 12 67 13 14 78 13 17 35 10 13 13 11 15 14 17 18 85 16 15 35 13 9 18 15 16 ,sep=,header=TRUE) data.b-read.table(text= ID 6 84 21 78 14 ,sep=,header=TRUE) library(plyr) join(data.a,data.b,by=ID,type=inner) # ID valueA valueB #1 6 12 12 #2 84 19 14 #3 21 15 14 #4 78 13 17 #5 14 17 18 A.K. - Original Message - From: Steven Ranney steven.ran...@gmail.com To: r-help@r-project.org Cc: Sent: Tuesday, November 27, 2012 5:17 PM Subject: [R] Finding values in one column and All - I have a data frame data.a ID valueA valueB 6 12 12 17 15 14 58 18 16 98 11 12 73 19 20 84 19 14 58 20 14 24 11 12 81 15 16 21 15 14 62 14 12 67 13 14 78 13 17 35 10 13 13 11 15 14 17 18 85 16 15 35 13 9 18 15 16 and a data frame data.b ID valueA valueB 6 84 21 78 14 I'd like to have R find the data.b$ID in data.a$ID and insert the corresponding data.a$valueA and data.a$valueB into the appropriate columns in data.b. How can I do this? Thanks for you help. SR Steven H. Ranney __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Finding values in one column and
Come to think of it the plyr package and the data.table packages also offer similar tools. For large merges (joins) I think the data.table package is much faster. John Kane Kingston ON Canada -Original Message- From: steven.ran...@gmail.com Sent: Tue, 27 Nov 2012 15:28:57 -0700 To: jrkrid...@inbox.com Subject: Re: [R] Finding values in one column and Thanks. Soon after I posted this question, I discovered merge(). Steven H. Ranney On Tue, Nov 27, 2012 at 3:26 PM, John Kane jrkrid...@inbox.com wrote: Have a look at ?merge John Kane Kingston ON Canada -Original Message- From: steven.ran...@gmail.com Sent: Tue, 27 Nov 2012 15:17:58 -0700 To: r-help@r-project.org Subject: [R] Finding values in one column and All - I have a data frame data.a IDvalueA valueB 6 12 12 1715 14 5818 16 9811 12 7319 20 8419 14 5820 14 2411 12 8115 16 2115 14 6214 12 6713 14 7813 17 3510 13 1311 15 1417 18 8516 15 3513 9 1815 16 and a data frame data.b IDvalueA valueB 6 84 21 78 14 I'd like to have R find the data.b$ID in data.a$ID and insert the corresponding data.a$valueA and data.a$valueB into the appropriate columns in data.b. How can I do this? Thanks for you help. SR Steven H. Ranney __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Publish your photos in seconds for FREE TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if4 FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plot from a jpeg
Hi all, I know that I can for instance draw to plots in one using nf-layout(matrix(c(1,2),1,2,byrow=FALSE)) Imagine I have 3 files: plot1.jpeg plot2.jpeg plot3.jpeg Anyone knows if I can read them and put on one colum and three rows reading directly from the jpeg file? Many 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.
[R] For-loop,string variables, and the $-operator
Hi all, First time poster, so sorry if I commit some breech of posting etiquette. My problem is as follows. I have a data frame where each column represents a category and the individual data points in each category are binary responses (in this case they are actually 1's and 0's). What I want to extract are the counts for each category and put them in a vector. To do that I used the following: cats-c(cat1,cat2, cat3, ...) c()-counts for(j in cats){ append(counts, sum(data$j)) - counts } However, the 'counts' object only contains 0's after the script runs: counts [1] 0, 0, 0, After replacing various elements in the script to isolate what the issue is, I've discovered the problem stems from data$j. Is there a reason using a variable with the subset operator is bad? Thanks, Allan [[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] CCA plot
Hi, I have a couple questions about fitting environmental (land use factors, plant species presence-absence, and soil variables) constraints to my CCA biplot. 1. After successfully plotting species and site scores in my CCA, I have been trying to insert the biplot arrows of the environmental constraints in my data set using the text() function. When I do that, the plot changes completely. Is there some code or a sample script you could let me know about? 2. I would like to include only the environment constraints that are significant at conf=0.95, but am not sure that I can do that in a CCA biplot. I was hoping that this way I could make my plot less crowded. 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.
[R] code optimisation problem
I'd like to write a function that has a vector and a (pos.) number as inputs and returns what is on the picture below (arithmetic means of (k) consecutive elements of a given vector). The problem is it works too slow for long vectors and i know it can be done without for loop. However, i've got no idea how. Can anyone help me with that? f1 - function(v,k) { n - length(v) z - (n-k+1) for (i in k:n) { v[i-k+1] - sum(v[(i-k+1):i]) } v - v[1:(n-k+1)] v - v/k return (v) } http://r.789695.n4.nabble.com/file/n4651030/Untitled.png -- View this message in context: http://r.789695.n4.nabble.com/code-optimisation-problem-tp4651030.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.