Re: [R] error using nls with logistic derivative
On Apr 17, 2012, at 06:23 , Francisco Mora Ardila wrote: Hi I´m trying to fit a nonlinear model to a derivative of the logistic function y = a/(1+exp((b-x)/c)) (this is the parametrization for the SSlogis function with nls) The derivative calculated with D function is: logis- expression(a/(1+exp((b-x)/c))) D(logis, x) a * (exp((b - x)/c) * (1/c))/(1 + exp((b - x)/c))^2 So I enter this expression in the nls function: ratelogis - nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, start=list(a = 21.16322, b = 8.83669, c = 2.957765), ) The data is: Y [1] 5.5199668 1.5234525 3.3557000 6.7211704 7.4237955 1.9703127 [7] 4.3939336 -1.4380091 3.2650180 3.5760906 0.2947972 1.0569417 X [1] 1 0 0 4 3 5 12 10 12 100 100 100 The problem is that I got the next error: Error en nls(Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2, : step factor 0.000488281 reduced below 'minFactor' of 0.000976563 I trien to change the minFactor using the control argument inside nls control=nls.control(maxiter=50, tol=1e-5, minFactor = 1/2048 but got a new error message: Error en nls(Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2, : step factor 0.000244141 reduced below 'minFactor' of 0.000488281 So it seems that as I modify minFactor, the step factor reduces also and I can never reach a solution. Does anybody Know what am I doing wrong? Is there a problem with the formula? How can I solve it? I tried some suggestions on R-help related topics but did not work. (Please don't send private messages. I don't do free consulting outside of the mailing lists.) With nls(), there's really no substitute for good data and good starting values. Did you actually try plotting those data? At best, they are extremely noisy. How did you obtain the starting values? They seem remarkably accurate for something that fits data so poorly. What is happening is that the algorithm shoots off into a region of the parameter space where it can't make any progress: ratelogis - nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2,+ start=list(a = 21.16322, b = 8.83669, c = 2.957765),+ trace=TRUE) 151.098 : 21.163220 8.836690 2.957765 127.1149 : 103.49326 11.43274 20.29663 111.344 : 833.02386 -45.86244 140.32985 111.3375 : 978.97214 -76.20571 159.90833 111.3374 : 1097.1376 -101.6771 174.2037 111.3228 : 1179.8451 -119.7416 183.3794 Notice that the b parameter which is supposed to be the maximum point starts off well to the right of the position of the largest Y values, then shoots into large negative values. With a little eyeballing, I can do better: ratelogis - nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, + start=list(a = 40, b = 3.5, c = 10),trace=T) 139.5173 : 40.0 3.5 10.0 97.28614 : 26.513424 4.052639 2.267709 81.53127 : 32.384910 3.473411 2.307504 65.11387 : 39.53542 3.01097 2.07678 50.66328 : 36.223529 2.590102 1.133965 50.50921 : 35.984466 2.565698 1.067731 50.50162 : 36.149993 2.573420 1.081673 50.50145 : 36.129962 2.572195 1.079504 50.50144 : 36.133656 2.572402 1.079862 50.50144 : 36.133061 2.572368 1.079803 However, the fit isn't exactly stellar. Try this: X - c(1, 0, 0, 4, 3, 5, 12, 10, 12, 100, 100, 100) Y - c(5.5199668, 1.5234525, 3.3557, 6.7211704, 7.4237955, 1.9703127, 4.3939336, -1.4380091, 3.265018, 3.5760906, 0.2947972, 1.0569417) plot(X,Y) ratelogis - nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, start=list(a = 40, b = 3.5, c = 10),trace=T) x0 - seq(0,100,,1000) lines(x0,predict(ratelogis,newdata=data.frame(X=x0))) lines(x0,evalq(a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2,envir=list(a = 21.16322, b = 8.83669, c = 2.957765, X=x0)), lty=dashed) -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Summary about how to divide data by week
Thank you to Ozgur, who gave me the hints for an easy solution. There are the commands that work for my case: mean(my_dataframe$Freq[my_dataframe$month == 5 my_dataframe$day %in% c(1:7)]) mean(my_dataframe$Freq[my_dataframe$month == 5 my_dataframe$day %in% c(8:14)]) ... Stefano Sofia PhD This is the original message: Dear list users, I have a data frame as below specified. From the 1st of May to the 30th of September of several years (e.g. from 2004 to 2011) I have a frequency of accidents. I need the mean of accidents divided by weeks (i.e. the mean of accidents from the 1st to the 7th of May of all the years, from the 8th to the 14th of May, ..., from the 29th to the 31st of May, from the 1st to the 7th of July and so on). Is there an easy way to do that? Thank you for your help Stefano Sofia yearmonthday Freq 1 2004 51 3 2 2004 5 10 2 3 2004 5 11 2 4 2004 5 12 2 5 2004 5 13 3 6 2004 5 14 0 7 2004 5 15 2 8 2004 5 16 1 9 2004 5 17 6 10 20045 18 1 11 20045 19 2 12 20045 2 4 13 20045 20 0 14 20045 21 0 15 20045 22 3 16 20045 23 4 17 20045 24 3 18 20045 25 2 19 20045 26 2 20 20045 27 0 21 20045 28 2 22 20045 29 3 23 20045 3 2 24 20045 30 3 25 20045 31 7 26 20045 4 1 27 20045 5 2 28 20045 6 3 29 20045 7 3 30 20045 8 1 31 20045 9 1 32 20046 1 3 33 20046 10 1 34 20046 11 3 35 20046 12 1 36 20046 13 3 37 20046 14 1 38 20046 15 1 ... AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere informazioni confidenziali, pertanto è destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si è il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed urgenza, la risposta al presente messaggio di posta elettronica può essere visionata da persone estranee al destinatario. IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Can a matrix have 'list' as rows/columns?
That is a fine section of 'The R Inferno' but I don't think it applies to your problem. The answer to your question in the subject line is obviously yes. It happens when the matrix (or more generally any array) is of mode list. A useful example of this is in Circle 8.1.8. http://www.burns-stat.com/pages/Tutor/R_inferno.pdf In your case you can do things like: M[[1,1]] [1] aaa M[[1,2]] [1] bbb M[[2,2]] [1] 0.274498 But not: M[[,2]] Error in M[[, 2]] : invalid subscript type 'symbol' Pat On 17/04/2012 05:13, Worik R wrote: After a lot of processing I get a matrix into M. I expected each row and column to be a vector. But it is a list. R-Inferno says... Arrays (including matrices) can be subscripted with a matrix of positive numbers. The subscripting matrix has as many columns as there are dimensions in the array—so two columns for a matrix. The result is a vector (not an array) containing the selected items. My version of R: version.string R version 2.12.1 (2010-12-16) Here is an example... Qm- c(aaa, bbb, ccc) DF- data.frame(Name=sample(Qm, replace=TRUE, size=22), Value=runif(22), stringsAsFactors=FALSE) M- sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,])}, DF) class(M) [1] matrix class(M[,1]) [1] list class(M[1,]) [1] list M aaa bbb ccc Name aaa bbbccc Value 0.4702648 0.274498 0.5529691 DF Name Value 1 ccc 0.99948920 2 aaa 0.51921281 3 aaa 0.10803943 4 aaa 0.82265847 5 ccc 0.83237260 6 bbb 0.88250933 7 aaa 0.41836131 8 aaa 0.66197290 9 ccc 0.01911771 10 ccc 0.4699 11 bbb 0.35719884 12 ccc 0.86274858 13 bbb 0.57528579 14 aaa 0.12452158 15 aaa 0.44167731 16 aaa 0.11660019 17 ccc 0.55296911 18 aaa 0.12796890 19 bbb 0.44595741 20 bbb 0.93024768 21 aaa 0.47026475 22 bbb 0.27449801 [[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] Approximately how big is an installation of all packages.
Thanks. That's a great help! KW On Apr 16, 2012, at 1:08 PM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: Note that the answer also depends on the platform (Uwe probably has two archs on Windows and no debug info in his DLLs), whether you byte-compile the packages, the optimization flags you use when compiling CRAN is around 3 - 4GB depending on the platform. Specifically, 3.5GB for x86_64 Linux with debug info. BioC software plus all the data packages needed to check the software packages is 20GB on that system. On 16/04/2012 17:52, Uwe Ligges wrote: On 16.04.2012 16:16, Keith Weintraub wrote: Can you tell me the size of those 3 packages separately? These are 5000 packages. If you want to kniow, why don't you try out? I have them in one library only. Uwe Ligges That is CRAN, BioC software, BioC data. If you can only give me CRAN vs the rest that's fine too. Whatever is easiest. Thanks, KW -- On Apr 16, 2012, at 9:12 AM, Uwe Ligges wrote: On 16.04.2012 00:16, Keith Weintraub wrote: Folks, If you know the answer great. If you can tell me which command to use to find out that information please let me know. If this is the wrong forum, my apologies. What is your definition of all packages? If you mean almost all CRAN and BioC software packages plus few BioC data packages, then I see an installed size of roughly 8Gb under Windows. Uwe Ligges Thanks, KW -- [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error using nls with logistic derivative
On Tue, Apr 17, 2012 at 12:23 AM, Francisco Mora Ardila fm...@oikos.unam.mx wrote: Hi I´m trying to fit a nonlinear model to a derivative of the logistic function y = a/(1+exp((b-x)/c)) (this is the parametrization for the SSlogis function with nls) The derivative calculated with D function is: logis- expression(a/(1+exp((b-x)/c))) D(logis, x) a * (exp((b - x)/c) * (1/c))/(1 + exp((b - x)/c))^2 So I enter this expression in the nls function: ratelogis - nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, start=list(a = 21.16322, b = 8.83669, c = 2.957765), ) The data is: Y [1] 5.5199668 1.5234525 3.3557000 6.7211704 7.4237955 1.9703127 [7] 4.3939336 -1.4380091 3.2650180 3.5760906 0.2947972 1.0569417 X [1] 1 0 0 4 3 5 12 10 12 100 100 100 The problem is that I got the next error: Error en nls(Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2, : step factor 0.000488281 reduced below 'minFactor' of 0.000976563 Try alg = plinear noting that we must drop the linear coefficient a from the formula and starting values and .lin in the output represents a: ratelogis - nls(Y ~ (exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, start=list(b = 8.83669, c = 2.957765), alg = plinear ) ratelogis plot(X,Y) o - order(X) lines(X[o], fitted(ratelogis)[o], col = red) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] packages install dependencies
Hi Uwe Thanks for your answer. I tried to install the packages marginalmodelplots_0.4.2.tar.gz from a local repository /home/bioadm/install/R_packages/120416/ using your suggestion (i.e. install.packages(, contriburl=/home/joel/RPacks)) I paste below the command install.packages(/home/bioadm/install/R_packages/120416/marginalmodelplots_0.4.2.tar.gz, repos=NULL, dependencies= TRUE, type=source, contriburl=/home/bioadm/install/R_packages/120416/) Warning: unable to access index for repository /home/bioadm/install/R_packages/120416/ Warning message: In install.packages(/home/bioadm/install/R_packages/120416/marginalmodelplots_0.4.2.tar.gz, : package â/home/bioadm/install/R_packages/120416/marginalmodelplots_0.4.2.tar.gzâ is not available For info this package depends of the locfit package. What should I do ? Thanks in advance Joël Masciocchi -Message d'origine- De : Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Envoyé : lundi 16 avril 2012 19:06 À : FRsr BioInfo Cc : r-help@r-project.org Objet : Re: [R] packages install dependencies On 16.04.2012 15:41, mail.bioi...@fr.netgrs.com wrote: Hello R-Members I have to install several R packages on a Unix server which doesn't have internet connection. I downloaded some packages manually and I installed it from source using the command R CMD INSTALL and it's work but in some cases I can't install the package because of the dependencies. So I download all the R packages into a directory for example /home/joel/RPacks. Is it possible to configure the R commands (i.e. CMD INSTALL command or install.packages() function) in order that R looks for dependencies in my repository. install.packages(, contriburl=/home/joel/RPacks) Uwe Ligges Thanks in advance, Best Regards - Cordialement, Joël --- Joel Masciocchi Bioinformatician Informatics Department Institut de Recherches SERVIER (I.d.R.S) 125, chemin de Ronde 78290 CROISSY-SUR-SEINE - FRANCE [[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] Test-Predict R survival analysis
Hi, I'm trying to use the R Survival analysis on a windows 7 system. The input data format is described at the end of this mail. 1/ I tried to perform a survival analysis including stratified variables using the following formula. cox.xtab_miR=coxph(Surv(time, status) ~ miR + strata(sex,nbligne, age), data=matrix) and obtain the following error message Warning message: In fitter(X, Y, strats, offset, init, control, weights = weights, : Ran out of iterations and did not converge Is this due to the model (error in formula) or is the number of stratified variables fixed? 2/ I wanted to used the predict information to create a survival model based on the same parameter as previously described - (Surv(time, status) ~ miR + strata(sex,nbligne, age) - and than testing it on the predict set of data.. I there any way to do that? Is there any way to plot this? Many thanks for your help. Kind regards / Sandrine Input data matrix $time [1] 58.14 17.10 14.71 17.43 16.00 7.00 7.50 8.00 8.00 9.85 20.00 9.14 [13] 3.85 5.00 4.00 13.00 15.71 32.00 33.00 8.00 36.00 8.00 42.00 31.43 [25] 29.71 80.00 25.14 40.00 25.14 30.00 12.00 10.71 28.00 4.57 9.00 15.71 [37] 6.85 39.85 6.57 42.00 16.28 14.00 6.71 12.57 65.14 35.28 33.85 52.00 [49] 24.57 32.71 7.28 70.00 7.28 6.71 23.00 10.00 7.14 19.86 55.42 40.28 [61] 21.28 31.14 34.00 44.00 7.28 70.71 7.57 44.85 56.00 21.14 91.71 $status [1] 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 0 [26] 0 0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0 [51] 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 $miR [1]836.12000458.64000442.03000125.47000 2914.44000 [6]114.53000 8091.1 2645.75000 3269.46000 1168.67000 [11] 3541.42000508.79000177.34000 4705.9 6677.3 [16] 4223.73000787.69265415.92000100.57000 10.58000 [21] 42.78000 29.36000 13.47000 1.0 13.08000 [26] 67.89000 16.09000 49.01000 75.78000 26.36000 [31] 6.36000 31.64173218.0 15699.17000 3215.71000 [36]294.98000 106678.83000554.79000198.53000161.64000 [41] 2481.18283 1093.7 5496.18000144.28000 12.5 [46] 79.49000 45.64000 31.07000 8.12000 15.27000 [51] 15.65780 18.0 2172.67000345.35000 3256.34000 [56] 3332.58000296.32000 7889.62000936.5458.6 [61] 1212.32000 2762.48000 1047.78000 3193.43000319.27000 [66] 16.29000 69.31000 84.11000 35.43000 4.98000 [71] 41.75000 $nbligne [1] 1 2 3 3 2 4 2 3 2 3 3 2 3 4 3 2 2 2 2 3 3 3 2 2 NA [26] 2 2 2 3 4 5 2 1 2 2 3 2 2 3 3 3 2 2 1 6 3 2 1 2 2 [51] 1 2 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 2 2 2 $sex [1] 1 2 1 1 1 2 1 2 1 1 1 2 1 1 1 2 2 1 1 1 1 2 2 1 1 [26] 1 1 1 1 1 1 2 1 2 2 1 1 2 2 1 2 1 1 1 1 1 2 1 2 2 [51] 1 1 1 2 1 1 1 1 1 1 2 1 2 1 2 1 1 1 2 2 2 $age [1] 77.00 64.00 50.00 57.00 60.00 53.00 51.00 57.69 53.50 77.37 65.39 78.10 [13] 51.38 73.22 57.33 53.39 44.68 55.94 58.00 47.00 62.00 48.00 55.00 55.00 [25] 56.00 22.00 77.00 56.09 65.63 48.00 61.00 73.99 68.71 47.34 71.60 61.16 [37] 77.94 73.21 66.45 67.69 48.84 70.96 74.43 65.41 64.73 77.87 58.70 65.00 [49] 73.34 75.64 87.86 57.23 60.43 68.27 64.57 51.12 61.91 60.12 84.54 53.99 [61] 33.88 75.95 43.29 67.38 67.80 66.30 52.36 58.81 69.35 80.47 54.38 $predict [1] TRAINING TRAINING TRAINING TRAINING TRAINING TRAINING TRAINING TRAINING [9] TRAINING TRAINING TRAINING PREDICT PREDICT PREDICT PREDICT PREDICT [17] PREDICT PREDICT TRAINING TRAINING TRAINING TRAINING TRAINING TRAINING [25] TRAINING TRAINING TRAINING TRAINING TRAINING PREDICT PREDICT PREDICT [33] PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT [41] PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT [49] PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT [57] PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT [65] PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT PREDICT Levels: PREDICT TRAINING -- Sandrine Imbeaud INSERM, UMR U-674, IUH Université Paris Descartes Génomique Fonctionnelle des tumeurs solides 27 rue Juliette Dodu F75010 Paris, France TEL: +33 (0)1 53 72 51 98 FAX: +33 (0)1 53 72 51 92 MOBILE: +33 (0)6 12 69 80 29 http://www.inserm-u674.net/ [[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] Can a matrix have 'list' as rows/columns?
On Apr 17, 2012, at 12:13 AM, Worik R wrote: After a lot of processing I get a matrix into M. I expected each row and column to be a vector. But it is a list. This behavior is not the result of limitation in how R's sapply might have processed a purely numeric set of results, but is because you (probably) returned a hetergeneous set of classes rom you inner function. Assuming that last is actually function(x){tail,1}, then the structure of M is str(M) List of 6 $ : chr aaa $ : num 0.224 $ : chr bbb $ : num 0.768 $ : chr ccc $ : num 0.904 - attr(*, dim)= int [1:2] 2 3 - attr(*, dimnames)=List of 2 ..$ : chr [1:2] Name Value ..$ : chr [1:3] aaa bbb ccc Had the result been a more homogeneous collection, I sapply would have returned an array of atomic numeric vectors. Try just returning a number: M2 - sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,Value])}, DF) class(M) [1] numeric str(M2) Named num [1:3] 0.6184 0.0446 0.3605 - attr(*, names)= chr [1:3] aaa bbb ccc -- David. R-Inferno says... Arrays (including matrices) can be subscripted with a matrix of positive numbers. The subscripting matrix has as many columns as there are dimensions in the arrayso two columns for a matrix. The result is a vector (not an array) containing the selected items. My version of R: version.string R version 2.12.1 (2010-12-16) Here is an example... Qm - c(aaa, bbb, ccc) DF - data.frame(Name=sample(Qm, replace=TRUE, size=22), Value=runif(22), stringsAsFactors=FALSE) M - sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,])}, DF) class(M) [1] matrix class(M[,1]) [1] list class(M[1,]) [1] list M aaa bbb ccc Name aaa bbbccc Value 0.4702648 0.274498 0.5529691 DF Name Value 1 ccc 0.99948920 2 aaa 0.51921281 3 aaa 0.10803943 4 aaa 0.82265847 5 ccc 0.83237260 6 bbb 0.88250933 7 aaa 0.41836131 8 aaa 0.66197290 9 ccc 0.01911771 10 ccc 0.4699 11 bbb 0.35719884 12 ccc 0.86274858 13 bbb 0.57528579 14 aaa 0.12452158 15 aaa 0.44167731 16 aaa 0.11660019 17 ccc 0.55296911 18 aaa 0.12796890 19 bbb 0.44595741 20 bbb 0.93024768 21 aaa 0.47026475 22 bbb 0.27449801 [[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. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] loss of information in pdf plots
Hi there is it possible that pdfs generated using the pdf() function with default settings leads to loss of information? I was plotting copy number changes from Agilent 180k data in form of rectangles (rect()) while each rectangle represents one region of copy number change. When plotting into a pdf I noticed that some very small rectangles do not appear (even after extensive zooming) in the pdf using the pdf() function. But they do when writing the screen output into a pdf using the GUI. Does anyone have some advice on this how I can plot pdfs without losing information? Best wishes Kristian R version 2.14.0 (2011-10-31) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] CGHregions_1.12.0 CGHcall_2.14.0CGHbase_1.12.0marray_1.32.0 [5] limma_3.10.3 Biobase_2.14.0DNAcopy_1.28.0impute_1.28.0 loaded via a namespace (and not attached): [1] tools_2.14.0 Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 [[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] system command to a specific shell (bash)
On 17.04.2012 01:26, MacQueen, Don wrote: I believe that shell() was superceded by system(), quite a long time ago. Not really, under Windows, shell() will start a shell while system() won't. Uwe Ligges However, I get this: foo- system('printenv',intern=TRUE) ; foo[grepl('SHELL',foo)] [1] SHELL=/bin/tcsh XTERM_SHELL=/bin/tcsh And tcsh is my login shell, i.e., as specified for my account at the OS level. To me, this implies that you should get bash by default if your account is configured for bash, but I can't know for certain. -Don __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] loss of information in pdf plots
Hi Hi there is it possible that pdfs generated using the pdf() function with default settings leads to loss of information? I was plotting copy number changes from Agilent 180k data in form of rectangles (rect()) while each rectangle represents one region of copy number change. When plotting into a pdf I noticed that some very small rectangles do not appear (even after extensive zooming) in the pdf using the pdf() function. But they do when writing the screen output into a pdf using the GUI. Does anyone have some advice on this how I can plot pdfs without losing information? I am not sure if it has something to do with dingbats but you could try it. Set useDingbats=FALSE in you pdf call. Regards Petr Best wishes Kristian R version 2.14.0 (2011-10-31) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] CGHregions_1.12.0 CGHcall_2.14.0CGHbase_1.12.0marray_1.32.0 [5] limma_3.10.3 Biobase_2.14.0DNAcopy_1.28.0impute_1.28.0 loaded via a namespace (and not attached): [1] tools_2.14.0 Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 [[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] packages install dependencies
On 17.04.2012 10:57, mail.bioi...@fr.netgrs.com wrote: Hi Uwe Thanks for your answer. I tried to install the packages marginalmodelplots_0.4.2.tar.gz from a local repository /home/bioadm/install/R_packages/120416/ using your suggestion (i.e. install.packages(, contriburl=/home/joel/RPacks)) I paste below the command install.packages(/home/bioadm/install/R_packages/120416/marginalmodelplots_0.4.2.tar.gz, repos=NULL, dependencies= TRUE, type=source, contriburl=/home/bioadm/install/R_packages/120416/) Warning: unable to access index for repository /home/bioadm/install/R_packages/120416/ Warning message: In install.packages(/home/bioadm/install/R_packages/120416/marginalmodelplots_0.4.2.tar.gz, : package â/home/bioadm/install/R_packages/120416/marginalmodelplots_0.4.2.tar.gzâ is not available Then you do not have a repository. Its defintiion is that it contains a PACKAGES file which it obviously does not contain. Nevertheless, you can create a PACKAGE file via function write_PACKAGES() in package tools. Uwe Ligges For info this package depends of the locfit package. What should I do ? Thanks in advance Joël Masciocchi -Message d'origine- De : Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Envoyé : lundi 16 avril 2012 19:06 À :FRsr BioInfo Cc : r-help@r-project.org Objet : Re: [R] packages install dependencies On 16.04.2012 15:41, mail.bioi...@fr.netgrs.com wrote: Hello R-Members I have to install several R packages on a Unix server which doesn't have internet connection. I downloaded some packages manually and I installed it from source using the command R CMD INSTALL and it's work but in some cases I can't install the package because of the dependencies. So I download all the R packages into a directory for example /home/joel/RPacks. Is it possible to configure the R commands (i.e. CMD INSTALL command or install.packages() function) in order that R looks for dependencies in my repository. install.packages(, contriburl=/home/joel/RPacks) Uwe Ligges Thanks in advance, Best Regards - Cordialement, Joël --- Joel Masciocchi Bioinformatician Informatics Department Institut de Recherches SERVIER (I.d.R.S) 125, chemin de Ronde 78290 CROISSY-SUR-SEINE - FRANCE [[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] loss of information in pdf plots
Thanks Petr. Unfortunately this does not help. Kristian Am 17.04.2012 um 14:18 schrieb Petr PIKAL: Hi Hi there is it possible that pdfs generated using the pdf() function with default settings leads to loss of information? I was plotting copy number changes from Agilent 180k data in form of rectangles (rect()) while each rectangle represents one region of copy number change. When plotting into a pdf I noticed that some very small rectangles do not appear (even after extensive zooming) in the pdf using the pdf() function. But they do when writing the screen output into a pdf using the GUI. Does anyone have some advice on this how I can plot pdfs without losing information? I am not sure if it has something to do with dingbats but you could try it. Set useDingbats=FALSE in you pdf call. Regards Petr Best wishes Kristian R version 2.14.0 (2011-10-31) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] CGHregions_1.12.0 CGHcall_2.14.0CGHbase_1.12.0marray_1.32.0 [5] limma_3.10.3 Biobase_2.14.0DNAcopy_1.28.0impute_1.28.0 loaded via a namespace (and not attached): [1] tools_2.14.0 Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 [[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. Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] correlation matrix between data from different files
Hello Rui, Thanks a lot for your answer. Hou hoped that your script would help me? I answer you: It is WON-DER-FUL! It works very well! I had first some difficulties to adapt it to my data, but I succeeded afterwords when I made a test between 2 stations. It's not perfect yet (I still have to modify a bit my data because it doesn't recognize the time column, and I have some problems with the automatization according to the name of the data from each stations), but the main problem (correlation matrix) seems to be resolved thanks to you! Thanks a lot again! -- View this message in context: http://r.789695.n4.nabble.com/correlation-matrix-between-data-from-different-files-tp4552226p4564610.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] loss of information in pdf plots
On 17.04.2012 14:35, Unger, Kristian, Dr. wrote: Thanks Petr. Unfortunately this does not help. In that case, we need a reproducible example. Uwe Ligges Kristian Am 17.04.2012 um 14:18 schrieb Petr PIKAL: Hi Hi there is it possible that pdfs generated using the pdf() function with default settings leads to loss of information? I was plotting copy number changes from Agilent 180k data in form of rectangles (rect()) while each rectangle represents one region of copy number change. When plotting into a pdf I noticed that some very small rectangles do not appear (even after extensive zooming) in the pdf using the pdf() function. But they do when writing the screen output into a pdf using the GUI. Does anyone have some advice on this how I can plot pdfs without losing information? I am not sure if it has something to do with dingbats but you could try it. Set useDingbats=FALSE in you pdf call. Regards Petr Best wishes Kristian R version 2.14.0 (2011-10-31) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] CGHregions_1.12.0 CGHcall_2.14.0CGHbase_1.12.0marray_1.32.0 [5] limma_3.10.3 Biobase_2.14.0DNAcopy_1.28.0impute_1.28.0 loaded via a namespace (and not attached): [1] tools_2.14.0 Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 [[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. Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to extract overall effect in from glmer object?
Hello, I am using glmer() from the lme4-package to run generalized linear mixed models. Is there a way to extract the overall variable effects from the model output object? For example, for linear models using lm() I use the anova() function to extract these results, however this is not possible for glmer(). Any help is welcome! Cheers, Thomas -- View this message in context: http://r.789695.n4.nabble.com/How-to-extract-overall-effect-in-from-glmer-object-tp4564590p4564590.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] differents behaviour of packages depending on rJava under 32 and 64 bit versions of R 2.14.2
Hi listeRs, Maybe I have missed something, but I am facing a problem I don't understand even after reading archives and manuals ( maybe not carefully enough !) : On my PC (64-bit OS, Intel Xeon CPU , two L5506@2.13 GHz processors, 12 Go RAM) under Windows 7 SP1, I run both 32-bit (i386-pc-mingw32/i386) and 64-bit (x86_64-pc-mingw32/x64) version 2.14.2 (2012-02-29) of R, packages being updated daily. Loading package lsa gives no problem under the 32-bit version : -- library(lsa) Le chargement a nécessité le package : Snowball Le chargement a nécessité le package : RWeka -- But does not work under the 64-bit version : --- library(lsa) Le chargement a nécessité le package : Snowball Error : .onLoad a échoué dans loadNamespace() pour 'Snowball', détails : appel : NULL erreur : .onLoad a échoué dans loadNamespace() pour 'rJava', détails : appel : fun(libname, pkgname) erreur : JAVA_HOME cannot be determined from the Registry Erreur : le package Snowball ne peut être chargé Because of the JAVA_HOME and Registry problem I suppose this is not strictly related to R but rather to the R - Java communication, but I can't figure what is happening, as it is working under the 32-bit configuration. Can someone here help ? Thanks by advance, all the best, Olivier -- Olivier ETERRADOSSI Maître-Assistant, HDR Ecole des Mines dAlès (CMGD, site de Pau) Pôle Matériaux Polymères Avancés (MPA) Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9 Tel : 05 59 30 90 35 (direct) - 05 59 30 54 25 (std) Fax : 05 59 30 63 68 [[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] loss of information in pdf plots
On Apr 17, 2012, at 7:08 AM, Unger, Kristian, Dr. wrote: Hi there is it possible that pdfs generated using the pdf() function with default settings leads to loss of information? I was plotting copy number changes from Agilent 180k data in form of rectangles (rect()) while each rectangle represents one region of copy number change. When plotting into a pdf I noticed that some very small rectangles do not appear (even after extensive zooming) in the pdf using the pdf() function. But they do when writing the screen output into a pdf using the GUI. Does anyone have some advice on this how I can plot pdfs without losing information? Best wishes Kristian R version 2.14.0 (2011-10-31) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] CGHregions_1.12.0 CGHcall_2.14.0CGHbase_1.12.0marray_1.32.0 [5] limma_3.10.3 Biobase_2.14.0DNAcopy_1.28.0impute_1.28.0 loaded via a namespace (and not attached): [1] tools_2.14.0 If you can provide some reproducible code (small example that yields the problem), that would help. However, you may be experiencing a problem in your PDF viewer (Preview?) due to anti-aliasing, which is noted here: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-there-unwanted-borders Regards, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] loss of information in pdf plots
There must be loss of accuracy: coordinates in PDF are recorded to finite accuracy (for pdf(), something like 0.01 as I recall). In addition, the R plot engine assumes finite accuracy, a minimum width for lines And as people are pointing out, so do PDF viewers. Do not expect to zoom into a plot (PDF or otherwise): if you want a large plot, plot it large in the first place. On 17/04/2012 13:58, Marc Schwartz wrote: On Apr 17, 2012, at 7:08 AM, Unger, Kristian, Dr. wrote: Hi there is it possible that pdfs generated using the pdf() function with default settings leads to loss of information? I was plotting copy number changes from Agilent 180k data in form of rectangles (rect()) while each rectangle represents one region of copy number change. When plotting into a pdf I noticed that some very small rectangles do not appear (even after extensive zooming) in the pdf using the pdf() function. But they do when writing the screen output into a pdf using the GUI. Does anyone have some advice on this how I can plot pdfs without losing information? Best wishes Kristian R version 2.14.0 (2011-10-31) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) Which is already 3 versions old: see what the posting guide has to say about that locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] CGHregions_1.12.0 CGHcall_2.14.0CGHbase_1.12.0marray_1.32.0 [5] limma_3.10.3 Biobase_2.14.0DNAcopy_1.28.0impute_1.28.0 loaded via a namespace (and not attached): [1] tools_2.14.0 If you can provide some reproducible code (small example that yields the problem), that would help. However, you may be experiencing a problem in your PDF viewer (Preview?) due to anti-aliasing, which is noted here: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-there-unwanted-borders Regards, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] packages install dependencies
On 17.04.2012 15:21, mail.bioi...@fr.netgrs.com wrote: Hi I checked inside the directory but I have the PACKAGE file as you can see ls /home/bioadm/install/R_packages/test/PACKAGES PACKAGES PACKAGES.gz I created them using this command write_PACKAGES(../test/, type=win.binary ) Errr, given your path specifications, I assume you are not under Windows and given the extensions of the files, I assume you have source packages, hence you need a PACKAGES file for a source repository. Uwe Ligges I retried the command but I got the same error. install.packages(/home/bioadm/install/R_packages/test/marginalmodelplots_0.4.2.tar.gz, repos=NULL, dependencies =TRUE, contriburl=/home/bioadm/install/R_packages/test/) Installing package(s) into â/soft/R-2.8.1/lib64/R/libraryâ (as âlibâ is unspecified) Warning: unable to access index for repository /home/bioadm/install/R_packages/test/ Warning message: package â/home/bioadm/install/R_packages/test/marginalmodelplots_0.4.2.tar.gzâ is not available (for R version 2.15.0) i checked also the permissions for this directory but it's OK as I created it with full acess for everyone drwxrwxrwx 2 bioadm test 155648 Apr 17 14:49 test Do you have any suggestions ? Joël -Message d'origine- De : Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Envoyé : mardi 17 avril 2012 14:25 À :FRsr BioInfo Cc : r-help@r-project.org Objet : Re: [R] packages install dependencies On 17.04.2012 10:57, mail.bioi...@fr.netgrs.com wrote: Hi Uwe Thanks for your answer. I tried to install the packages marginalmodelplots_0.4.2.tar.gz from a local repository /home/bioadm/install/R_packages/120416/ using your suggestion (i.e. install.packages(, contriburl=/home/joel/RPacks)) I paste below the command install.packages(/home/bioadm/install/R_packages/120416/marginalmodel plots_0.4.2.tar.gz, repos=NULL, dependencies= TRUE, type=source, contriburl=/home/bioadm/install/R_packages/120416/) Warning: unable to access index for repository /home/bioadm/install/R_packages/120416/ Warning message: In install.packages(/home/bioadm/install/R_packages/120416/marginalmodelplots_0.4.2.tar.gz, : package â/home/bioadm/install/R_packages/120416/marginalmodelplots_0.4.2.tar.g zâ is not available Then you do not have a repository. Its defintiion is that it contains a PACKAGES file which it obviously does not contain. Nevertheless, you can create a PACKAGE file via function write_PACKAGES() in package tools. Uwe Ligges For info this package depends of the locfit package. What should I do ? Thanks in advance Joël Masciocchi -Message d'origine- De : Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Envoyé : lundi 16 avril 2012 19:06 À :FRsr BioInfo Cc : r-help@r-project.org Objet : Re: [R] packages install dependencies On 16.04.2012 15:41, mail.bioi...@fr.netgrs.com wrote: Hello R-Members I have to install several R packages on a Unix server which doesn't have internet connection. I downloaded some packages manually and I installed it from source using the command R CMD INSTALL and it's work but in some cases I can't install the package because of the dependencies. So I download all the R packages into a directory for example /home/joel/RPacks. Is it possible to configure the R commands (i.e. CMD INSTALL command or install.packages() function) in order that R looks for dependencies in my repository. install.packages(, contriburl=/home/joel/RPacks) Uwe Ligges Thanks in advance, Best Regards - Cordialement, Joël - -- Joel Masciocchi Bioinformatician Informatics Department Institut de Recherches SERVIER (I.d.R.S) 125, chemin de Ronde 78290 CROISSY-SUR-SEINE - FRANCE [[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] differents behaviour of packages depending on rJava under 32 and 64 bit versions of R 2.14.2
On 17/04/2012 14:00, Olivier Eterradossi wrote: Hi listeRs, Maybe I have missed something, but I am facing a problem I don't understand even after reading archives and manuals (…maybe not carefully enough !) : 64-bit rJava needs 64-bit Java: 32-bit rJava needs 32-bit Java. You can install both on the same machine, and there are different registries presented to 32- and 64-bit programs, so only the correct one will be seen (if they are installed correctly). In any case, rJava has its own help forums, so it you need further help, ask there (and the maintainer does not read R-help routinely). On my PC (64-bit OS, Intel Xeon CPU , two L5506@2.13 GHz processors, 12 Go RAM) under Windows 7 SP1, I run both 32-bit (i386-pc-mingw32/i386) and 64-bit (x86_64-pc-mingw32/x64) version 2.14.2 (2012-02-29) of R, packages being updated daily. Loading package lsa gives no problem under the 32-bit version : -- library(lsa) Le chargement a nécessité le package : Snowball Le chargement a nécessité le package : RWeka -- But does not work under the 64-bit version : --- library(lsa) Le chargement a nécessité le package : Snowball Error : .onLoad a échoué dans loadNamespace() pour 'Snowball', détails : appel : NULL erreur : .onLoad a échoué dans loadNamespace() pour 'rJava', détails : appel : fun(libname, pkgname) erreur : JAVA_HOME cannot be determined from the Registry Erreur : le package ‘Snowball’ ne peut être chargé Because of the JAVA_HOME and Registry problem I suppose this is not strictly related to R but rather to the R- Java communication, but I can't figure what is happening, as it is working under the 32-bit configuration. Can someone here help ? Thanks by advance, all the best, Olivier -- Olivier ETERRADOSSI Maître-Assistant, HDR Ecole des Mines d’Alès (CMGD, site de Pau) Pôle Matériaux Polymères Avancés (MPA) Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9 Tel : 05 59 30 90 35 (direct) - 05 59 30 54 25 (std) Fax : 05 59 30 63 68 [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loss of information in pdf plots
Thanks Uwe. Please use the following below to reproduce the problem. Also, find the plots as I get them in my Dropbox: http://dl.dropbox.com/u/42940015/Rplot.pdf (plot as I get it when I use the save as... function from the Mac GUI menu. http://dl.dropbox.com/u/42940015/test.pdf (plot using the pdf() function. There should be red and blue boxes alternating with small white spaces in between. Actually neither the pdf from the screen plot nor the pdf() plot show exactly what I would expect. pdf(test.pdf,useDingbats=FALSE) ytp - c(-89325387,-89216522,-60796604,-58334752,-57765318,-55659470,-55054287,-53883354,-50215659,-50118524,-50072127,-50045267,-49883861,-48749073,-48689425,-48304344,-48232108,-48200930,-47389665,-47334632,-47006453,-46801749,-46779857,-46500741,-34202088,-106271) ybp - c(-90163070,-89315653,-89212325,-60737864,-58320017,-57748589,-55640346,-54993254,-53873394,-50204330,-50104099,-50064400,-50006459,-49870854,-48727216,-48665687,-48296706,-48221116,-48190704,-47378997,-47321850,-46998634,-46789748,-46765297,-35147449,-33961185) col - rep(c(blue,red),13) plot(c(0, 200), c(0, -90163070), type= n, xlab=, ylab=,axes=F) rect( 35+((p-1)*20), ytp,50+((p-1)*20),ybp,col=col,border=NA,main=hhh) dev.off() Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Am 17.04.2012 um 14:47 schrieb Uwe Ligges: On 17.04.2012 14:35, Unger, Kristian, Dr. wrote: Thanks Petr. Unfortunately this does not help. In that case, we need a reproducible example. Uwe Ligges Kristian Am 17.04.2012 um 14:18 schrieb Petr PIKAL: Hi Hi there is it possible that pdfs generated using the pdf() function with default settings leads to loss of information? I was plotting copy number changes from Agilent 180k data in form of rectangles (rect()) while each rectangle represents one region of copy number change. When plotting into a pdf I noticed that some very small rectangles do not appear (even after extensive zooming) in the pdf using the pdf() function. But they do when writing the screen output into a pdf using the GUI. Does anyone have some advice on this how I can plot pdfs without losing information? I am not sure if it has something to do with dingbats but you could try it. Set useDingbats=FALSE in you pdf call. Regards Petr Best wishes Kristian R version 2.14.0 (2011-10-31) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] CGHregions_1.12.0 CGHcall_2.14.0CGHbase_1.12.0marray_1.32.0 [5] limma_3.10.3 Biobase_2.14.0DNAcopy_1.28.0impute_1.28.0 loaded via a namespace (and not attached): [1] tools_2.14.0 Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.dehttp://www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 [[alternative HTML version deleted]] __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.dehttp://www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 [[alternative HTML version
Re: [R] loss of information in pdf plots
As far as I can see, the recommended way of using pdf() plot dev.off() works precisely, just zoom in far enough so that your screen is able to display the gaps, e.g. by zooming in by 6400% Uwe Ligges On 17.04.2012 15:53, Unger, Kristian, Dr. wrote: Thanks Uwe. Please use the following below to reproduce the problem. Also, find the plots as I get them in my Dropbox: http://dl.dropbox.com/u/42940015/Rplot.pdf (plot as I get it when I use the save as... function from the Mac GUI menu. http://dl.dropbox.com/u/42940015/test.pdf (plot using the pdf() function. There should be red and blue boxes alternating with small white spaces in between. Actually neither the pdf from the screen plot nor the pdf() plot show exactly what I would expect. pdf(test.pdf,useDingbats=FALSE) ytp- c(-89325387,-89216522,-60796604,-58334752,-57765318,-55659470,-55054287,-53883354,-50215659,-50118524,-50072127,-50045267,-49883861,-48749073,-48689425,-48304344,-48232108,-48200930,-47389665,-47334632,-47006453,-46801749,-46779857,-46500741,-34202088,-106271) ybp- c(-90163070,-89315653,-89212325,-60737864,-58320017,-57748589,-55640346,-54993254,-53873394,-50204330,-50104099,-50064400,-50006459,-49870854,-48727216,-48665687,-48296706,-48221116,-48190704,-47378997,-47321850,-46998634,-46789748,-46765297,-35147449,-33961185) col- rep(c(blue,red),13) plot(c(0, 200), c(0, -90163070), type= n, xlab=, ylab=,axes=F) rect( 35+((p-1)*20), ytp,50+((p-1)*20),ybp,col=col,border=NA,main=hhh) dev.off() Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Am 17.04.2012 um 14:47 schrieb Uwe Ligges: On 17.04.2012 14:35, Unger, Kristian, Dr. wrote: Thanks Petr. Unfortunately this does not help. In that case, we need a reproducible example. Uwe Ligges Kristian Am 17.04.2012 um 14:18 schrieb Petr PIKAL: Hi Hi there is it possible that pdfs generated using the pdf() function with default settings leads to loss of information? I was plotting copy number changes from Agilent 180k data in form of rectangles (rect()) while each rectangle represents one region of copy number change. When plotting into a pdf I noticed that some very small rectangles do not appear (even after extensive zooming) in the pdf using the pdf() function. But they do when writing the screen output into a pdf using the GUI. Does anyone have some advice on this how I can plot pdfs without losing information? I am not sure if it has something to do with dingbats but you could try it. Set useDingbats=FALSE in you pdf call. Regards Petr Best wishes Kristian R version 2.14.0 (2011-10-31) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] CGHregions_1.12.0 CGHcall_2.14.0CGHbase_1.12.0marray_1.32.0 [5] limma_3.10.3 Biobase_2.14.0DNAcopy_1.28.0impute_1.28.0 loaded via a namespace (and not attached): [1] tools_2.14.0 Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.dehttp://www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 [[alternative HTML version deleted]] __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.dehttp://www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764
Re: [R] differents behaviour of packages depending on rJava under32 and 64 bit versions of R 2.14.2
Thank you Prof., As always, simple things need to thing carefully :-( I have missed that point, and also the existence of rJava forums. ATB, Olivier -Message d'origine- De : Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Envoyé : mardi 17 avril 2012 15:32 À : Olivier Eterradossi Cc : r-help@r-project.org Objet : Re: [R] differents behaviour of packages depending on rJava under32 and 64 bit versions of R 2.14.2 On 17/04/2012 14:00, Olivier Eterradossi wrote: Hi listeRs, Maybe I have missed something, but I am facing a problem I don't understand even after reading archives and manuals ( maybe not carefully enough !) : 64-bit rJava needs 64-bit Java: 32-bit rJava needs 32-bit Java. You can install both on the same machine, and there are different registries presented to 32- and 64-bit programs, so only the correct one will be seen (if they are installed correctly). In any case, rJava has its own help forums, so it you need further help, ask there (and the maintainer does not read R-help routinely). On my PC (64-bit OS, Intel Xeon CPU , two L5506@2.13 GHz processors, 12 Go RAM) under Windows 7 SP1, I run both 32-bit (i386-pc-mingw32/i386) and 64-bit (x86_64-pc-mingw32/x64) version 2.14.2 (2012-02-29) of R, packages being updated daily. Loading package lsa gives no problem under the 32-bit version : -- library(lsa) Le chargement a nécessité le package : Snowball Le chargement a nécessité le package : RWeka -- But does not work under the 64-bit version : --- library(lsa) Le chargement a nécessité le package : Snowball Error : .onLoad a échoué dans loadNamespace() pour 'Snowball', détails : appel : NULL erreur : .onLoad a échoué dans loadNamespace() pour 'rJava', détails : appel : fun(libname, pkgname) erreur : JAVA_HOME cannot be determined from the Registry Erreur : le package Snowball ne peut être chargé Because of the JAVA_HOME and Registry problem I suppose this is not strictly related to R but rather to the R- Java communication, but I can't figure what is happening, as it is working under the 32-bit configuration. Can someone here help ? Thanks by advance, all the best, Olivier -- Olivier ETERRADOSSI Maître-Assistant, HDR Ecole des Mines dAlès (CMGD, site de Pau) Pôle Matériaux Polymères Avancés (MPA) Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9 Tel : 05 59 30 90 35 (direct) - 05 59 30 54 25 (std) Fax : 05 59 30 63 68 [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error using nls with logistic derivative
Peter Dalgaard has already given some indications. However, nls() is pretty fragile as a solver in my experience. I'm in the process of putting some more robust (in the computing and not statistical sense) solvers in the nlmrt package on the R-forge project at https://r-forge.r-project.org/R/?group_id=395 See output below. Best, JN source(ardila.R, echo=T) rm(list=ls()) require(nlmrt) logis- expression(a/(1+exp((b-x)/c))) D(logis, x) a * (exp((b - x)/c) * (1/c))/(1 + exp((b - x)/c))^2 myY-c(5.5199668, 1.5234525, 3.3557000, 6.7211704, 7.4237955, 1.9703127, 4.3939336, + -1.4380091, 3.2650180, 3.5760906, 0.2947972, 1.0569417) myX-c(1, 0, 0, 4, 3, 5, 12, 10, 12, 100, 100, 100) mydata-data.frame(X=myX, Y=myY) ratelogis - try(nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, +start=list(a = 21.16322, b = 8.83669, c = 2.957765),trace=TRUE, data=myda [TRUNCATED] 151.098 : 21.163220 8.836690 2.957765 127.1149 : 103.49326 11.43274 20.29663 111.344 : 833.02390 -45.86244 140.32986 111.3375 : 978.97105 -76.20547 159.90818 111.3374 : 1097.1336 -101.6763 174.2032 111.3227 : 1179.8406 -119.7406 183.3788 Error in nls(Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2, : step factor 0.000488281 reduced below 'minFactor' of 0.000976562 print(ratelogis) [1] Error in nls(Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2, : \n step factor 0.000488281 reduced below 'minFactor' of 0.000976562\n attr(,class) [1] try-error attr(,condition) simpleError in nls(Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2, start = list(a = 21.16322, b = 8.83669, c = 2.957765), trace = TRUE, data = mydata): step factor 0.000488281 reduced below 'minFactor' of 0.000976562 ratelogisn - nlxb(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, +start=list(a = 21.16322, b = 8.83669, c = 2.957765),trace=TRUE, data=mydata [TRUNCATED] 'data.frame': 12 obs. of 2 variables: $ X: num 1 0 0 4 3 5 12 10 12 100 ... $ Y: num 5.52 1.52 3.36 6.72 7.42 ... NULL formula: Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2 lower:[1] -Inf -Inf -Inf upper:[1] Inf Inf Inf $watch [1] FALSE $phi [1] 1 $lamda [1] 1e-04 $offset [1] 100 $laminc [1] 10 $lamdec [1] 4 $femax [1] 1 $jemax [1] 5000 Data variable Y : [1] 5.5199668 1.5234525 3.3557000 6.7211704 7.4237955 1.9703127 [7] 4.3939336 -1.4380091 3.2650180 3.5760906 0.2947972 1.0569417 Data variable X : [1] 1 0 0 4 3 5 12 10 12 100 100 100 Start:lamda: 1e-04 SS= 151.098 at a = 21.16322 b = 8.83669 c = 2.957765 1 / 0 gradient projection0 = -113.7506 gangle= -0.2949267 Stepsize= 1 lamda: 4e-05 SS= 127.1308 at a = 102.7381 b = 11.32418 c = 20.15418 2 / 1 gradient projection0 = -55.55629 gangle= -0.1594696 Stepsize= 1 lamda: 4e-04 SS= 129.9286 at a = 378.4733 b = -71.39815 c = 50.21802 3 / 2 gradient projection0 = -49.05021 gangle= -0.505497 [snip] lamda: 2814.75 SS= 50.50144 at a = 36.13314 b = 2.572373 c = 1.079811 42 / 25 gradient projection0 = -5.685471e-20 gangle= -0.9954213 Stepsize= 1 lamda: 28147.5 SS= 50.50144 at a = 36.13314 b = 2.572373 c = 1.079811 43 / 25 gradient projection0 = -5.68707e-21 gangle= -0.9954364 Stepsize= 1 lamda: 281475 SS= 50.50144 at a = 36.13314 b = 2.572373 c = 1.079811 44 / 25 gradient projection0 = -5.687227e-22 gangle= -0.995437 Stepsize= 1 No parameter change print(ratelogisn) $resid [1] -0.3897067 1.0662193 -0.7660282 -1.1606765 0.6222073 0.9203074 [7] -4.3885301 1.4723895 -3.2596145 -3.5760906 -0.2947972 -1.0569417 $jacobian a b c [1,] 1.419821e-01 -2.954633e+00 -4.486669e-01 [2,] 7.167026e-02 -1.992780e+00 2.349023e+00 [3,] 7.167026e-02 -1.992780e+00 2.349023e+00 [4,] 1.538890e-01 2.981895e+00 -1.207117e+00 [5,] 2.226765e-01 1.456449e+00 -6.874521e+00 [6,] 7.13e-02 2.165639e+00 2.191813e+00 [7,] 1.495441e-04 5.002498e-03 3.867174e-02 [8,] 9.514926e-04 3.177379e-02 1.867210e-01 [9,] 1.495441e-04 5.002498e-03 3.867174e-02 [10,] 6.050186e-40 2.024541e-38 1.806428e-36 [11,] 6.050186e-40 2.024541e-38 1.806428e-36 [12,] 6.050186e-40 2.024541e-38 1.806428e-36 $feval [1] 44 $jeval [1] 25 $coeffs [1] 36.133144 2.572373 1.079811 $ssquares [1] 50.50144 ratelogis - try(nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, +start=list(a = 36.133144, b= 2.572373, c=1.079811),trace=TRUE, data=mydat [TRUNCATED] 50.50144 : 36.133144 2.572373 1.079811 print(ratelogis) Nonlinear regression model model: Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2 data: mydata a b c 36.133 2.572 1.080 residual sum-of-squares: 50.5 Number of iterations to convergence: 0 Achieved convergence tolerance: 4.818e-07 On 04/17/2012 06:00 AM, r-help-requ...@r-project.org wrote: Message: 112 Date: Mon, 16 Apr 2012 23:23:07 -0500 From: Francisco Mora Ardila fm...@oikos.unam.mx
Re: [R] packages install dependencies
Hi I checked inside the directory but I have the PACKAGE file as you can see ls /home/bioadm/install/R_packages/test/PACKAGES PACKAGES PACKAGES.gz I created them using this command write_PACKAGES(../test/, type=win.binary ) I retried the command but I got the same error. install.packages(/home/bioadm/install/R_packages/test/marginalmodelplots_0.4.2.tar.gz, repos=NULL, dependencies =TRUE, contriburl=/home/bioadm/install/R_packages/test/) Installing package(s) into â/soft/R-2.8.1/lib64/R/libraryâ (as âlibâ is unspecified) Warning: unable to access index for repository /home/bioadm/install/R_packages/test/ Warning message: package â/home/bioadm/install/R_packages/test/marginalmodelplots_0.4.2.tar.gzâ is not available (for R version 2.15.0) i checked also the permissions for this directory but it's OK as I created it with full acess for everyone drwxrwxrwx 2 bioadm test 155648 Apr 17 14:49 test Do you have any suggestions ? Joël -Message d'origine- De : Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Envoyé : mardi 17 avril 2012 14:25 À : FRsr BioInfo Cc : r-help@r-project.org Objet : Re: [R] packages install dependencies On 17.04.2012 10:57, mail.bioi...@fr.netgrs.com wrote: Hi Uwe Thanks for your answer. I tried to install the packages marginalmodelplots_0.4.2.tar.gz from a local repository /home/bioadm/install/R_packages/120416/ using your suggestion (i.e. install.packages(, contriburl=/home/joel/RPacks)) I paste below the command install.packages(/home/bioadm/install/R_packages/120416/marginalmodel plots_0.4.2.tar.gz, repos=NULL, dependencies= TRUE, type=source, contriburl=/home/bioadm/install/R_packages/120416/) Warning: unable to access index for repository /home/bioadm/install/R_packages/120416/ Warning message: In install.packages(/home/bioadm/install/R_packages/120416/marginalmodelplots_0.4.2.tar.gz, : package â/home/bioadm/install/R_packages/120416/marginalmodelplots_0.4.2.tar.g zâ is not available Then you do not have a repository. Its defintiion is that it contains a PACKAGES file which it obviously does not contain. Nevertheless, you can create a PACKAGE file via function write_PACKAGES() in package tools. Uwe Ligges For info this package depends of the locfit package. What should I do ? Thanks in advance Joël Masciocchi -Message d'origine- De : Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Envoyé : lundi 16 avril 2012 19:06 À :FRsr BioInfo Cc : r-help@r-project.org Objet : Re: [R] packages install dependencies On 16.04.2012 15:41, mail.bioi...@fr.netgrs.com wrote: Hello R-Members I have to install several R packages on a Unix server which doesn't have internet connection. I downloaded some packages manually and I installed it from source using the command R CMD INSTALL and it's work but in some cases I can't install the package because of the dependencies. So I download all the R packages into a directory for example /home/joel/RPacks. Is it possible to configure the R commands (i.e. CMD INSTALL command or install.packages() function) in order that R looks for dependencies in my repository. install.packages(, contriburl=/home/joel/RPacks) Uwe Ligges Thanks in advance, Best Regards - Cordialement, Joël - -- Joel Masciocchi Bioinformatician Informatics Department Institut de Recherches SERVIER (I.d.R.S) 125, chemin de Ronde 78290 CROISSY-SUR-SEINE - FRANCE [[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] Partial Dependence and RandomForest
Note that the partialPlot() function also returns the x-y pairs being plotted, so you can work from there if you wish. As to SD, my guess is you want some sort of confidence interval or band around the curve? I do not know of any theory to produce that, but that may well just be my ignorance. Andy -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of jmc Sent: Friday, April 13, 2012 11:20 AM To: r-help@r-project.org Subject: Re: [R] Partial Dependence and RandomForest Thank you Andy. I obviously neglected to read into the help file and, frustratingly, could have known this all along. However, I am still interested in knowing the relative maximum value in the partial plots via query instead of visual interpretation (and possibly getting at other statistical measures like standard deviation). Is it possible to do this? I will keep investigating, but would appreciate a hint in the right direction if you have time. -- View this message in context: http://r.789695.n4.nabble.com/Partial-Dependence-and-RandomForest-tp4549705p4555146.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. Notice: This e-mail message, together with any attachme...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loss of information in pdf plots
Thanks Uwe, you are right! The reason why it works fine now might be that the borders switch of the rect() function was set to white rather than NA when I sent my initial request. This obviously led to drawing of white borders that overlaid some of the tiny blue or red rectangles. However, it is still suspicious to me that the screen output looks quite different from the plot in the pdf. Thanks all for your great help! Best wishes Kristian Tel.: +49-89-3187-3515 Am 17.04.2012 um 16:04 schrieb Uwe Ligges: As far as I can see, the recommended way of using pdf() plot dev.off() works precisely, just zoom in far enough so that your screen is able to display the gaps, e.g. by zooming in by 6400% Uwe Ligges On 17.04.2012 15:53, Unger, Kristian, Dr. wrote: Thanks Uwe. Please use the following below to reproduce the problem. Also, find the plots as I get them in my Dropbox: http://dl.dropbox.com/u/42940015/Rplot.pdf (plot as I get it when I use the save as... function from the Mac GUI menu. http://dl.dropbox.com/u/42940015/test.pdf (plot using the pdf() function. There should be red and blue boxes alternating with small white spaces in between. Actually neither the pdf from the screen plot nor the pdf() plot show exactly what I would expect. pdf(test.pdf,useDingbats=FALSE) ytp- c(-89325387,-89216522,-60796604,-58334752,-57765318,-55659470,-55054287,-53883354,-50215659,-50118524,-50072127,-50045267,-49883861,-48749073,-48689425,-48304344,-48232108,-48200930,-47389665,-47334632,-47006453,-46801749,-46779857,-46500741,-34202088,-106271) ybp- c(-90163070,-89315653,-89212325,-60737864,-58320017,-57748589,-55640346,-54993254,-53873394,-50204330,-50104099,-50064400,-50006459,-49870854,-48727216,-48665687,-48296706,-48221116,-48190704,-47378997,-47321850,-46998634,-46789748,-46765297,-35147449,-33961185) col- rep(c(blue,red),13) plot(c(0, 200), c(0, -90163070), type= n, xlab=, ylab=,axes=F) rect( 35+((p-1)*20), ytp,50+((p-1)*20),ybp,col=col,border=NA,main=hhh) dev.off() Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Am 17.04.2012 um 14:47 schrieb Uwe Ligges: On 17.04.2012 14:35, Unger, Kristian, Dr. wrote: Thanks Petr. Unfortunately this does not help. In that case, we need a reproducible example. Uwe Ligges Kristian Am 17.04.2012 um 14:18 schrieb Petr PIKAL: Hi Hi there is it possible that pdfs generated using the pdf() function with default settings leads to loss of information? I was plotting copy number changes from Agilent 180k data in form of rectangles (rect()) while each rectangle represents one region of copy number change. When plotting into a pdf I noticed that some very small rectangles do not appear (even after extensive zooming) in the pdf using the pdf() function. But they do when writing the screen output into a pdf using the GUI. Does anyone have some advice on this how I can plot pdfs without losing information? I am not sure if it has something to do with dingbats but you could try it. Set useDingbats=FALSE in you pdf call. Regards Petr Best wishes Kristian R version 2.14.0 (2011-10-31) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] CGHregions_1.12.0 CGHcall_2.14.0CGHbase_1.12.0marray_1.32.0 [5] limma_3.10.3 Biobase_2.14.0DNAcopy_1.28.0impute_1.28.0 loaded via a namespace (and not attached): [1] tools_2.14.0 Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.dehttp://www.helmholtz-muenchen.dehttp://www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 [[alternative HTML version deleted]] __ R-help@r-project.orgmailto:R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.dehttp://www.helmholtz-muenchen.dehttp://www.helmholtz-muenchen.de Aufsichtsratsvorsitzende:
Re: [R] How to create a data.frame from several time series?
Hello all, followup to yesterday's question: Part of my confusion was caused by my embarrassing mistake of overwriting the ppk function with another object, which of course broke the next iteration of the loop. Secondly, I got exactly what I wanted like this: aggregate.zoo - function(series) { agg - aggregate(data=series, value ~ month, ppk, lsl=1300, usl=1500) return (zoo(x=agg$value, order.by=agg$month)) } l1 = split(df, df$tool) l2 = lapply(l1, aggregate.zoo) l3 = do.call(merge, l2) I puzzled this together from various example with only 80% understanding how it works and why. Regards, robert __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Function with multiple indices
Hi, I wrote a function which works for one group but not for multiple groups in several years. Could anyone help me out? The dateset has 3 variables, year, group, and sales. I want to calculate the annual group median adjusted sales performance for observation i in group j and year yr, I do the following procedure. For each yar, 1. exclude observation i from group j 2. calculate the sales median for group j without observation i and call it med 3. substract med from the sales of observation i to obtain the group median adjusted sales performance for observation i The dataset, function, and questions are as follows. x1 - read.table(textConnection(YEAR GROUP SALES 1997 11 0.027 1997 11 0.001 1997 11 0.697 1997 11 0.047 1997 11 0.225 1998 11 0.025 1998 11 0.002 1998 11 0.001 1998 11 0.659 1998 11 0.037 1997 12 0.152 1997 12 0.025 1997 12 0.417 1997 12 0.081 1997 12 0.194 1997 12 0.069 1997 12 0.062 1998 12 0.146 1998 12 0.028 1998 12 0.437 1997 13 0.087 1997 13 0.008 1997 13 0.014 1997 13 0.010 1997 13 0.018 1997 13 0.002 1997 13 0.010 1997 13 0.079 1997 13 0.092 1997 13 0.118 1997 14 0.111 1997 14 0.013 1997 14 0.506 1997 14 0.333 1997 14 0.018 1997 14 0.017 1998 14 0.155 1998 14 0.018 1998 14 0.477 1998 14 0.312), header=TRUE) # The whole dataset x1 # Data for the first group only GROUP11 - x1[1:10,] GROUP11 # The function works for the first group in one year perf = function(x) { for (i in 1:nrow(x)) { salesi - x$SALES[i] med - median(x$SALES[-i]) print (salesi - med) } } perf(GROUP11) # Why the above funtion doesn't work in the following? tapply(x1$SALES, list(x1$YEAR, x1$GROUP), perf) aggregate(x1$SALES, by=list(x1$YEAR, x1$GROUP),FUN=perf) Thanks! Chingfu Chang __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] loss of information in pdf plots
On 17.04.2012 16:16, Unger, Kristian, Dr. wrote: Thanks Uwe, you are right! The reason why it works fine now might be that the borders switch of the rect() function was set to white rather than NA when I sent my initial request. This obviously led to drawing of white borders that overlaid some of the tiny blue or red rectangles. However, it is still suspicious to me that the screen output looks quite different from the plot in the pdf. Well, the screen is completely different than the pdf (the latter works rather precisely, the screen has typically not much more than 2000x1200 pixels and the question is how to render effects that are smaller than a pixel ... Now the windows device and your pdf viewer decide to do different things (and R handles the devices slightly different as well, of course). Uwe Ligges Thanks all for your great help! Best wishes Kristian Tel.: +49-89-3187-3515 Am 17.04.2012 um 16:04 schrieb Uwe Ligges: As far as I can see, the recommended way of using pdf() plot dev.off() works precisely, just zoom in far enough so that your screen is able to display the gaps, e.g. by zooming in by 6400% Uwe Ligges On 17.04.2012 15:53, Unger, Kristian, Dr. wrote: Thanks Uwe. Please use the following below to reproduce the problem. Also, find the plots as I get them in my Dropbox: http://dl.dropbox.com/u/42940015/Rplot.pdf (plot as I get it when I use the save as... function from the Mac GUI menu. http://dl.dropbox.com/u/42940015/test.pdf (plot using the pdf() function. There should be red and blue boxes alternating with small white spaces in between. Actually neither the pdf from the screen plot nor the pdf() plot show exactly what I would expect. pdf(test.pdf,useDingbats=FALSE) ytp- c(-89325387,-89216522,-60796604,-58334752,-57765318,-55659470,-55054287,-53883354,-50215659,-50118524,-50072127,-50045267,-49883861,-48749073,-48689425,-48304344,-48232108,-48200930,-47389665,-47334632,-47006453,-46801749,-46779857,-46500741,-34202088,-106271) ybp- c(-90163070,-89315653,-89212325,-60737864,-58320017,-57748589,-55640346,-54993254,-53873394,-50204330,-50104099,-50064400,-50006459,-49870854,-48727216,-48665687,-48296706,-48221116,-48190704,-47378997,-47321850,-46998634,-46789748,-46765297,-35147449,-33961185) col- rep(c(blue,red),13) plot(c(0, 200), c(0, -90163070), type= n, xlab=, ylab=,axes=F) rect( 35+((p-1)*20), ytp,50+((p-1)*20),ybp,col=col,border=NA,main=hhh) dev.off() Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Am 17.04.2012 um 14:47 schrieb Uwe Ligges: On 17.04.2012 14:35, Unger, Kristian, Dr. wrote: Thanks Petr. Unfortunately this does not help. In that case, we need a reproducible example. Uwe Ligges Kristian Am 17.04.2012 um 14:18 schrieb Petr PIKAL: Hi Hi there is it possible that pdfs generated using the pdf() function with default settings leads to loss of information? I was plotting copy number changes from Agilent 180k data in form of rectangles (rect()) while each rectangle represents one region of copy number change. When plotting into a pdf I noticed that some very small rectangles do not appear (even after extensive zooming) in the pdf using the pdf() function. But they do when writing the screen output into a pdf using the GUI. Does anyone have some advice on this how I can plot pdfs without losing information? I am not sure if it has something to do with dingbats but you could try it. Set useDingbats=FALSE in you pdf call. Regards Petr Best wishes Kristian R version 2.14.0 (2011-10-31) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] CGHregions_1.12.0 CGHcall_2.14.0CGHbase_1.12.0marray_1.32.0 [5] limma_3.10.3 Biobase_2.14.0DNAcopy_1.28.0impute_1.28.0 loaded via a namespace (and not attached): [1] tools_2.14.0 Arbeitsgruppenleiter Integrative Biologie / Head of Integrative Biology Group Abteilung für Strahlenzytogenetik / Research Unit of Radiation Cytogenetics Tel.: +49-89-3187-3515 Helmholtz Zentrum München Deutsches Forschungszentrum für Gesundheit und Umwelt (GmbH) Ingolstädter Landstr. 1 85764 Neuherberg www.helmholtz-muenchen.dehttp://www.helmholtz-muenchen.dehttp://www.helmholtz-muenchen.de Aufsichtsratsvorsitzende: MinDir´in Bärbel Brumme-Bothe Geschäftsführer: Prof. Dr. Günther Wess und Dr. Nikolaus Blum Registergericht: Amtsgericht München HRB 6466 USt-IdNr: DE 129521671 [[alternative HTML version deleted]] __ R-help@r-project.orgmailto:R-help@r-project.orgmailto:R-help@r-project.org mailing
[R] puzzling Date math result
Hi, I cannot make a reproducible example easily for my problem, so I'll describe it as best as I can. I merged 2 dataframes but was surprised when one line on the x dataframe did not get a match in the y dataframe, because I knew such a match existed. There was only one by variable in the merge, in Date format: in x: $ période: Date, format: 2009-06-09 2009-07-09 ... in y: $ date : Date, format: 2009-05-12 2009-06-09 … I extracted the date that did not match into variables a (from x) and b (from y): a=test1$période[21] b=test2$date[22] a [1] 2011-04-06 b [1] 2011-04-06 and then this very puzzling situation: a==b [1] FALSE as.integer(a) [1] 15070 as.integer(b) [1] 15070 as.integer(a)==as.integer(b) [1] TRUE Thanks in advance for an explanation or a suggestion to further study this puzzle, Denis sessionInfo() R version 2.15.0 (2012-03-30) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] fr_CA.UTF-8/en_US.UTF-8/fr_CA.UTF-8/C/fr_CA.UTF-8/fr_CA.UTF-8 attached base packages: [1] splines stats graphics grDevices utils datasets methods [8] base other attached packages: [1] doBy_4.5.2 MASS_7.3-17 snow_0.3-8 lme4_0.999375-42 [5] Matrix_1.0-6 lattice_0.20-6 multcomp_1.2-12 mvtnorm_0.9-9992 [9] R2HTML_2.2 survival_2.36-12 gdata_2.8.2 loaded via a namespace (and not attached): [1] grid_2.15.0 gtools_2.6.2 nlme_3.1-103 stats4_2.15.0 tools_2.15.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] image.plot specify colors for range of data points, please help
Hi If I had a dataset of the following below and I want to plot colors for this image.plot so that: red for data above 1 black for data between/equal 1 and -1 green for data below -1 normally its: image.plot(data) but how do I add the colors for the range of data points as above? Many thanks for your help! _DATA_ 2.04 2.02 1.60 1.92 0.98 0.50 0.40 -0.50 -0.40 -1.90 -2.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.
[R] Re : image.plot specify colors for range of data points, please help
Hi, image.plot(x, breaks=c(-100,-1,1,100), col=c('green','black','red')) Regards, Pascal - Mail original - De : David Lyon david_ly...@yahoo.com À : r-help@r-project.org r-help@r-project.org Cc : Envoyé le : Mercredi 18 avril 2012 0h00 Objet : [R] image.plot specify colors for range of data points, please help Hi If I had a dataset of the following below and I want to plot colors for this image.plot so that: red for data above 1 black for data between/equal 1 and -1 green for data below -1 normally its: image.plot(data) but how do I add the colors for the range of data points as above? Many thanks for your help! _DATA_ 2.04 2.02 1.60 1.92 0.98 0.50 0.40 -0.50 -0.40 -1.90 -2.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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] What functions are available for Quadratically Constrained Quadratic Programming in R?
Hi all, Could anybody please point me to the solver function in R on QCQP? The quadprog package seems to be only able to handle the linear constraints... 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] Re : image.plot specify colors for range of data points, please help
Thank you so much! - Original Message - From: Pascal Oettli kri...@ymail.com To: David Lyon david_ly...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Tuesday, April 17, 2012 11:31 AM Subject: Re : [R] image.plot specify colors for range of data points, please help Hi, image.plot(x, breaks=c(-100,-1,1,100), col=c('green','black','red')) Regards, Pascal - Mail original - De : David Lyon david_ly...@yahoo.com À : r-help@r-project.org r-help@r-project.org Cc : Envoyé le : Mercredi 18 avril 2012 0h00 Objet : [R] image.plot specify colors for range of data points, please help Hi If I had a dataset of the following below and I want to plot colors for this image.plot so that: red for data above 1 black for data between/equal 1 and -1 green for data below -1 normally its: image.plot(data) but how do I add the colors for the range of data points as above? Many thanks for your help! _DATA_ 2.04 2.02 1.60 1.92 0.98 0.50 0.40 -0.50 -0.40 -1.90 -2.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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 accessing .Rdata objects in a loop
Hi, I am trying to access many .Rdata objects and do some operations with them using a loop. I can load the files but can't access them. The files' names are stored in a character vector called names. After loading the objects, I can view each one using ls() and see that two objects are present for each. I am trying to access the one with the name which is the same as the name of the .Rdata. I can access individual .Rdata object using backticks around its name like this: names- c(df1, df2, df3) load(paste(path, /, df1, .RData, sep=) df- `df1` But when I try using the variable name in a loop it does not work: for (n in names) { print(names) load(paste(path, /, names, .RData, sep=)) df- `n` ###do some other operations with each object } Could you please help me understand what I can do to view these objects? Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Problem-accessing-Rdata-objects-in-a-loop-tp4565154p4565154.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] Summary about how to divide data by week
Hello, I'm glad you have a solution that works. Maybe you could do the same without hard-coding the values 1:7, 8:14. $ library(chron) dat - with(my_dataframe, paste(month, day, year, sep=/)) week - cut(chron(dat), breaks=weeks) head(week) tapply(my_dataframe$Freq, week, mean) Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Summary-about-how-to-divide-data-by-week-tp4563909p4565199.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] Function with multiple indices
Hello, In your first call, perf(GROUP11), you're passing a data.frame, in the 'tapply' and 'aggregate' you are passing a vector, x1$SALES, and the operator '$' is not valid. tapply(x1$SALES, list(x1$YEAR, x1$GROUP), perf) Error in x$SALES : $ operator is invalid for atomic vectors There's another thing, the function doesn't return a value, just prints them. See if this revision does what you want. perf_b = function(x) { nr - NROW(x) y - numeric(nr) for (i in 1:nr) { salesi - x$SALES[i] med - median(x$SALES[-i]) print(salesi - med) y[i] - salesi - med } y } sapply(split(x1, list(x1$YEAR, x1$GROUP)), perf_b) Then, 'unlist' the result. Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Function-with-multiple-indices-tp4564907p4565175.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 accessing .Rdata objects in a loop
Try reading ?load again. It takes a single filename only. Also 'n' is a character, not a symbol for a variable. I think you need to do some reading on basic programming. Try An Introduction to R (part of the distro) to get you going. -- Bert On Tue, Apr 17, 2012 at 8:38 AM, francy francy.casal...@gmail.com wrote: Hi, I am trying to access many .Rdata objects and do some operations with them using a loop. I can load the files but can't access them. The files' names are stored in a character vector called names. After loading the objects, I can view each one using ls() and see that two objects are present for each. I am trying to access the one with the name which is the same as the name of the .Rdata. I can access individual .Rdata object using backticks around its name like this: names- c(df1, df2, df3) load(paste(path, /, df1, .RData, sep=) df- `df1` But when I try using the variable name in a loop it does not work: for (n in names) { print(names) load(paste(path, /, names, .RData, sep=)) df- `n` ###do some other operations with each object } Could you please help me understand what I can do to view these objects? Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Problem-accessing-Rdata-objects-in-a-loop-tp4565154p4565154.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem accessing .Rdata objects in a loop
I'm not sure that's francy's problem. This seems to work for me: # Some fake data nms - letters[1:5] lapply(nms, function(x) assign(x, rnorm(10), .GlobalEnv)) # Make some .Rdata files lapply(nms, function(x) save(list =x, file = paste0(x, .Rdata))) # Check they are there list.files() # Bring them in and do operations for(nm in nms){ load(paste0(nm,.Rdata)) print(max(get(nm))) # Works } Francy's problem seems to be trying to use `n` (the symbol, not the character vector) to access the loaded objects instead of get. Use of the backticks doesn't do what I think you (Francy) think it does here. Of course, I think this is all a little easier if one uses saveRDS / readRDS which can assign directly to an object upon load (xxx - loadRDS(filename)) -- Duncan Murdoch pointed these out to me just a few weeks ago. Michael On Tue, Apr 17, 2012 at 12:07 PM, Bert Gunter gunter.ber...@gene.com wrote: Try reading ?load again. It takes a single filename only. Also 'n' is a character, not a symbol for a variable. I think you need to do some reading on basic programming. Try An Introduction to R (part of the distro) to get you going. -- Bert On Tue, Apr 17, 2012 at 8:38 AM, francy francy.casal...@gmail.com wrote: Hi, I am trying to access many .Rdata objects and do some operations with them using a loop. I can load the files but can't access them. The files' names are stored in a character vector called names. After loading the objects, I can view each one using ls() and see that two objects are present for each. I am trying to access the one with the name which is the same as the name of the .Rdata. I can access individual .Rdata object using backticks around its name like this: names- c(df1, df2, df3) load(paste(path, /, df1, .RData, sep=) df- `df1` But when I try using the variable name in a loop it does not work: for (n in names) { print(names) load(paste(path, /, names, .RData, sep=)) df- `n` ###do some other operations with each object } Could you please help me understand what I can do to view these objects? Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Problem-accessing-Rdata-objects-in-a-loop-tp4565154p4565154.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] What functions are available for Quadratically Constrained Quadratic Programming in R?
Looks like we need an SDP solver in R... Any pointers? thanks a lot! On Tue, Apr 17, 2012 at 10:54 AM, Michael comtech@gmail.com wrote: Hi all, Could anybody please point me to the solver function in R on QCQP? The quadprog package seems to be only able to handle the linear constraints... 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] puzzling Date math result
On Tue, 17 Apr 2012 10:44:40 -0400, Denis Chabot wrote: Hi, I cannot make a reproducible example easily for my problem, so I'll describe it as best as I can. YOU KIND OF NEED ONE... a=test1$période[21] b=test2$date[22] a f argin-left:5px; width:100%b [1] 2011-04-06 THIS IS WHY YOU NEED TO GIVE US A REPRODUCABLE MEANS BECAUSE IF I SIMPLY DO A=2011-04-06 AND B=2011-04-06 I'M GOING TO GET A==B TRUE WHERE IS THE DATA IN THE DF'S BEING SOURCED FROM? IS IT A DATABASE? COULD THERE BE DIFFERENT DATA DEFINITIONS? IS ITS A CSV FILE ETC? and then thi ft:#1010ff 2px solid; margin-left:5px; width:100%as.integer(a) [1] 15070 as.integer(b) [1] 15070 SUGGESTION THAT MIGHT POINT YOU IN A DIRECTION... as.integer (15070) pre as.integer (15070.1) [1] 15070 as.integer (15070)==as.integer(15070.1) [1] TRUE 15070==15070.1 [1] FALSE SECOND SUGGESTION WOULD BE TO DROP THE à NO IDEA WHY THAT WOULD CAUSE A PROBLEM (OR WHERE), BUT ANYTHING THATS NOT A-Z OR A-Z ONLY INTRODUCES A POTENTIAL EXTRA HEADACHE... as.integer(a)==as.integer(b) [[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] puzzling Date math result
On Tue, 17 Apr 2012 10:44:40 -0400, Denis Chabot wrote: Hi, I cannot make a reproducible example easily for my problem, so I'll describe it as best as I can. YOU KIND OF NEED ONE... a=test1$période[21] b=test2$date[22] a x in-left: 5px; width: 100%;b [1] 2011-04-06 THIS IS WHY YOU NEED TO GIVE US A REPRODUCABLE MEANS BECAUSE IF I SIMPLY DO A=2011-04-06 AND B=2011-04-06 I'M GOING TO GET A==B TRUE WHERE IS THE DATA IN THE DF'S BEING SOURCED FROM? IS IT A DATABASE? COULD THERE BE DIFFERENT DATA DEFINITIONS? IS ITS A CSV FILE ETC? as.integer(a) [1] 15070 as.integer(b) [1] 15070 SUGGESTION THAT MIGHT POINT YOU IN A DIRECTION... as.integer (15070) [1] 15070 as.integer (15070.1) [1] 15070 as. 0)==as.integer(15070.1) [1] TRUE 15070==15070.1 [1] FALSE SECOND SUGGESTION WOULD BE TO DROP THE à NO IDEA WHY THAT WOULD CAUSE A PROBLEM (OR WHERE), BUT ANYTHING THATS NOT A-Z OR A-Z ONLY INTRODUCES A POTENTIAL EXTRA HEADACHE.. [[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 using nls with logistic derivative
It seems to work! Thanks and sorry for the personal message Francisco On Tue, 17 Apr 2012 09:09:24 +0200, peter dalgaard wrote On Apr 17, 2012, at 06:23 , Francisco Mora Ardila wrote: Hi I´m trying to fit a nonlinear model to a derivative of the logistic function y = a/(1+exp((b-x)/c)) (this is the parametrization for the SSlogis function with nls) The derivative calculated with D function is: logis- expression(a/(1+exp((b-x)/c))) D(logis, x) a * (exp((b - x)/c) * (1/c))/(1 + exp((b - x)/c))^2 So I enter this expression in the nls function: ratelogis - nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, start=list(a = 21.16322, b = 8.83669, c = 2.957765), ) The data is: Y [1] 5.5199668 1.5234525 3.3557000 6.7211704 7.4237955 1.9703127 [7] 4.3939336 -1.4380091 3.2650180 3.5760906 0.2947972 1.0569417 X [1] 1 0 0 4 3 5 12 10 12 100 100 100 The problem is that I got the next error: Error en nls(Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2, : step factor 0.000488281 reduced below 'minFactor' of 0.000976563 I trien to change the minFactor using the control argument inside nls control=nls.control(maxiter=50, tol=1e-5, minFactor = 1/2048 but got a new error message: Error en nls(Y ~ a * (exp((b - X)/c) * (1/c))/(1 + exp((b - X)/c))^2, : step factor 0.000244141 reduced below 'minFactor' of 0.000488281 So it seems that as I modify minFactor, the step factor reduces also and I can never reach a solution. Does anybody Know what am I doing wrong? Is there a problem with the formula? How can I solve it? I tried some suggestions on R-help related topics but did not work. (Please don't send private messages. I don't do free consulting outside of the mailing lists.) With nls(), there's really no substitute for good data and good starting values. Did you actually try plotting those data? At best, they are extremely noisy. How did you obtain the starting values? They seem remarkably accurate for something that fits data so poorly. What is happening is that the algorithm shoots off into a region of the parameter space where it can't make any progress: ratelogis - nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2,+ start=list(a = 21.16322, b = 8.83669, c = 2.957765),+ trace=TRUE) 151.098 : 21.163220 8.836690 2.957765 127.1149 : 103.49326 11.43274 20.29663 111.344 : 833.02386 -45.86244 140.32985 111.3375 : 978.97214 -76.20571 159.90833 111.3374 : 1097.1376 -101.6771 174.2037 111.3228 : 1179.8451 -119.7416 183.3794 Notice that the b parameter which is supposed to be the maximum point starts off well to the right of the position of the largest Y values, then shoots into large negative values. With a little eyeballing, I can do better: ratelogis - nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, + start=list(a = 40, b = 3.5, c = 10),trace=T) 139.5173 : 40.0 3.5 10.0 97.28614 : 26.513424 4.052639 2.267709 81.53127 : 32.384910 3.473411 2.307504 65.11387 : 39.53542 3.01097 2.07678 50.66328 : 36.223529 2.590102 1.133965 50.50921 : 35.984466 2.565698 1.067731 50.50162 : 36.149993 2.573420 1.081673 50.50145 : 36.129962 2.572195 1.079504 50.50144 : 36.133656 2.572402 1.079862 50.50144 : 36.133061 2.572368 1.079803 However, the fit isn't exactly stellar. Try this: X - c(1, 0, 0, 4, 3, 5, 12, 10, 12, 100, 100, 100) Y - c(5.5199668, 1.5234525, 3.3557, 6.7211704, 7.4237955, 1.9703127, 4.3939336, -1.4380091, 3.265018, 3.5760906, 0.2947972, 1.0569417) plot(X,Y) ratelogis - nls(Y ~ a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2, start=list(a = 40, b = 3.5, c = 10),trace=T) x0 - seq(0,100,,1000) lines(x0,predict(ratelogis,newdata=data.frame(X=x0))) lines(x0,evalq(a*(exp((b-X)/c)*(1/c))/(1 + exp((b-X)/c))^2,envir=list(a = 21.16322, b = 8.83669, c = 2.957765, X=x0)), lty=dashed) -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com -- Francisco Mora Ardila Estudiante de Doctorado Centro de Investigaciones en Ecosistemas Universidad Nacional Autónoma de México __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to add specific column to data.set?
Hi I have a data.set with 7 lists, with over 7000 observations in each list. to of the lists contain country names. like: aus dnk fra aus usa aut itlusa . . . etc. My dilemma is that I want to add an extra column/list to my data.set. If the countries are both european it should be assigned 1 or true AND if one or both the countries are non-european it should be assigned 0 or false. Please et me know if you dont understand my dilemma. Thanks -- View this message in context: http://r.789695.n4.nabble.com/How-to-add-specific-column-to-data-set-tp4565341p4565341.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] puzzling Date math result
A slightly quieter response: Please use dput() to create a reproducible example -- for this case, if x and y aren't too long, it seems that dput(x) and dput(y) would comprise one. str() helps (and thank you for that -- it gave me a place to start), but it doesn't provide quite enough to reproduce here. My guess is that R FAQ 7.31 is in play here... note that storage.mode(as.Date(Sys.Date())) is double not integer, so you need to keep an eye on the floating point gremlins. Michael On Tue, Apr 17, 2012 at 12:25 PM, Calum Polwart ya...@wittongilbert.free-online.co.uk wrote: On Tue, 17 Apr 2012 10:44:40 -0400, Denis Chabot wrote: Hi, I cannot make a reproducible example easily for my problem, so I'll describe it as best as I can. YOU KIND OF NEED ONE... a=test1$période[21] b=test2$date[22] a f argin-left:5px; width:100%b [1] 2011-04-06 THIS IS WHY YOU NEED TO GIVE US A REPRODUCABLE MEANS BECAUSE IF I SIMPLY DO A=2011-04-06 AND B=2011-04-06 I'M GOING TO GET A==B TRUE WHERE IS THE DATA IN THE DF'S BEING SOURCED FROM? IS IT A DATABASE? COULD THERE BE DIFFERENT DATA DEFINITIONS? IS ITS A CSV FILE ETC? and then thi ft:#1010ff 2px solid; margin-left:5px; width:100%as.integer(a) [1] 15070 as.integer(b) [1] 15070 SUGGESTION THAT MIGHT POINT YOU IN A DIRECTION... as.integer (15070) pre as.integer (15070.1) [1] 15070 as.integer (15070)==as.integer(15070.1) [1] TRUE 15070==15070.1 [1] FALSE SECOND SUGGESTION WOULD BE TO DROP THE É NO IDEA WHY THAT WOULD CAUSE A PROBLEM (OR WHERE), BUT ANYTHING THATS NOT A-Z OR A-Z ONLY INTRODUCES A POTENTIAL EXTRA HEADACHE... as.integer(a)==as.integer(b) [[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] How to add specific column to data.set?
Do you have lists or something like a data.frame? Your printout suggests you don't actually have a list. (well, data.frames really are lists but let's just not talk about that) Perhaps %in% is what you are looking for... EU - c(UK,FR,DE) # Yes, I know there are more countries - c(US,CH,UK, CA, MX, FR, DE) countries %in% EU or more to your question cbind(countries, countries %in% EU) or data.frame(Country = countries, EU.Member = countries %in% EU) Michael On Tue, Apr 17, 2012 at 12:40 PM, phillip03 phillipbrig...@hotmail.com wrote: Hi I have a data.set with 7 lists, with over 7000 observations in each list. to of the lists contain country names. like: aus dnk fra aus usa aut itl usa . . . etc. My dilemma is that I want to add an extra column/list to my data.set. If the countries are both european it should be assigned 1 or true AND if one or both the countries are non-european it should be assigned 0 or false. Please et me know if you dont understand my dilemma. Thanks -- View this message in context: http://r.789695.n4.nabble.com/How-to-add-specific-column-to-data-set-tp4565341p4565341.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] How to create a data.frame from several time series?
It's a rather risky idea to call your function aggregate.zoo -- that's actually a pre-existing function and it could (will!) confuse the method dispatch system. In short, S3 methods use the name convention generic.class (e.g., aggregate is the generic and zoo is the class) so when you just use aggregate (a S3 generic function) it looks at the class of the object and if it finds zoo, it will attempt to apply aggregate.zoo to it. E.g., library(zoo) z - zoo(1:100, Sys.Date() + 1:100) aggregate(z, as.Date(as.yearmon(time(z))), mean) # Then I define your function aggregate.zoo - function(series) { agg - aggregate(data=series, value ~ month, ppk, lsl=1300, usl=1500) return (zoo(x=agg$value, order.by=agg$month)) } # Then I go away for a few days and try my same command aggregate(z, as.Date(as.yearmon(time(z))), mean) # What just happened?!?!?! Hope this helps, Michael On Tue, Apr 17, 2012 at 10:11 AM, Robert Latest boblat...@gmail.com wrote: Hello all, followup to yesterday's question: Part of my confusion was caused by my embarrassing mistake of overwriting the ppk function with another object, which of course broke the next iteration of the loop. Secondly, I got exactly what I wanted like this: aggregate.zoo - function(series) { agg - aggregate(data=series, value ~ month, ppk, lsl=1300, usl=1500) return (zoo(x=agg$value, order.by=agg$month)) } l1 = split(df, df$tool) l2 = lapply(l1, aggregate.zoo) l3 = do.call(merge, l2) I puzzled this together from various example with only 80% understanding how it works and why. Regards, robert __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] What functions are available for Quadratically Constrained Quadratic Programming in R?
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Michael Sent: Tuesday, April 17, 2012 9:31 AM To: r-help Subject: Re: [R] What functions are available for Quadratically Constrained Quadratic Programming in R? Looks like we need an SDP solver in R... Any pointers? thanks a lot! On Tue, Apr 17, 2012 at 10:54 AM, Michael comtech@gmail.com wrote: Hi all, Could anybody please point me to the solver function in R on QCQP? The quadprog package seems to be only able to handle the linear constraints... Thank you! library(sos) findFn('semidefinite programming') The above returned 6 results. You might look to see if one of them meets your needs. 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.
[R] Cummerbund differential expression data analysis package issue
Hi all, I'm having the same issue as in this previous post: http://r.789695.n4.nabble.com/R-error-td4200447.html#a4209042 And as another user of Biostar: http://www.biostars.org/post/show/42562/cummerbund-isnt-managing-cuffdiff-database/#42895 Whereby I'm trying to output cuffdiff data into cummeRbund, but it appears to be having issues with connection to a database (below). Does anyone have any suggestions as to how I can fix this? Thanks! cuff_data - readCufflinks('/home/sbica1/tophat/finaltrans/tophat/0125diff_out') Creating database /home/sbica1/tophat/finaltrans/tophat/0125diff_out/cuffData.db Reading /home/sbica1/tophat/finaltrans/tophat/0125diff_out/genes.fpkm_tracking Checking samples table... Populating samples table... Writing genes table Reshaping geneData table Recasting Writing gene Data table Reading /home/sbica1/tophat/finaltrans/tophat/0125diff_out/gene_exp.diff Error in function (classes, fdef, mtable) : unable to find an inherited method for function make.db.names, for signature SQLiteConnection, integer csVolcano(genes(cuff_data),'0',36) Error in .local(object, x, y, features, ...) : One or more values of 'x' or 'y' are not valid sample names! -- View this message in context: http://r.789695.n4.nabble.com/Cummerbund-differential-expression-data-analysis-package-issue-tp4565409p4565409.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] ANOVA Data Error
Hello I am having some trouble performing a simple ANOVA in R I am working with 2001 census tract information regarding religion. I am quite a rookie at this whole R experiance, but I would like to improve my skills. *I read in my data and subset it accordingly to select only the columns I desired. * newottawa=ottawa_census[,c(97,121,124,125,126,127,128,129,130,131,132,133)] newottawa *This is the formula used to try and perform my ANOVA* anovaottawa=aov(newottawa$RomanCatholic~newottawa$UnitedChurch) summary(anovaottawa) The (-) in the formula is actually a tilde in my R code (but it wont show up properly in this email) *My Error Message:* Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : invalid to change the storage mode of a factor In addition: Warning message: In model.response(mf, numeric) : using type=numeric with a factor response will be ignored I fear that my data is in the wrong format or something of that nature and thus R will not allow me to perform analysis on it. Thank you for your time, and have a good one :) -- View this message in context: http://r.789695.n4.nabble.com/ANOVA-Data-Error-tp4565415p4565415.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 add specific column to data.set?
Hi Michael Sorry it is a data frame where to of the columns are 22 countries arranged in random. I now want to add and ekstra column that is 1 if the country par for the specific row is both european countries and 0 if not. Regards -- View this message in context: http://r.789695.n4.nabble.com/How-to-add-specific-column-to-data-set-tp4565341p4565466.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] ANOVA Data Error
On Apr 17, 2012, at 1:03 PM, MatthewJudd wrote: Hello I am having some trouble performing a simple ANOVA in R I am working with 2001 census tract information regarding religion. I am quite a rookie at this whole R experiance, but I would like to improve my skills. *I read in my data and subset it accordingly to select only the columns I desired. * newottawa =ottawa_census[,c(97,121,124,125,126,127,128,129,130,131,132,133)] newottawa *This is the formula used to try and perform my ANOVA* anovaottawa=aov(newottawa$RomanCatholic~newottawa$UnitedChurch) summary(anovaottawa) The (-) in the formula is actually a tilde in my R code (but it wont show up properly in this email) *My Error Message:* Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : invalid to change the storage mode of a factor In addition: Warning message: In model.response(mf, numeric) : using type=numeric with a factor response will be ignored I fear that my data is in the wrong format or something of that nature and thus R will not allow me to perform analysis on it. It would seem passing strange to have a variable named RomanCatholic that was a continuous variable. My guess is that you are not using the function properly. How much experience do you have with regression functions in R ... and a corollary question: is this homework? -- David. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Cummerbund differential expression data analysis package issue
On 04/17/2012 10:02 AM, craigledee wrote: Hi all, I'm having the same issue as in this previous post: http://r.789695.n4.nabble.com/R-error-td4200447.html#a4209042 And as another user of Biostar: http://www.biostars.org/post/show/42562/cummerbund-isnt-managing-cuffdiff-database/#42895 Whereby I'm trying to output cuffdiff data into cummeRbund, but it appears to be having issues with connection to a database (below). Does anyone have any suggestions as to how I can fix this? Thanks! Hi cRaig cummeRbund is a Bioconductor package so ask on the Bioconductor mailing list http://bioconductor.org/help/mailing-list/#bioconductor (without subscribing via http://bioconductor.org/help/mailing-list/mailform/ if that's more convenient) Be sure to include the package maintainer packageDescription(cummeRbund)$Maintainer in the email. Martin cuff_data- readCufflinks('/home/sbica1/tophat/finaltrans/tophat/0125diff_out') Creating database /home/sbica1/tophat/finaltrans/tophat/0125diff_out/cuffData.db Reading /home/sbica1/tophat/finaltrans/tophat/0125diff_out/genes.fpkm_tracking Checking samples table... Populating samples table... Writing genes table Reshaping geneData table Recasting Writing gene Data table Reading /home/sbica1/tophat/finaltrans/tophat/0125diff_out/gene_exp.diff Error in function (classes, fdef, mtable) : unable to find an inherited method for function make.db.names, for signature SQLiteConnection, integer csVolcano(genes(cuff_data),'0',36) Error in .local(object, x, y, features, ...) : One or more values of 'x' or 'y' are not valid sample names! -- View this message in context: http://r.789695.n4.nabble.com/Cummerbund-differential-expression-data-analysis-package-issue-tp4565409p4565409.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. -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 add specific column to data.set?
Reproducible example not provided... try this -- it should generalize to multiple columns: EU - c(UK,FR,DE) # Yes, I know there are more countries - data.frame( country1 = c(US,CH,UK,AU), country2 = c( CA, MX, FR, DE), stringsAsFactors = FALSE) cbind(countries, EU.Membership = Reduce(``, lapply(countries, function(x) x %in% EU))) Michael On Tue, Apr 17, 2012 at 1:24 PM, phillip03 phillipbrig...@hotmail.com wrote: Hi Michael Sorry it is a data frame where to of the columns are 22 countries arranged in random. I now want to add and ekstra column that is 1 if the country par for the specific row is both european countries and 0 if not. Regards -- View this message in context: http://r.789695.n4.nabble.com/How-to-add-specific-column-to-data-set-tp4565341p4565466.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] How to add specific column to data.set?
On Apr 17, 2012, at 1:55 PM, R. Michael Weylandt wrote: Reproducible example not provided... try this -- it should generalize to multiple columns: EU - c(UK,FR,DE) # Yes, I know there are more countries - data.frame( country1 = c(US,CH,UK,AU), country2 = c( CA, MX, FR, DE), stringsAsFactors = FALSE) cbind(countries, EU.Membership = Reduce(``, lapply(countries, function(x) x %in% EU))) I would have thought this to be somewhat clearer: countries$bothEU - (countries$country1 %in% EU) (countries$country2 %in% EU) And, yes, I know the parens weren't actually needed. Michael On Tue, Apr 17, 2012 at 1:24 PM, phillip03 phillipbrig...@hotmail.com wrote: Hi Michael Sorry it is a data frame where to of the columns are 22 countries arranged in random. I now want to add and ekstra column that is 1 if the country par for the specific row is both european countries and 0 if not. Regards David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] parallel processing with multiple directories
Hello, I would like to run some code in parallel with each cluster reading/writing to a different working directory. I've tried the following code without success. The error I get is: Error in setwd(x) : cannot change working directory library(parallel) dirs - list(out1,out2,out3) # these directories are located within the current working directory temp - 1:3 testF - function(x) { setwd(x) saveRDS(temp,temp.drs) } mclapply(dirs, testF) Any help would be appreciated! --David * David R. Schaefer, Ph.D. Assistant Professor School of Social and Family Dynamics Arizona State University www.public.asu.edu/~schaef/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Cummerbund differential expression data analysis package issue
I'll give it a bash, thanks! Craig -- View this message in context: http://r.789695.n4.nabble.com/Cummerbund-differential-expression-data-analysis-package-issue-tp4565409p4565611.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] simple time series plot
I'm an absolute R newbie, but my question is (or at least seems) simple: I have a number of sensor values from different sensors, along with timestamps, so something like this: sensor 1: read_at:1 2 4 5 6 value:1 15 815 23 sensor 2: read_at:23 4 6 7 value: 10 11712 28 what I need is a line plot of the sensor values, aligned given their timestamps (it's in unix epoc time). which data structure should i use? can i import from CSV file? how should I format that data file? which commands do I need to get the plot? is there a simple tutorial (didn't find any). how would you solve this? THANKS a lot! phibo -- View this message in context: http://r.789695.n4.nabble.com/simple-time-series-plot-tp4565579p4565579.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] parallel processing with multiple directories
On Tue, Apr 17, 2012 at 11:06:05AM -0700, David Schaefer wrote: Hello, I would like to run some code in parallel with each cluster reading/writing to a different working directory. I've tried the following code without success. The error I get is: Error in setwd(x) : cannot change working directory library(parallel) dirs - list(out1,out2,out3) # these directories are located within the current working directory temp - 1:3 testF - function(x) { setwd(x) saveRDS(temp,temp.drs) } mclapply(dirs, testF) Hi. Try to include print(getwd()) to testF() function, so that you see, where the script is running. Another option is not to use setwd() and use saveRDS(temp, paste(x, temp.drs, sep=/)) instead of saveRDS(temp,temp.drs). Hope this helps. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] simple time series plot
On Apr 17, 2012, at 2:04 PM, phibo wrote: I'm an absolute R newbie, but my question is (or at least seems) simple: I have a number of sensor values from different sensors, along with timestamps, so something like this: sensor 1: read_at:1 2 4 5 6 value:1 15 815 23 sensor 2: read_at:23 4 6 7 value: 10 11712 28 what I need is a line plot of the sensor values, aligned given their timestamps (it's in unix epoc time). Probably something simple can be done to convert to POSIXct. which data structure should i use? can i import from CSV file? Of course you can. Generally works well. Other separators work as well. how should I format that data file? Can you show us what the file look like by just pasting a few rows into a message which commands do I need to get the plot? is there a simple tutorial (didn't find any). There is the Introduction to R shipped with every installation of R, which is about as simple as it gets. Most people seem to skip that step, but it is packed with crucial concepts and illustrations. how would you solve this? First we need to see how the data looks to a plain text editor. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] some questions about sympy (that is, rSymPy)
see below! On Sat, Apr 14, 2012 at 4:05 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Fri, Apr 13, 2012 at 9:50 PM, Kjetil Halvorsen kjetilbrinchmannhalvor...@gmail.com wrote: I am experimenting with rSymPy, and it seems to work nice. However, I dislike the need to wrap all sympy expressions within quotes, it leads to ugly calls like library(rSymPy) Var(x,y,z) sympy((x+y)**2) and so on. Suggest you review the rSymPy home page which illustrates how to use the Sym interface, e.g. library(rSymPy) x - Var(x) y - Var(y) (x+y)*(x+y) [1] (x + y)**2 Thanks! But there seems to be errors in that interface. First: sessionInfo() R version 2.15.0 (2012-03-30) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rSymPy_0.2-1.1 rJython_0.0-2 rjson_0.2.8rJava_0.9-3pnmath_0.0-3 [6] MASS_7.3-17 loaded via a namespace (and not attached): [1] compiler_2.15.0 fortunes_1.5-0 tools_2.15.0 x - Var('x') y - x*x deriv(y, x, 2) [1] 2 z - exp(-x) Error in match(.Generic, transtab[, 1], nomatch = 0) : object 'transtab' not found Math.Sym function (x, ...) { idx - match(.Generic, transtab[, 1], nomatch = 0) fn - if (idx 0) transtab[idx, 3] else .Generic Sym(fn, (, x, )) } bytecode: 0x31a42b0 environment: namespace:rSymPy Kjetil -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] parallel processing with multiple directories
On 04/17/2012 11:06 AM, David Schaefer wrote: Hello, I would like to run some code in parallel with each cluster reading/writing to a different working directory. I've tried the following code without success. The error I get is: Error in setwd(x) : cannot change working directory library(parallel) dirs- list(out1,out2,out3) # these directories are located within the current working directory temp- 1:3 testF- function(x) { setwd(x) saveRDS(temp,temp.drs) } mclapply(dirs, testF) Any help would be appreciated! Hi David, Suppose that jobs 1 and 3 are executed on processor 2. Then after the first iteration the directory is ./out1 and on the second iteration setwd() tries to change to ./out1/out3. Full path names might help. My unasked-for advice would be to put 'more' of the processing in testF, so that it is reasonable to return and then aggregate the results without writing to disk. Martin --David * David R. Schaefer, Ph.D. Assistant Professor School of Social and Family Dynamics Arizona State University www.public.asu.edu/~schaef/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 sympy (that is, rSymPy)
On Tue, Apr 17, 2012 at 4:00 PM, Kjetil Halvorsen kjetilbrinchmannhalvor...@gmail.com wrote: see below! On Sat, Apr 14, 2012 at 4:05 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Fri, Apr 13, 2012 at 9:50 PM, Kjetil Halvorsen kjetilbrinchmannhalvor...@gmail.com wrote: I am experimenting with rSymPy, and it seems to work nice. However, I dislike the need to wrap all sympy expressions within quotes, it leads to ugly calls like library(rSymPy) Var(x,y,z) sympy((x+y)**2) and so on. Suggest you review the rSymPy home page which illustrates how to use the Sym interface, e.g. library(rSymPy) x - Var(x) y - Var(y) (x+y)*(x+y) [1] (x + y)**2 Thanks! But there seems to be errors in that interface. First: That's just a missing feature -- there are many -- rSymPy is only partly developed but its developed enough that its trivial to add your own: Exp - function(x) Sym(exp(, x, )) Exp(-x) * Exp(x) [1] 1 -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sweave problem after R update version
I would notice this error compiling a Sweave document after I updated R from version 2.14.2 to 2.15.0: Error in driver$finish(drobj) : the output file 'MyDocument.tex' has disappeared Calls: Anonymous - do.call - Anonymous - Anonymous Execution halted Do you have any suggestion? Regards Riccardo Sent from iPod [[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] Can a matrix have 'list' as rows/columns?
On Tue, Apr 17, 2012 at 11:52 PM, David Winsemius dwinsem...@comcast.netwrote: On Apr 17, 2012, at 12:13 AM, Worik R wrote: After a lot of processing I get a matrix into M. I expected each row and column to be a vector. But it is a list. This behavior is not the result of limitation in how R's sapply might have processed a purely numeric set of results, but is because you (probably) returned a hetergeneous set of classes rom you inner function. Assuming that last is actually function(x){tail,1}, then the structure of M is str(M) List of 6 [snip] ..$ : chr [1:3] aaa bbb ccc Had the result been a more homogeneous collection, I sapply would have returned an array of atomic numeric vectors. Try just returning a number: M2 - sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,Value])}, DF) Yes that returns a vector. I want a matrix. I see that my problem is that the columns of DF are not all the same type. Once I did that (made Value character) I get my matrix just as I need. SO it was I passed *in* that was the problem Not what I did with it inside sapply. In this case I would expect M to be a list. I am gobsmacked that a list can be considered a vector.Is that a bug? It must be bad design? I have been using R for a number of years (5?) and heavilly for two years. I am still getting bitten by these features in R. To my mind there are many places that R violates the *principle of least surprise. But it may be my mind that is at fault! What are other people's experience?* Worik class(M) [1] numeric str(M2) Named num [1:3] 0.6184 0.0446 0.3605 - attr(*, names)= chr [1:3] aaa bbb ccc -- David. R-Inferno says... Arrays (including matrices) can be subscripted with a matrix of positive numbers. The subscripting matrix has as many columns as there are dimensions in the arrayso two columns for a matrix. The result is a vector (not an array) containing the selected items. My version of R: version.string R version 2.12.1 (2010-12-16) Here is an example... Qm - c(aaa, bbb, ccc) DF - data.frame(Name=sample(Qm, replace=TRUE, size=22), Value=runif(22), stringsAsFactors=FALSE) M - sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,])}, DF) class(M) [1] matrix class(M[,1]) [1] list class(M[1,]) [1] list M aaa bbb ccc Name aaa bbbccc Value 0.4702648 0.274498 0.5529691 DF Name Value 1 ccc 0.99948920 2 aaa 0.51921281 3 aaa 0.10803943 4 aaa 0.82265847 5 ccc 0.83237260 6 bbb 0.88250933 7 aaa 0.41836131 8 aaa 0.66197290 9 ccc 0.01911771 10 ccc 0.4699 11 bbb 0.35719884 12 ccc 0.86274858 13 bbb 0.57528579 14 aaa 0.12452158 15 aaa 0.44167731 16 aaa 0.11660019 17 ccc 0.55296911 18 aaa 0.12796890 19 bbb 0.44595741 20 bbb 0.93024768 21 aaa 0.47026475 22 bbb 0.27449801 [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT [[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] Sweave problem after R update version
On 12-04-17 5:35 PM, Riccardo Romoli wrote: I would notice this error compiling a Sweave document after I updated R from version 2.14.2 to 2.15.0: Error in driver$finish(drobj) : the output file 'MyDocument.tex' has disappeared Calls:Anonymous - do.call - Anonymous - Anonymous Execution halted Do you have any suggestion? Yes, simplify your document as much as possible to still keep triggering the error. Chances are you'll see what's causing it, but if not, post the simplest bad version here, and someone else will likely be able to help you. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] random effects using lmer
Hi, I am trying to run a logistic regression to look at the risk of malaria infection in individuals. I want to account for intra household correlation and so want to include a household level random effect. I have been using the lmer command in lme4 package but am getting some strange results that are completely different to those I get using STATA. Can I just check that this is the correct code lmer(IsPos ~ Dist + (1 | HouseID), family=binomial) Where IsPos is a binary vector of positives and negatives, Dist is the variable of interest and HouseID is the household ID number. For those STATA users, the equivalent I'm using is xtlogit IsPos Dist, i(HouseID) Any help would be much appreciated..! Thanks! Hugh -- View this message in context: http://r.789695.n4.nabble.com/random-effects-using-lmer-tp4566030p4566030.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] Method=df for coxph in survival package
I've been following the example in the R help page: http://stat.ethz.ch/R-manual/R-devel/library/survival/html/frailty.html library(survival); coxph(Surv(time, status) ~ age + frailty(inst, df=4), lung) Here, in this particular example they fixed the degrees of freedom for the random institution effects to be 4. But, how did they decide? This clearly can't be the number of institutions as there are 19 institutions. length(unique(lung$inst)) [1] 19 But, how to decide what degrees of freedom to specify for your random institution effect? What was the reason they chose df=4? Can anyone please direct me (Reference or explanations) how to decide what df to use for the frailty terms? Thank you very much. Dave -- View this message in context: http://r.789695.n4.nabble.com/Method-df-for-coxph-in-survival-package-tp4566006p4566006.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] Manually reconstructing arima model from coefficients
Colleagues I am a new to R but already love it. I have the following problem: I fitted arima model to my time series like this (please ignore modeling parameters as they are not important now): x = scan(C:/data.txt) x = ts(x, start=1, frequency=1) x.fit-arima(x, order = c(1,0,0), seasonal = list(order=c(0,0,1))) Now I want to use this model for forecasting and backtesting (!). My goal is to apply exactly this model to different data – another time series object, let’s call it “y”. How can I do this in R. One of the options is to extract coefficients and to create my own function that can be applied to any time series but I suspect and hope that there is a better way of doing this. If there is not an easy option can anyone suggest a complete equation that includes seasonal terms that can be easily programmed (for example in C) for a person who knows some programming but very little math. Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Manually-reconstructing-arima-model-from-coefficients-tp4566082p4566082.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] Error with Rcmd check library --as-cran
Hello all, I was checking the newest update of my library before submitting it to CRAN, using R 2.15.0 and Rtools for Windows 215 using Rcmd in the Command Prompt, on my x64 Windows7 laptop. I recently heard that for checking packages for CRAN submission one should use the option --as-cran; previously I was submitting packages, so I was trying that for the first time. The check proceeds fine until it tries running the examples, at which point it produces the following error message: pkgname - paleotree source(file.path(R.home(share), R, examples-header.R)) options(warn = 1) options(pager = console) library('paleotree') Loading required package: ape Error in loadNamespace(i, c(lib.loc, .libPaths())) : there is no package called 'Matrix' Error: package/namespace load failed for 'paleotree' Execution halted My package depends on ape, but not Matrix. Matrix is installed, though, on my workstation, as are the other ape dependencies. The check works fine by default and with the --timings option. What is different about --as-cran that makes it unable to find Matrix? Thanks for the help, -Dave Bapst, UChicago -- David Bapst Dept of Geophysical Sciences University of Chicago 5734 S. Ellis Chicago, IL 60637 http://home.uchicago.edu/~dwbapst/ http://cran.r-project.org/web/packages/paleotree/index.html http://home.uchicago.edu/%7Edwbapst/ [[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] Sum part of row and add this as a new column vector
Hello, Try df1 - read.table(text= County 1990 1991 1992 1993 Alachua 1 1 1 1 Baker 0 0 0 0 Bay 0 0 1 0 Bradford 0 0 0 0 , header=TRUE) df1$Total - rowSums(df1[ , -1]) # Not column 1 df1$Total - rowSums(df1[ , 2:5])# Explicit column numbers Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Sum-part-of-row-and-add-this-as-a-new-column-vector-tp4566097p4566155.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] Can a matrix have 'list' as rows/columns?
On Apr 17, 2012, at 7:27 PM, Worik R wrote: On Tue, Apr 17, 2012 at 11:52 PM, David Winsemius dwinsem...@comcast.net wrote: On Apr 17, 2012, at 12:13 AM, Worik R wrote: After a lot of processing I get a matrix into M. I expected each row and column to be a vector. But it is a list. This behavior is not the result of limitation in how R's sapply might have processed a purely numeric set of results, but is because you (probably) returned a hetergeneous set of classes rom you inner function. Assuming that last is actually function(x){tail,1}, then the structure of M is str(M) List of 6 [snip] ..$ : chr [1:3] aaa bbb ccc Had the result been a more homogeneous collection, I sapply would have returned an array of atomic numeric vectors. Try just returning a number: M2 - sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,Value])}, DF) Yes that returns a vector. I want a matrix. I see that my problem is that the columns of DF are not all the same type. Once I did that (made Value character) I get my matrix just as I need. SO it was I passed *in* that was the problem Not what I did with it inside sapply. In this case I would expect M to be a list. I am gobsmacked that a list can be considered a vector.Is that a bug? No. It is by design. list is an acceptable storage mode for vector(). It must be bad design? That is (obviously) a matter of opinion. R is in the middle region between LiSP and a strongly typed language. I have been using R for a number of years (5?) and heavilly for two years. I am still getting bitten by these features in R. To my mind there are many places that R violates the *principle of least surprise. I keep getting surprises as well. I did experience surprise at the point I saw that is.vector() returning TRUE for a list. I think that means that is.vector is rather less informative than I expected. Essentially only language objects fail: z - as.formula(x ~ y) z x ~ y is.vector(z) [1] FALSE Even expressions are vectors: z - expression( x ~ y) z expression(x ~ y) is.vector(z) [1] TRUE But it may be my mind that is at fault! What are other people's experience?* I still have not fully wrapped my head around the higher levels of the language. I thought reading Chamber's book would help, but it had too much prose and did not present enough worked examples to sync with my learning style. I'm still looking for a book that lets me use the language more effectively. -- David. Worik class(M) [1] numeric str(M2) Named num [1:3] 0.6184 0.0446 0.3605 - attr(*, names)= chr [1:3] aaa bbb ccc -- David. R-Inferno says... Arrays (including matrices) can be subscripted with a matrix of positive numbers. The subscripting matrix has as many columns as there are dimensions in the arrayso two columns for a matrix. The result is a vector (not an array) containing the selected items. My version of R: version.string R version 2.12.1 (2010-12-16) Here is an example... Qm - c(aaa, bbb, ccc) DF - data.frame(Name=sample(Qm, replace=TRUE, size=22), Value=runif(22), stringsAsFactors=FALSE) M - sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,])}, DF) class(M) [1] matrix class(M[,1]) [1] list class(M[1,]) [1] list M aaa bbb ccc Name aaa bbbccc Value 0.4702648 0.274498 0.5529691 DF Name Value 1 ccc 0.99948920 2 aaa 0.51921281 3 aaa 0.10803943 4 aaa 0.82265847 5 ccc 0.83237260 6 bbb 0.88250933 7 aaa 0.41836131 8 aaa 0.66197290 9 ccc 0.01911771 10 ccc 0.4699 11 bbb 0.35719884 12 ccc 0.86274858 13 bbb 0.57528579 14 aaa 0.12452158 15 aaa 0.44167731 16 aaa 0.11660019 17 ccc 0.55296911 18 aaa 0.12796890 19 bbb 0.44595741 20 bbb 0.93024768 21 aaa 0.47026475 22 bbb 0.27449801 David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Manually reconstructing arima model from coefficients
What exactly do you mean by apply it to a different data set? Unlike regular regressions, time series models don't (generally) use new data to make forecasts ... By the way, this is a good guide to the time series functionality available in R: http://cran.r-project.org/web/views/TimeSeries.html Michael On Tue, Apr 17, 2012 at 5:54 PM, sergey777 ssam...@uwo.ca wrote: Colleagues I am a new to R but already love it. I have the following problem: I fitted arima model to my time series like this (please ignore modeling parameters as they are not important now): x = scan(C:/data.txt) x = ts(x, start=1, frequency=1) x.fit-arima(x, order = c(1,0,0), seasonal = list(order=c(0,0,1))) Now I want to use this model for forecasting and backtesting (!). My goal is to apply exactly this model to different data – another time series object, let’s call it “y”. How can I do this in R. One of the options is to extract coefficients and to create my own function that can be applied to any time series but I suspect and hope that there is a better way of doing this. If there is not an easy option can anyone suggest a complete equation that includes seasonal terms that can be easily programmed (for example in C) for a person who knows some programming but very little math. Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Manually-reconstructing-arima-model-from-coefficients-tp4566082p4566082.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] Error with Rcmd check library --as-cran
paleotree imports phangorn which depends on Matrix, so your example does indeed depend on Matrix. A possible reason is that your installed Matrix was built for a different version of R, i.e. check packageDescription(Matrix). /Henrik On Tue, Apr 17, 2012 at 4:23 PM, David Bapst dwba...@uchicago.edu wrote: Hello all, I was checking the newest update of my library before submitting it to CRAN, using R 2.15.0 and Rtools for Windows 215 using Rcmd in the Command Prompt, on my x64 Windows7 laptop. I recently heard that for checking packages for CRAN submission one should use the option --as-cran; previously I was submitting packages, so I was trying that for the first time. The check proceeds fine until it tries running the examples, at which point it produces the following error message: pkgname - paleotree source(file.path(R.home(share), R, examples-header.R)) options(warn = 1) options(pager = console) library('paleotree') Loading required package: ape Error in loadNamespace(i, c(lib.loc, .libPaths())) : there is no package called 'Matrix' Error: package/namespace load failed for 'paleotree' Execution halted My package depends on ape, but not Matrix. Matrix is installed, though, on my workstation, as are the other ape dependencies. The check works fine by default and with the --timings option. What is different about --as-cran that makes it unable to find Matrix? Thanks for the help, -Dave Bapst, UChicago -- David Bapst Dept of Geophysical Sciences University of Chicago 5734 S. Ellis Chicago, IL 60637 http://home.uchicago.edu/~dwbapst/ http://cran.r-project.org/web/packages/paleotree/index.html http://home.uchicago.edu/%7Edwbapst/ [[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] How to add specific column to data.set?
This is the first and last part of my data frame. There is 3465 (not 7000) observations so the 1 or 0 column has to be 3465 rows long aswell year country1 country2 contig comlangpop1gdp1 pop2 gdp2 rtadist avgflow 11992 AUS AUT 0 0 17.4950008 321708.281 7.7825189 194684.078 0 15608.4 1.075999e+02 21992 AUS BEL 0 0 17.4950008 321708.281 10.0450001 231762.094 0 16319.2 4.767162e+02 31992 AUS CAN 0 1 17.4950008 321708.281 28.5195980 570291.188 0 15391.1 7.456945e+02 41992 AUS CHE 0 0 17.4950008 321708.281 6.875 249471.422 0 16170.1 4.625214e+02 51992 AUS DEU 0 0 17.4950008 321708.281 80.6240005 2062141.500 0 15935.1 2.047573e+03 . . . . . . 3461 2006 NZL SWE 0 0 4.1253757 103873.211 9.0457277 384927.281 0 17389.6 1.371846e+02 3462 2006 NZL USA 0 1 4.1253757 103873.211 298.9880981 13201819.000 0 12765.8 3.273475e+03 3463 2006 PRT SWE 0 0 10.5896521 192571.922 9.0457277 384927.281 1 2821.6 6.624816e+02 3464 2006 PRT USA 0 0 10.5896521 192571.922 298.9880981 13201819.000 0 7004.5 2.381285e+03 3465 2006 SWE USA 0 0 9.0457277 384927.281 298.9880981 13201819.000 0 7440.5 9.35e+03 -- View this message in context: http://r.789695.n4.nabble.com/How-to-add-specific-column-to-data-set-tp4565341p4566008.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] Error in eval when using contrast and nlme
Hi everybody, I've written a function to run an LME model on data derived from functional magnetic resonance images. When I run the function with contrasts included I get the following error Error in eval(expr, envir, enclos) : object 'inModelFormula' not found I think it has something do do with the way contrast evaluates arguments, but I've got no idea how to fix it. The code attached below demonstrates the problem. Could anyone advise on how to fix/eliminate the problem? -8-- rm(list=ls()) library(nlme) library(contrast) model = structure(list(subject = structure(c(1L, 2L, 3L, 10L, 11L, 12L, 15L, 18L, 20L, 27L, 31L, 34L, 36L, 35L, 33L, 37L, 40L, 39L, 41L, 38L, 42L, 5L, 6L, 7L, 8L, 13L, 22L, 14L, 21L, 19L, 25L, 23L, 24L, 16L, 28L, 26L, 30L, 9L, 29L, 32L, 17L, 4L, 1L, 2L, 3L, 10L, 11L, 12L, 15L, 18L, 20L, 27L, 31L, 34L, 36L, 35L, 33L, 37L, 40L, 39L, 41L, 38L, 42L, 5L, 6L, 7L, 8L, 13L, 22L, 14L, 21L, 19L, 25L, 23L, 24L, 16L, 28L, 26L, 30L, 9L, 29L, 32L, 17L, 4L, 1L, 2L, 3L, 10L, 11L, 12L, 15L, 18L, 20L, 27L, 31L, 34L, 36L, 35L, 33L, 37L, 40L, 39L, 41L, 38L, 42L, 5L, 6L, 7L, 8L, 13L, 22L, 14L, 21L, 19L, 25L, 23L, 24L, 16L, 28L, 26L, 30L, 9L, 29L, 32L, 17L, 4L, 1L, 2L, 3L, 10L, 11L, 12L, 15L, 18L, 20L, 27L, 31L, 34L, 36L, 35L, 33L, 37L, 40L, 39L, 41L, 38L, 42L, 5L, 6L, 7L, 8L, 13L, 22L, 14L, 21L, 19L, 25L, 23L, 24L, 16L, 28L, 26L, 30L, 9L, 29L, 32L, 17L, 4L, 1L, 2L, 3L, 10L, 11L, 12L, 15L, 18L, 20L, 27L, 31L, 34L, 36L, 35L, 33L, 37L, 40L, 39L, 41L, 38L, 42L, 5L, 6L, 7L, 8L, 13L, 22L, 14L, 21L, 19L, 25L, 23L, 24L, 16L, 28L, 26L, 30L, 9L, 29L, 32L, 17L, 4L), .Label = c(T0004, T0005, T0009, T0020, T0026, T0030, T0049, T0050, T0072, T0078, T0079, T0080, T0083, T0085, T0094, T0104, T0105, T0111, T0112, T0113, T0114, T0115, T0119, T0131, T0136, T0141, T0143, T0150, T0152, T0162, T0167, T0196, T0198, T0216, T0217, T0218, T0219, T0244, T0245, T0246, T0253, T0262), class = factor), group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(A, B), class = factor), brik = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c(20r, 40r, 80r, neg40r, neg80r), class = factor), scanner = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L,
Re: [R] Error with Rcmd check library --as-cran
On Apr 17, 2012, at 9:15 PM, Henrik Bengtsson wrote: paleotree imports phangorn which depends on Matrix, so your example does indeed depend on Matrix. A possible reason is that your installed Matrix was built for a different version of R, i.e. check packageDescription(Matrix). I thought Matrix was included by default as of a couple of R versions ago? -- David. /Henrik On Tue, Apr 17, 2012 at 4:23 PM, David Bapst dwba...@uchicago.edu wrote: Hello all, I was checking the newest update of my library before submitting it to CRAN, using R 2.15.0 and Rtools for Windows 215 using Rcmd in the Command Prompt, on my x64 Windows7 laptop. I recently heard that for checking packages for CRAN submission one should use the option --as-cran; previously I was submitting packages, so I was trying that for the first time. The check proceeds fine until it tries running the examples, at which point it produces the following error message: pkgname - paleotree source(file.path(R.home(share), R, examples-header.R)) options(warn = 1) options(pager = console) library('paleotree') Loading required package: ape Error in loadNamespace(i, c(lib.loc, .libPaths())) : there is no package called 'Matrix' Error: package/namespace load failed for 'paleotree' Execution halted My package depends on ape, but not Matrix. Matrix is installed, though, on my workstation, as are the other ape dependencies. The check works fine by default and with the --timings option. What is different about --as- cran that makes it unable to find Matrix? Thanks for the help, -Dave Bapst, UChicago -- David Bapst Dept of Geophysical Sciences University of Chicago 5734 S. Ellis Chicago, IL 60637 http://home.uchicago.edu/~dwbapst/ http://cran.r-project.org/web/packages/paleotree/index.html http://home.uchicago.edu/%7Edwbapst/ [[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. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to add specific column to data.set?
Ok, so you simply need to use the methods David or I provided -- it looks like you don't even have to change the variable names... Is there something that isn't clear now? Also, reproducible examples are much better if you use dput() so they are actually reproducible Michael On Tue, Apr 17, 2012 at 5:17 PM, phillip03 phillipbrig...@hotmail.com wrote: This is the first and last part of my data frame. There is 3465 (not 7000) observations so the 1 or 0 column has to be 3465 rows long aswell year country1 country2 contig comlang pop1 gdp1 pop2 gdp2 rta dist avgflow 1 1992 AUS AUT 0 0 17.4950008 321708.281 7.7825189 194684.078 0 15608.4 1.075999e+02 2 1992 AUS BEL 0 0 17.4950008 321708.281 10.0450001 231762.094 0 16319.2 4.767162e+02 3 1992 AUS CAN 0 1 17.4950008 321708.281 28.5195980 570291.188 0 15391.1 7.456945e+02 4 1992 AUS CHE 0 0 17.4950008 321708.281 6.875 249471.422 0 16170.1 4.625214e+02 5 1992 AUS DEU 0 0 17.4950008 321708.281 80.6240005 2062141.500 0 15935.1 2.047573e+03 . . . . . . 3461 2006 NZL SWE 0 0 4.1253757 103873.211 9.0457277 384927.281 0 17389.6 1.371846e+02 3462 2006 NZL USA 0 1 4.1253757 103873.211 298.9880981 13201819.000 0 12765.8 3.273475e+03 3463 2006 PRT SWE 0 0 10.5896521 192571.922 9.0457277 384927.281 1 2821.6 6.624816e+02 3464 2006 PRT USA 0 0 10.5896521 192571.922 298.9880981 13201819.000 0 7004.5 2.381285e+03 3465 2006 SWE USA 0 0 9.0457277 384927.281 298.9880981 13201819.000 0 7440.5 9.35e+03 -- View this message in context: http://r.789695.n4.nabble.com/How-to-add-specific-column-to-data-set-tp4565341p4566008.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] Error with Rcmd check library --as-cran
On 12-04-17 9:21 PM, David Winsemius wrote: On Apr 17, 2012, at 9:15 PM, Henrik Bengtsson wrote: paleotree imports phangorn which depends on Matrix, so your example does indeed depend on Matrix. A possible reason is that your installed Matrix was built for a different version of R, i.e. check packageDescription(Matrix). I thought Matrix was included by default as of a couple of R versions ago? It is. There are some problems in 2.15.0 in checking whether package dependencies are present; they only show up on some Windows systems. If you can, please try the checks on R-patched, and see if you get the same problem. If you do, and can send me the tarball, I'll try it on my system. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] puzzling Date math result
Thank you both to Michael and Calum, Your comments pointed me to the answer. I did not succeed in making a useful reproducible example using dput(), so I'll have to study that command further. But it is no longer necessary for this thread to have a successful end. Your comments about floating point gremlins, and the reminder that as.integer (15070.1) is 15070, made me realize that I should have used as.numeric(), not as.integer(), to see what was going on. The two dates were indeed different, one was 15070.3. I went back to the many operations I did to create the offending dataframe and realized that I aggregated two small samples together and attributed to them the mean date (literally using the mean function on the 2 dates). As the result looked normal in Date format, I thought all was well. Lesson learned. Thanks again and sorry to have been a bit quick to resort to the list on this one. Denis Le 2012-04-17 à 12:53, R. Michael Weylandt a écrit : A slightly quieter response: Please use dput() to create a reproducible example -- for this case, if x and y aren't too long, it seems that dput(x) and dput(y) would comprise one. str() helps (and thank you for that -- it gave me a place to start), but it doesn't provide quite enough to reproduce here. My guess is that R FAQ 7.31 is in play here... note that storage.mode(as.Date(Sys.Date())) is double not integer, so you need to keep an eye on the floating point gremlins. Michael On Tue, Apr 17, 2012 at 12:25 PM, Calum Polwart ya...@wittongilbert.free-online.co.uk wrote: On Tue, 17 Apr 2012 10:44:40 -0400, Denis Chabot wrote: Hi, I cannot make a reproducible example easily for my problem, so I'll describe it as best as I can. YOU KIND OF NEED ONE... a=test1$période[21] b=test2$date[22] a f argin-left:5px; width:100%b [1] 2011-04-06 THIS IS WHY YOU NEED TO GIVE US A REPRODUCABLE MEANS BECAUSE IF I SIMPLY DO A=2011-04-06 AND B=2011-04-06 I'M GOING TO GET A==B TRUE WHERE IS THE DATA IN THE DF'S BEING SOURCED FROM? IS IT A DATABASE? COULD THERE BE DIFFERENT DATA DEFINITIONS? IS ITS A CSV FILE ETC? and then thi ft:#1010ff 2px solid; margin-left:5px; width:100%as.integer(a) [1] 15070 as.integer(b) [1] 15070 SUGGESTION THAT MIGHT POINT YOU IN A DIRECTION... as.integer (15070) pre as.integer (15070.1) [1] 15070 as.integer (15070)==as.integer(15070.1) [1] TRUE 15070==15070.1 [1] FALSE SECOND SUGGESTION WOULD BE TO DROP THE É NO IDEA WHY THAT WOULD CAUSE A PROBLEM (OR WHERE), BUT ANYTHING THATS NOT A-Z OR A-Z ONLY INTRODUCES A POTENTIAL EXTRA HEADACHE... as.integer(a)==as.integer(b) [[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] Manually reconstructing arima model from coefficients
Michael My final goal is to perform forecasting in real time. My historical data that is used for training consist of about 2000 samples. Fitting ARIMA model x.fit-arima(x, order = c(5,0,0), seasonal = list(order=c(0,0,1))) takes about 3-5 minutes, often I do not have so much time between receiving new samples of data. Therefore, I want to re-create my arima model let's say only every 50 samples but I want to update my forecast every time new data sample arrives (in a real time). In other words I want to apply my arima model to forecasting future events that will occurre not right after the model was created but some time later after a few more intermediate samples were received. I think this problem is similar to applying already fitted arima forecasting to a new time series object that has similar statistical properties as a tested set, since these are the same series just shifted in the future. [[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] introducing R to high school students
I participate peripherally on a listserve for middle- and high-school science teachers. Sometimes questions about graphing or data analysis come up. I never miss an opportunity to advocate for R. However, the teachers are often skeptical that their students would be able to issue commands or write a little code; they think it would be too difficult. Perhaps this stems from the Microsoft- and spreadsheet-centered, pointy-clicky culture prevalent in most US public schools. Then again, I have little experience teaching this age group, besides my own kids and my Science Olympiad team, so I respect their concerns and expertise. I don't know yet what software they generally use, but I suspect MS Excel and SPSS. Now I have to put my money where my mouth is. I've offered to visit a high school and introduce R to some fairly advanced students participating in a longitudinal 3-year science research class. I anticipate keeping things very simple: --objects and the fact that there is stuff inside them. str(), head(), tail() --how to get data into R --dataframes, as I imagine they will mostly be using single, rectangular datasets --a lot of graphics (I can't imagine that plot(force, acceleration) is beyond a high-schooler's capability.) --simple descriptive statistics --maybe t-tests, chi-square tests, and simple linear regression. Alas, probably more than we would have time to cover. Has anyone done anything with R in high schools? Thanks. --Chris Ryan SUNY Upstate Medical University Binghamton Clinical Campus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] introducing R to high school students
In addition to whatever feedback you may get here, you might subscribe to the SIG-Teaching list for another interested population. Michael On Tue, Apr 17, 2012 at 10:46 PM, Christopher W Ryan cr...@binghamton.edu wrote: I participate peripherally on a listserve for middle- and high-school science teachers. Sometimes questions about graphing or data analysis come up. I never miss an opportunity to advocate for R. However, the teachers are often skeptical that their students would be able to issue commands or write a little code; they think it would be too difficult. Perhaps this stems from the Microsoft- and spreadsheet-centered, pointy-clicky culture prevalent in most US public schools. Then again, I have little experience teaching this age group, besides my own kids and my Science Olympiad team, so I respect their concerns and expertise. I don't know yet what software they generally use, but I suspect MS Excel and SPSS. Now I have to put my money where my mouth is. I've offered to visit a high school and introduce R to some fairly advanced students participating in a longitudinal 3-year science research class. I anticipate keeping things very simple: --objects and the fact that there is stuff inside them. str(), head(), tail() --how to get data into R --dataframes, as I imagine they will mostly be using single, rectangular datasets --a lot of graphics (I can't imagine that plot(force, acceleration) is beyond a high-schooler's capability.) --simple descriptive statistics --maybe t-tests, chi-square tests, and simple linear regression. Alas, probably more than we would have time to cover. Has anyone done anything with R in high schools? Thanks. --Chris Ryan SUNY Upstate Medical University Binghamton Clinical Campus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Can a matrix have 'list' as rows/columns?
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Worik R Sent: Tuesday, April 17, 2012 4:28 PM To: r-help Subject: Re: [R] Can a matrix have 'list' as rows/columns? On Tue, Apr 17, 2012 at 11:52 PM, David Winsemius dwinsem...@comcast.netwrote: On Apr 17, 2012, at 12:13 AM, Worik R wrote: After a lot of processing I get a matrix into M. I expected each row and column to be a vector. But it is a list. This behavior is not the result of limitation in how R's sapply might have processed a purely numeric set of results, but is because you (probably) returned a hetergeneous set of classes rom you inner function. Assuming that last is actually function(x){tail,1}, then the structure of M is str(M) List of 6 [snip] ..$ : chr [1:3] aaa bbb ccc Had the result been a more homogeneous collection, I sapply would have returned an array of atomic numeric vectors. Try just returning a number: M2 - sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,Value])}, DF) Yes that returns a vector. I want a matrix. I see that my problem is that the columns of DF are not all the same type. Once I did that (made Value character) I get my matrix just as I need. SO it was I passed *in* that was the problem Not what I did with it inside sapply. In this case I would expect M to be a list. I am gobsmacked that a list can be considered a vector.Is that a bug? It must be bad design? I have been using R for a number of years (5?) and heavilly for two years. I am still getting bitten by these features in R. To my mind there are many places that R violates the *principle of least surprise. But it may be my mind that is at fault! What are other people's experience?* Since a matrix may contain logical, integer, numeric (double precision), complex, and character data, I would be surprised if it didn't also handle list data. I am surprised that a matrix cannot contain factor data. z - matrix(factor(letters[1:6], levels=letters[1:10]), nrow=2) z [,1] [,2] [,3] [1,] a c e [2,] b d f str(z) chr [1:2, 1:3] a b c d e f Different things surprise different people. You might try using vapply() instead of sapply(). It forces you to supply what you expect the output of FUN(X[[i]]) to look like and will stop with an explicit error message if it doesn't match your expectation on any iteration. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com Worik class(M) [1] numeric str(M2) Named num [1:3] 0.6184 0.0446 0.3605 - attr(*, names)= chr [1:3] aaa bbb ccc -- David. R-Inferno says... Arrays (including matrices) can be subscripted with a matrix of positive numbers. The subscripting matrix has as many columns as there are dimensions in the array-so two columns for a matrix. The result is a vector (not an array) containing the selected items. My version of R: version.string R version 2.12.1 (2010-12-16) Here is an example... Qm - c(aaa, bbb, ccc) DF - data.frame(Name=sample(Qm, replace=TRUE, size=22), Value=runif(22), stringsAsFactors=FALSE) M - sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,])}, DF) class(M) [1] matrix class(M[,1]) [1] list class(M[1,]) [1] list M aaa bbb ccc Name aaa bbbccc Value 0.4702648 0.274498 0.5529691 DF Name Value 1 ccc 0.99948920 2 aaa 0.51921281 3 aaa 0.10803943 4 aaa 0.82265847 5 ccc 0.83237260 6 bbb 0.88250933 7 aaa 0.41836131 8 aaa 0.66197290 9 ccc 0.01911771 10 ccc 0.4699 11 bbb 0.35719884 12 ccc 0.86274858 13 bbb 0.57528579 14 aaa 0.12452158 15 aaa 0.44167731 16 aaa 0.11660019 17 ccc 0.55296911 18 aaa 0.12796890 19 bbb 0.44595741 20 bbb 0.93024768 21 aaa 0.47026475 22 bbb 0.27449801 [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r- helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT [[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] introducing R to high school students
Hi Chris, I am not sure, whether introducing R to High School students would be a good idea as I feel we should encourage students to sketch the graphs in paper to get their concepts right. Excel is fine, but - if I write an equation on the board, will the student be able to visualize its graph? Allowing students to use software to plot graphs at a very early age may hinder that learning. What I would focus on (as the teacher pointed out - that they may not be able to write code) - is being able to write simple codes to get a grasp on programming (they can use QBASIC which is one of the simplest programming softwares). R to my mind should be introduced at an undergraduate level - where they are able to use its real power (vectors, matrices, graphics etc.). Thats my view :) Regards, Indrajit From: Christopher W Ryan cr...@binghamton.edu To: R-help R-help@r-project.org Sent: Wednesday, April 18, 2012 8:16 AM Subject: [R] introducing R to high school students I participate peripherally on a listserve for middle- and high-school science teachers. Sometimes questions about graphing or data analysis come up. I never miss an opportunity to advocate for R. However, the teachers are often skeptical that their students would be able to issue commands or write a little code; they think it would be too difficult. Perhaps this stems from the Microsoft- and spreadsheet-centered, pointy-clicky culture prevalent in most US public schools. Then again, I have little experience teaching this age group, besides my own kids and my Science Olympiad team, so I respect their concerns and expertise. I don't know yet what software they generally use, but I suspect MS Excel and SPSS. Now I have to put my money where my mouth is. I've offered to visit a high school and introduce R to some fairly advanced students participating in a longitudinal 3-year science research class. I anticipate keeping things very simple: --objects and the fact that there is stuff inside them. str(), head(), tail() --how to get data into R --dataframes, as I imagine they will mostly be using single, rectangular datasets --a lot of graphics (I can't imagine that plot(force, acceleration) is beyond a high-schooler's capability.) --simple descriptive statistics --maybe t-tests, chi-square tests, and simple linear regression. Alas, probably more than we would have time to cover. Has anyone done anything with R in high schools? Thanks. --Chris Ryan SUNY Upstate Medical University Binghamton Clinical Campus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] introducing R to high school students
Christopher, I suggest that you look at R through Excel. This is a Springer book that Erich Neuwirth and I wrote. It is designed as a computational supplement to any introductory Statistics book. It uses Erich's RExcel to give either menu access to R from Excel (using Rcmdr embedded into the Excel menu system), or by placing any R function inside the Excel automatic recalculation model. RExcel is available either in the RExcelInstaller package from CRAN, or fully integrated into a complete R system from rcom.univie.ac.at. Go to the Downloads page and download the current RAndFriends installer. We have discussions on using RExcel in the classroom in the Literature and presentations section on the Wiki page at the rcom site. Several of the links are to papers at the UseR! conferences. This one specifically addresses teaching: http://www.r-project.org/useR-2006/Slides/BaierEtAl.pdf Baier, T., Heiberger, R., Neuwirth, E., Schinagl, K., Grossmann, W. (2007). Using R for teaching statistics to nonmajors: Comparing experiences of two different approaches. Paper presented at the UseR 2006, Vienna. Rich On Apr 17, 2012, at 22:46, Christopher W Ryan cr...@binghamton.edu wrote: I participate peripherally on a listserve for middle- and high-school science teachers. Sometimes questions about graphing or data analysis come up. I never miss an opportunity to advocate for R. However, the teachers are often skeptical that their students would be able to issue commands or write a little code; they think it would be too difficult. Perhaps this stems from the Microsoft- and spreadsheet-centered, pointy-clicky culture prevalent in most US public schools. Then again, I have little experience teaching this age group, besides my own kids and my Science Olympiad team, so I respect their concerns and expertise. I don't know yet what software they generally use, but I suspect MS Excel and SPSS. Now I have to put my money where my mouth is. I've offered to visit a high school and introduce R to some fairly advanced students participating in a longitudinal 3-year science research class. I anticipate keeping things very simple: --objects and the fact that there is stuff inside them. str(), head(), tail() --how to get data into R --dataframes, as I imagine they will mostly be using single, rectangular datasets --a lot of graphics (I can't imagine that plot(force, acceleration) is beyond a high-schooler's capability.) --simple descriptive statistics --maybe t-tests, chi-square tests, and simple linear regression. Alas, probably more than we would have time to cover. Has anyone done anything with R in high schools? Thanks. --Chris Ryan SUNY Upstate Medical University Binghamton Clinical Campus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to keep spacing in column name while reading data from data frame?
Hi, I am working on dataframe and column names are multiwords but when i read it it become one word with space relplaced by . How can i keep normall spacing reading file. for e.g. input file Data Test Data Out 35 54 But when i read this data in table it becomes Data.TestData.Out 35 54 Pls help me out. Thanks -- View this message in context: http://r.789695.n4.nabble.com/How-to-keep-spacing-in-column-name-while-reading-data-from-data-frame-tp4566585p4566585.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 with Rcmd check library --as-cran
Hi all- Henrik, packageDescription informs me that I have Matrix version 1.0-6, which is the newest version on CRAN. Duncan, I installed R-patched from CRAN, reset my path variable, reinstalled paleotree's dependencies and reran Rcmd check with --as-cran. This produced a related but different error. Instead of failing when examples were being run, it failed earlier when during testing the installation. See below: The check log: * using log directory 'c:/MyPackages/paleotree.Rcheck' * using R version 2.15.0 Patched (2012-04-09 r58947) * using platform: x86_64-pc-mingw32 (64-bit) * using session charset: ISO8859-1 * checking for file 'paleotree/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'paleotree' version '1.3' * checking CRAN incoming feasibility ... OK * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking whether package 'paleotree' can be installed ... ERROR Installation failed. See 'c:/MyPackages/paleotree.Rcheck/00install.out' for details. If I go to 00install.out as directed, I find: * installing *source* package 'paleotree' ... ** R ** preparing package for lazy loading Error in loadNamespace(i, c(lib.loc, .libPaths())) : there is no package called 'Matrix' ERROR: lazy loading failed for package 'paleotree' * removing 'c:/MyPackages/paleotree.Rcheck/paleotree' So it appears to be the same general problem with it finding package dependencies with the --as-cran option. This does not occur when I run the vanilla check command; the check runs fine and it appears to run into no issues with running examples. Duncan, I'll send you the tar ball source file shortly. Thank you for your kind offer of checking the file for me. -Dave On Tue, Apr 17, 2012 at 8:28 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 12-04-17 9:21 PM, David Winsemius wrote: On Apr 17, 2012, at 9:15 PM, Henrik Bengtsson wrote: paleotree imports phangorn which depends on Matrix, so your example does indeed depend on Matrix. A possible reason is that your installed Matrix was built for a different version of R, i.e. check packageDescription(Matrix). I thought Matrix was included by default as of a couple of R versions ago? It is. There are some problems in 2.15.0 in checking whether package dependencies are present; they only show up on some Windows systems. If you can, please try the checks on R-patched, and see if you get the same problem. If you do, and can send me the tarball, I'll try it on my system. Duncan Murdoch -- David Bapst Dept of Geophysical Sciences University of Chicago 5734 S. Ellis Chicago, IL 60637 http://home.uchicago.edu/~dwbapst/ http://cran.r-project.org/web/packages/paleotree/index.html http://home.uchicago.edu/%7Edwbapst/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to change color of bar based on y value of y axis?
Hi, I m working on bar chart. *Input file:* index -5 1 index -4 3 index -3 2 index -2 10 index -1 7 index 0 2 index 1 1 barplot(t(as.matrix(i[3])), ylab= value, main = testdata, beside=TRUE, col=c(burlywood1),horiz=TRUE,cex.names=0.8,names.arg=t(as.matrix(i[,2]))) But i need to change the color of bar where value of y = -3 dynamically. How can i implement it. Regards http://r.789695.n4.nabble.com/file/n4566636/Screenshot.png -- View this message in context: http://r.789695.n4.nabble.com/How-to-change-color-of-bar-based-on-y-value-of-y-axis-tp4566636p4566636.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] introducing R to high school students
On Tue, Apr 17, 2012 at 10:46 PM, Christopher W Ryan cr...@binghamton.edu wrote: I participate peripherally on a listserve for middle- and high-school science teachers. Sometimes questions about graphing or data analysis come up. I never miss an opportunity to advocate for R. However, the teachers are often skeptical that their students would be able to issue commands or write a little code; they think it would be too difficult. Perhaps this stems from the Microsoft- and spreadsheet-centered, pointy-clicky culture prevalent in most US public schools. Then again, I have little experience teaching this age group, besides my own kids and my Science Olympiad team, so I respect their concerns and expertise. I don't know yet what software they generally use, but I suspect MS Excel and SPSS. Now I have to put my money where my mouth is. I've offered to visit a high school and introduce R to some fairly advanced students participating in a longitudinal 3-year science research class. I anticipate keeping things very simple: --objects and the fact that there is stuff inside them. str(), head(), tail() --how to get data into R --dataframes, as I imagine they will mostly be using single, rectangular datasets --a lot of graphics (I can't imagine that plot(force, acceleration) is beyond a high-schooler's capability.) --simple descriptive statistics --maybe t-tests, chi-square tests, and simple linear regression. I have some experience in this and would have to agree with Indrajit that this is not a good idea. When I tried to teach R to a high school student it was not very successful. Certainly based on that experience the list above is way too complex. Don't teach anything on that list at all. The number of concepts involved in that is simply overwhelming. Also avoid teaching anything that requires complex installation if you want them to be able to carry it forward by themselves. I would expect the reaction would be that most will have no interest and the ones that do will be frustrated by the large number of concepts needed to get going. The only part that seemed to trigger any interest was when I showed the large list of colors available in colors() and then playing with inserting different colors in: colors() plot(1:5, col = violetred) Assuming you are committed to this and go ahead, I would divide it into two parts: 1. a graphics demo -- make it clear its a demonstration so they have an appreciation of what is possible and you are not actually teaching anything in this portion. 2. Teach them how to install R, run the above two commands (substituting in different colors), how to exit and point out that there are many tutorials in: http://cran.r-project.org/other-docs.html and they can pick one they like (since the official documents will be over their head). If you do that then perhaps a small number will have sufficient interest to try it some more at home but I wouldn't be surprised if none do and that most or all would prefer something with more immediate gratification. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to change color of bar based on y value of y axis?
Hi Hi, I m working on bar chart. *Input file:* index -5 1 index -4 3 index -3 2 index -2 10 index -1 7 index 0 2 index 1 1 barplot(t(as.matrix(i[3])), ylab= value, main = testdata, beside=TRUE, col=c(burlywood1),horiz=TRUE,cex.names=0.8,names.arg=t(as.matrix(i[,2]))) You still failing to provide reproducible examples. Maybe you want this. x-sample(1:10, 5) barplot(x, col=c(burlywood1)) set.seed(333) y-sample(-3:0, 5, replace=T) barplot(x, col=c(burlywood1, red)[(y==-3)+1]) Regards Petr But i need to change the color of bar where value of y = -3 dynamically. How can i implement it. Regards http://r.789695.n4.nabble.com/file/n4566636/Screenshot.png -- View this message in context: http://r.789695.n4.nabble.com/How-to-change- color-of-bar-based-on-y-value-of-y-axis-tp4566636p4566636.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] How to keep spacing in column name while reading data from data frame?
Hi Hi, I am working on dataframe and column names are multiwords but when i read it it become one word with space relplaced by . How can i keep normall spacing reading file. for e.g. input file Data Test Data Out 35 54 But when i read this data in table it becomes Data.TestData.Out 35 54 Pls help me out. Thanks You need to change check.names parameter when reading in your file. Regards Petr -- View this message in context: http://r.789695.n4.nabble.com/How-to-keep- spacing-in-column-name-while-reading-data-from-data-frame-tp4566585p4566585.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] Can a matrix have 'list' as rows/columns?
Not sure this adds to, subtracts from, or obfuscates this thread, but ... x - list(a=1:3,b = log, c=letters[2],d=as.list(1:5)) is.vector(x) [1] TRUE dim(x) - c(2,2) is.matrix(x) [1] TRUE is.vector(x) [1] FALSE x [,1] [,2] [1,] Integer,3 b [2,] ? List,5 x[2,1](5) Error: attempt to apply non-function ## because... x[2,1] [[1]] function (x, base = exp(1)) .Primitive(log) ## thus ... x[2,1][[1]](5) [1] 1.609438 ## as well as x[[2]](5) [1] 1.609438 ## because it's still the case that ... is.list(x) [1] TRUE ## it's a list with dim attribute and thus... class(x) [1] matrix ## But it's not a vector: is.vector(x) [1] FALSE I'm not sure all this is consistent, but I think a full understanding of the semantics probably requires poking into more musty corners of R than I can handle, anyway. Cheers, Bert On Tue, Apr 17, 2012 at 5:15 PM, David Winsemius dwinsem...@comcast.net wrote: On Apr 17, 2012, at 7:27 PM, Worik R wrote: On Tue, Apr 17, 2012 at 11:52 PM, David Winsemius dwinsem...@comcast.netwrote: On Apr 17, 2012, at 12:13 AM, Worik R wrote: After a lot of processing I get a matrix into M. I expected each row and column to be a vector. But it is a list. This behavior is not the result of limitation in how R's sapply might have processed a purely numeric set of results, but is because you (probably) returned a hetergeneous set of classes rom you inner function. Assuming that last is actually function(x){tail,1}, then the structure of M is str(M) List of 6 [snip] ..$ : chr [1:3] aaa bbb ccc Had the result been a more homogeneous collection, I sapply would have returned an array of atomic numeric vectors. Try just returning a number: M2 - sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,Value])}, DF) Yes that returns a vector. I want a matrix. I see that my problem is that the columns of DF are not all the same type. Once I did that (made Value character) I get my matrix just as I need. SO it was I passed *in* that was the problem Not what I did with it inside sapply. In this case I would expect M to be a list. I am gobsmacked that a list can be considered a vector. Is that a bug? No. It is by design. list is an acceptable storage mode for vector(). It must be bad design? That is (obviously) a matter of opinion. R is in the middle region between LiSP and a strongly typed language. I have been using R for a number of years (5?) and heavilly for two years. I am still getting bitten by these features in R. To my mind there are many places that R violates the *principle of least surprise. I keep getting surprises as well. I did experience surprise at the point I saw that is.vector() returning TRUE for a list. I think that means that is.vector is rather less informative than I expected. Essentially only language objects fail: z - as.formula(x ~ y) z x ~ y is.vector(z) [1] FALSE Even expressions are vectors: z - expression( x ~ y) z expression(x ~ y) is.vector(z) [1] TRUE But it may be my mind that is at fault! What are other people's experience?* I still have not fully wrapped my head around the higher levels of the language. I thought reading Chamber's book would help, but it had too much prose and did not present enough worked examples to sync with my learning style. I'm still looking for a book that lets me use the language more effectively. -- David. Worik class(M) [1] numeric str(M2) Named num [1:3] 0.6184 0.0446 0.3605 - attr(*, names)= chr [1:3] aaa bbb ccc -- David. R-Inferno says... Arrays (including matrices) can be subscripted with a matrix of positive numbers. The subscripting matrix has as many columns as there are dimensions in the array—so two columns for a matrix. The result is a vector (not an array) containing the selected items. My version of R: version.string R version 2.12.1 (2010-12-16) Here is an example... Qm - c(aaa, bbb, ccc) DF - data.frame(Name=sample(Qm, replace=TRUE, size=22), Value=runif(22), stringsAsFactors=FALSE) M - sapply(Qm, function(nm, DF){last(DF[DF[, Name]==nm,])}, DF) class(M) [1] matrix class(M[,1]) [1] list class(M[1,]) [1] list M aaa bbb ccc Name aaa bbb ccc Value 0.4702648 0.274498 0.5529691 DF Name Value 1 ccc 0.99948920 2 aaa 0.51921281 3 aaa 0.10803943 4 aaa 0.82265847 5 ccc 0.83237260 6 bbb 0.88250933 7 aaa 0.41836131 8 aaa 0.66197290 9 ccc 0.01911771 10 ccc 0.4699 11 bbb 0.35719884 12 ccc 0.86274858 13 bbb 0.57528579 14 aaa 0.12452158 15 aaa 0.44167731 16 aaa 0.11660019 17 ccc 0.55296911 18 aaa 0.12796890 19 bbb 0.44595741 20 bbb 0.93024768 21 aaa 0.47026475 22 bbb 0.27449801 David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting
Re: [R] introducing R to high school students
...snipped I anticipate keeping things very simple: --objects and the fact that there is stuff inside them. str(), head(), tail() --how to get data into R --dataframes, as I imagine they will mostly be using single, rectangular datasets --a lot of graphics (I can't imagine that plot(force, acceleration) is beyond a high-schooler's capability.) --simple descriptive statistics --maybe t-tests, chi-square tests, and simple linear regression. I have some experience in this and would have to agree with Indrajit that this is not a good idea. When I tried to teach R to a high school student it was not very successful. Certainly based on that experience the list above is way too complex. Don't teach anything on that list at all. The number of concepts involved in that is simply overwhelming. Oh amen amen! I'd go farther: It's overwhelming for college students. Farther yet: I've met very few scientists and engineers who understand what a standard deviation is. Fewer still who understand the difference between a sample statistic and a population parameter for which it's an estimate. This approach to basic statistics is (imho) symptomatic of why our discipline is so widely disliked and misunderstood. Cheers, Bert Also avoid teaching anything that requires complex installation if you want them to be able to carry it forward by themselves. I would expect the reaction would be that most will have no interest and the ones that do will be frustrated by the large number of concepts needed to get going. The only part that seemed to trigger any interest was when I showed the large list of colors available in colors() and then playing with inserting different colors in: colors() plot(1:5, col = violetred) Assuming you are committed to this and go ahead, I would divide it into two parts: 1. a graphics demo -- make it clear its a demonstration so they have an appreciation of what is possible and you are not actually teaching anything in this portion. 2. Teach them how to install R, run the above two commands (substituting in different colors), how to exit and point out that there are many tutorials in: http://cran.r-project.org/other-docs.html and they can pick one they like (since the official documents will be over their head). If you do that then perhaps a small number will have sufficient interest to try it some more at home but I wouldn't be surprised if none do and that most or all would prefer something with more immediate gratification. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.