Re: [R] Remove Even Number from A Vector
On Fri, 1 Aug 2008, Gundala Viswanath wrote: How can I remove the even number from the following vector x [1] 4 5 6 8 17 20 21 22 23 25 26 31 35 36 38 40 41 42 43 [20] 44 50 74 75 82 84 89 90 91 95 96 97 100 101 102 118 119 121 122 [39] 123 135 136 157 158 yielding 5, 17, 21, 23, 25, . (keep odd number). x[which(x %% 2 != 0)] -- SIGSIG -- signature too long (core dumped) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Extract Element of String with R's Regex
Hi, I have this string, in which I want to extract some of it's element: x - Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669 -965.35 yielding this array [1] 211952_at RANBP5 2 In Perl we would do it this way: __BEGIN__ my @needed =(); my $str = Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669 -965.35; $str =~ /Best-K Gene \d+ (\w+) (\w+) Noc= \d - (\d) LL= (.*)/; push @needed, ($1,$2,$3); __END___ How can we achieve this with R? - E.W. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cutting out numbers from vectors
On Thu, 31 Jul 2008, calundergrad wrote: i have a vector with values similar to the below text [1] 001-010-001-0 I want to get rid of all leading zeroes. for example i want to change the values of the vector so that [1] 001-010-001-0 becomes [1] 1-010-001-0. Another example [1]082-232-232-1 becomes [1] 82-232-232-1 xform - function(nstr) { nstr.vec - unlist(strsplit(nstr, '-')) nstr.vec[1] - as.character(as.integer(nstr.vec[1])) return(paste(nstr.vec, collapse='-')) } stopifnot(xform('001-010-001-0') == '1-010-001-0') stopifnot(xform('082-232-232-1') == '82-232-232-1') -- SIGSIG -- signature too long (core dumped) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Remove Even Number from A Vector
x[!(x %% 2 == 0)] On Thu, Jul 31, 2008 at 10:01 PM, Gundala Viswanath [EMAIL PROTECTED]wrote: Dear all, How can I remove the even number from the following vector x [1] 4 5 6 8 17 20 21 22 23 25 26 31 35 36 38 40 41 42 43 [20] 44 50 74 75 82 84 89 90 91 95 96 97 100 101 102 118 119 121 122 [39] 123 135 136 157 158 yielding 5, 17, 21, 23, 25, . (keep odd number). - Gundala Viswanath Jakarta - Indonesia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Extract Element of String with R's Regex
How about: unlist(strsplit(x, split= ))[c(4:5,10)] That perl script looks like a good reason to avoid perl. Simon. On Fri, 2008-08-01 at 15:13 +0900, Edward Wijaya wrote: Hi, I have this string, in which I want to extract some of it's element: x - Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669 -965.35 yielding this array [1] 211952_at RANBP5 2 In Perl we would do it this way: __BEGIN__ my @needed =(); my $str = Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669 -965.35; $str =~ /Best-K Gene \d+ (\w+) (\w+) Noc= \d - (\d) LL= (.*)/; push @needed, ($1,$2,$3); __END___ How can we achieve this with R? - E.W. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 http://www.uq.edu.au/~uqsblomb email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] hclust interrogation use of $merge for dendrogram annotation?
Hi all, I've been doing some investigation to see if it is possible to implement an hclust/dendrogram related requirement that I've been given. So far ?hclust and a lot of googling haven't provided the information I'm looking for (I've been using R sporadically for a year). The requirement I have is to: On a dendrogram plot, draw points at various merge locations, based on some other data. For instance, for an initial 15 cluster dend, assume I need to mark the 1st,2nd and 7th merge by drawing points on the plot. This needs to be done within an R script, though if some FORTRAN or C code needs to be modified, that is fine. Where I'm stuck is: 1) making sense of the full $merge in hclust 2) programatically calculating an X-coordinate for plotting the marker points. For 1) The first couple of merges in make sense as they correspond to known clusters. But after several merges, the values in $merge do not seem to correspond to anything. eg. After a merge, what/how is the 'new' cluster referred to? This results is not knowing what needs to be done to programatically locate where on the plot the merge at height 'h' is. At this stage I'm assuming part of this lies in the 2 external FORTRAN functions that hclust calls. Any assistance on how to determine the merge location on the plot would be great! Thanks, Ben __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] anisotropy in vgm model. HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dear Alessandro, For the vgm-helpfile: Anisotropy parameters define which direction this is (the main axis), and how much shorter the range is in (the) direction(s) perpendicular to this main axis. Notice that the directions should be perpendicular. 90° and 45° are not perpendicular. Please don't forget to provide commented, minimal, self-contained, reproducible code as the posting guide requests. In this case it was not reproducible because we don't have the dataset. Futhermore R-sig-geo would be a more a propriate mailing list for this kind of questions. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Alessandro Verzonden: donderdag 31 juli 2008 23:23 Aan: r-help@r-project.org Onderwerp: [R] anisotropy in vgm model. HELP!!! Hi All, I have this problem. I don't understand the right code in R when I have an anisotropy in the semivariogram model plot(variogram(Z~1, subground, cutoff=1800, width=80, alpha=c(45, 135, 90, 135))) I have a good model in 90° and eventually in 90° and 45° v = variogram(Z~1, subground, cutoff=1800, width=80, alpha=c(0, 45, 90, 135)) v.fit = fit.variogram(v, vgm(model=Lin, anis=c(?))) Thank you Alessandro [[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] Function to check the presence of an Item in an array
Hi all, Is there a way to do it? For example: x foo bar bar2 qux is there a function to return TRUE/FALSE given a test variable func(foo) TRUE func(GUNDALA) FALSE Is there such func in R? - Gundala Viswanath Jakarta - Indonesia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] is this a bug (apply and class) ?
Hello R users, I run this code under windows XP and R 2.7.1 : head(esoph) agegp alcgptobgp ncases ncontrols 1 25-34 0-39g/day 0-9g/day 040 2 25-34 0-39g/day10-19 010 3 25-34 0-39g/day20-29 0 6 4 25-34 0-39g/day 30+ 0 5 5 25-34 40-79 0-9g/day 027 6 25-34 40-7910-19 0 7 class(esoph$agegp) [1] ordered factor class(esoph$alcgp) [1] ordered factor class(esoph$tobgp) [1] ordered factor class(esoph$ncases) [1] numeric class(esoph$ncontrols) [1] numeric apply(esoph, 2, class) agegp alcgp tobgp ncases ncontrols character character character character character I don't understand why the result is all character... Thanks a lot. [[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] Function to check the presence of an Item in an array
Look at %in% or match foo %in% x HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Gundala Viswanath Verzonden: vrijdag 1 augustus 2008 10:41 Aan: [EMAIL PROTECTED] Onderwerp: [R] Function to check the presence of an Item in an array Hi all, Is there a way to do it? For example: x foo bar bar2 qux is there a function to return TRUE/FALSE given a test variable func(foo) TRUE func(GUNDALA) FALSE Is there such func in R? - Gundala Viswanath Jakarta - Indonesia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Function to check the presence of an Item in an array
check ?%in%, e.g., x - c(foo, bar, bar2, qux) foo %in% x GUNDALA %in% x I hope it helps. Best, Dimitris --- Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://perswww.kuleuven.be/dimitris_rizopoulos/ Quoting Gundala Viswanath [EMAIL PROTECTED]: Hi all, Is there a way to do it? For example: x foo bar bar2 qux is there a function to return TRUE/FALSE given a test variable func(foo) TRUE func(GUNDALA) FALSE Is there such func in R? - Gundala Viswanath Jakarta - Indonesia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.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] is this a bug (apply and class) ?
On 8/1/2008 4:49 AM, David Hajage wrote: Hello R users, I run this code under windows XP and R 2.7.1 : head(esoph) agegp alcgptobgp ncases ncontrols 1 25-34 0-39g/day 0-9g/day 040 2 25-34 0-39g/day10-19 010 3 25-34 0-39g/day20-29 0 6 4 25-34 0-39g/day 30+ 0 5 5 25-34 40-79 0-9g/day 027 6 25-34 40-7910-19 0 7 class(esoph$agegp) [1] ordered factor class(esoph$alcgp) [1] ordered factor class(esoph$tobgp) [1] ordered factor class(esoph$ncases) [1] numeric class(esoph$ncontrols) [1] numeric apply(esoph, 2, class) agegp alcgp tobgp ncases ncontrols character character character character character I don't understand why the result is all character... Because the data frame is coerced to a matrix by apply(): If X is not an array but has a dimension attribute, apply attempts to coerce it to an array via as.matrix if it is two-dimensional (e.g., data frames)... Try lapply() or sapply() instead. lapply(esoph, class) $agegp [1] ordered factor $alcgp [1] ordered factor $tobgp [1] ordered factor $ncases [1] numeric $ncontrols [1] numeric Thanks a lot. [[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. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] drop1() seems to give unexpected results compare to anova()
Dear all, I have been trying to investigate the behaviour of different weights in weighted regression for a dataset with lots of missing data. As a start I simulated some data using the following: library(MASS) N - 200 sigma - matrix(c(1, .5, .5, 1), nrow = 2) sim.set - as.data.frame(mvrnorm(N, c(0, 0), sigma)) colnames(sim.set) - c('x1', 'x2') # x1 x2 are correlated sim.set$x3 - rnorm(N, 0, 1) # x3 is independent sim.set$x4 - rnorm(N, 0, 1) # x4 is red herring sim.set$y = 4 * sim.set$x1 + 5 * sim.set$x2 + 6 * sim.set$x3 # y is outcome I then checked the correlation of my simulated data and fitted a linear regression to check if y = 4 * x1 + 5 * x2 + 6 * x3 indeed. round(cor(sim.set), 2) summary(model - lm(y ~ ., data = sim.set)) Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -5.423e-17 1.256e-16 -4.320e-01 0.666 x1 4.000e+00 1.388e-16 2.881e+16 2e-16 *** x2 5.000e+00 1.441e-16 3.470e+16 2e-16 *** x3 6.000e+00 1.188e-16 5.051e+16 2e-16 *** x4 -8.150e-18 1.165e-16 -7.000e-02 0.944 anova(model) Df Sum Sq Mean Sq F value Pr(F) x1 1 8686.1 8686.1 2.8218e+33 2e-16 *** x2 1 5568.7 5568.7 1.8091e+33 2e-16 *** x3 1 7852.1 7852.1 2.5509e+33 2e-16 *** x4 1 1.507e-32 1.507e-32 4.9000e-03 0.9443 Residuals 195 6.002e-28 3.078e-30 All was well so far, as x4 was identified as not significant and its coeff was almost 0 (because I made it so in the first place). Now I expected it to be dropped in stepwise: step(model, direction = 'both', test = 'F') drop1(model, test = 'F') dropterm(model, test = 'F') Df Sum of Sq RSS AIC F value Pr(F) none 6.002e-28 -13585.7 x1 1 2555.1 2555.1 517.5 8.3006e+32 2.2e-16 *** x2 1 3707.0 3707.0 591.9 1.2043e+33 2.2e-16 *** x3 1 7851.9 7851.9 742.0 2.5508e+33 2.2e-16 *** x4 1 2.118e-27 2.718e-27 -13285.6 6.8806e+02 2.2e-16 *** Neither of those 3 lines of commands managed to drop x4 and its P value magically decreased from 0.94 to almost 0! I am also baffled by how R calculated those RSS. However, if I fitted the smaller model and compared it with the original one by hand, I got the expected answer: summary(model2 - lm(y ~ x1 + x2 + x3, data = sim.set)) anova(model, model2, test = 'F') Model 1: y ~ x1 + x2 + x3 + x4 Model 2: y ~ x1 + x2 + x3 Res.Df RSS Df Sum of Sq F Pr(F) 1 195 6.0025e-28 2 196 6.0026e-28 -1 -2.e-32 0.0049 0.9443 Interestingly, if I had started from a null model I ended up with y = 4 * x1 + 5 * x2 + 6 * x3 and R did not add x4 into the model as expected. summary(model1 - lm(y ~ 1, data = sim.set)) step(model1, direction = 'both', scope = .~. + x1 + x2 + x3 + x4, test = 'F') add1(model1, scope = .~. + x1 + x2 + x3 + x4, test = 'F') addterm(model1, scope = .~. + x1 + x2 + x3 + x4, test = 'F') Df Sum of Sq RSS AIC F value Pr(F) none 22107.0 943.1 x1 1 8686.1 13420.8 845.2 128.1478 2e-16 *** x2 1 11658.7 10448.3 795.2 220.9377 2e-16 *** x3 1 11045.4 11061.6 806.6 197.7096 2e-16 *** x4 1 13.4 22093.6 944.9 0.1199 0.7295 I'm not sure what is going on. I am running R 2.7.1 on Ubuntu Linux, with all components up to date. Thank you in advance for all your thoughts and replies. Yours sincerely, Thomas P C Chu University of Leicester LE1 7RH UK AOL Email goes Mobile! You can now read your AOL Emails whilst on the move. Sign up for a free AOL Email account with unlimited storage today. ** See what's new at http://www.aol.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] is this a bug (apply and class) ?
Please do read ?apply (see the posting guide) If 'X' is not an array but has a dimension attribute, 'apply' attempts to coerce it to an array via 'as.matrix' if it is two-dimensional (e.g., data frames) or via 'as.array'. and note sapply(esoph, class) $agegp [1] ordered factor $alcgp [1] ordered factor $tobgp [1] ordered factor $ncases [1] numeric $ncontrols [1] numeric On Fri, 1 Aug 2008, David Hajage wrote: Hello R users, I run this code under windows XP and R 2.7.1 : head(esoph) agegp alcgptobgp ncases ncontrols 1 25-34 0-39g/day 0-9g/day 040 2 25-34 0-39g/day10-19 010 3 25-34 0-39g/day20-29 0 6 4 25-34 0-39g/day 30+ 0 5 5 25-34 40-79 0-9g/day 027 6 25-34 40-7910-19 0 7 class(esoph$agegp) [1] ordered factor class(esoph$alcgp) [1] ordered factor class(esoph$tobgp) [1] ordered factor class(esoph$ncases) [1] numeric class(esoph$ncontrols) [1] numeric apply(esoph, 2, class) agegp alcgp tobgp ncases ncontrols character character character character character I don't understand why the result is all character... Thanks a lot. [[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, [EMAIL PROTECTED] 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] Coarsening the Resolution of a Dataset
Hi Jim, Thanks for your advice. The problem is that I can't lose any of the data - it's a global dataset, where the left-most column = 180 degrees west, and the right-most is 180 degrees east. The top row is the North Pole and the bottom row is the South Pole. I've got 512MB RAM on the machine I'm using - which has been enough to deal with such datasets before...? I'm wondering, is there an alternative means of achieving this? Perhaps orientated via the desired output of the 'coarsened' dataset - my calculations suggest that the dataset would need to change from the current 2160 x 4320 dimensions to 360 x 720. Is there any way of doing this based on averages of blocks of rows/columns, for example? Many thanks again, Steve _ Find the best and worst places on the planet __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Coarsening the Resolution of a Dataset
If you can reduce the size of your data by averaging, then you could read in a subset of the rows, average the 6x6 matrices and then write them out for a second phase of processing. The 2160x4230 object would take up 75MB if numeric, which is probably 50% of your available memory if you are running on windows with 512MB. I have 1GB and if I have nothing else running, I have about 650MB after the OS is loaded and such. On a 512MB machine, this might leave about 140MB for R to use. So if you can scale it down by averaging the 6x6 subsets, you will probably be much better off in doing your analysis, assuming you don't lose too much accuracy. Do you need it all in memory at the same time? Again a database might help if you can process subsets of the data. On Fri, Aug 1, 2008 at 5:10 AM, Steve Murray [EMAIL PROTECTED] wrote: Hi Jim, Thanks for your advice. The problem is that I can't lose any of the data - it's a global dataset, where the left-most column = 180 degrees west, and the right-most is 180 degrees east. The top row is the North Pole and the bottom row is the South Pole. I've got 512MB RAM on the machine I'm using - which has been enough to deal with such datasets before...? I'm wondering, is there an alternative means of achieving this? Perhaps orientated via the desired output of the 'coarsened' dataset - my calculations suggest that the dataset would need to change from the current 2160 x 4320 dimensions to 360 x 720. Is there any way of doing this based on averages of blocks of rows/columns, for example? Many thanks again, Steve _ Find the best and worst places on the planet http://clk.atdmt.com/UKM/go/101719807/direct/01/ -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] contour lines in windows device but neither in pdf nor in postscript
library(mvtnorm) x = seq(-4,4,length=201) xy= expand.grid(x,x) sigma = (diag(c(1,1))+1)/2 d2= matrix(dmvnorm(xy,sigma=sigma),201) xsamp = rmvnorm(200,sigma=sigma) contour(x,x,d2) points(xsamp,col=3,pch=16) pdf(pdftry.pdf) contour(x,x,d2) points(xsamp,col=3,pch=16) dev.off() postscript(pstry.ps) contour(x,x,d2) points(xsamp,col=3,pch=16) dev.off() # I can see contour lines in a window device but I can't see them in files pdftry.pdf and pstry.ps version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 7.1 year 2008 month 06 day23 svn rev45970 language R version.string R version 2.7.1 (2008-06-23) what's going wrong? Thanks in advance, Regards, Patrizio Frederic __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bug in the generic plot function for GLM?
Dear all, In R 2.7.1 on Windows it looks to me that the generic plot function for GLM objects uses standardized working residuals and not as labeled in the graph the standardized deviance residuals. It looks to me that from 2.7.0 to 2.7.1 there has been a bug introduced. Has anybody observed the same or do I misunderstand something in the generic plot function? Feedback is very much appreciated. Best regards, Beat [[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] Coarsening the Resolution of a Dataset
Ok thanks Jim - I'll give it a go! I'm new to R, so I'm not sure how I'd go about performing averages in subsets... I'll have a look into it, but any subsequent pointers would be gratefully received as ever! I'll also try playing with it in Access, and maybe even Excel 2007 might be able to do the trick too? Thanks again...! Steve __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] contour lines in windows device but neither in pdf nor in postscript
What viewers are you using? Works for me (using ghostscript 4.61 and acroread 8.1.2) -- I even tried 2.7.1 (as well as R-patched). On Fri, 1 Aug 2008, Patrizio Frederic wrote: library(mvtnorm) x = seq(-4,4,length=201) xy= expand.grid(x,x) sigma = (diag(c(1,1))+1)/2 d2= matrix(dmvnorm(xy,sigma=sigma),201) xsamp = rmvnorm(200,sigma=sigma) contour(x,x,d2) points(xsamp,col=3,pch=16) pdf(pdftry.pdf) contour(x,x,d2) points(xsamp,col=3,pch=16) dev.off() postscript(pstry.ps) contour(x,x,d2) points(xsamp,col=3,pch=16) dev.off() # I can see contour lines in a window device but I can't see them in files pdftry.pdf and pstry.ps version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 7.1 year 2008 month 06 day23 svn rev45970 language R version.string R version 2.7.1 (2008-06-23) what's going wrong? Thanks in advance, Regards, Patrizio Frederic __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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, [EMAIL PROTECTED] 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] contour lines in windows device but neither in pdf nor in postscript
dear Ripley and Diffort, thank you for the quick reply. I figured out it was my mistake: I wrote this to the list: contour(x,x,d2) in fact my framework I used contour(x,x,d2,labex=0) # that produced the error then I learned by myself that if I want to suppress labels I have to use contour(x,x,d2,drawlabel=F) and everything works fine now. Thank you again, Patrizio 2008/8/1 Prof Brian Ripley [EMAIL PROTECTED]: What viewers are you using? Works for me (using ghostscript 4.61 and acroread 8.1.2) -- I even tried 2.7.1 (as well as R-patched). On Fri, 1 Aug 2008, Patrizio Frederic wrote: library(mvtnorm) x = seq(-4,4,length=201) xy= expand.grid(x,x) sigma = (diag(c(1,1))+1)/2 d2= matrix(dmvnorm(xy,sigma=sigma),201) xsamp = rmvnorm(200,sigma=sigma) contour(x,x,d2) points(xsamp,col=3,pch=16) pdf(pdftry.pdf) contour(x,x,d2) points(xsamp,col=3,pch=16) dev.off() postscript(pstry.ps) contour(x,x,d2) points(xsamp,col=3,pch=16) dev.off() # I can see contour lines in a window device but I can't see them in files pdftry.pdf and pstry.ps version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 7.1 year 2008 month 06 day23 svn rev45970 language R version.string R version 2.7.1 (2008-06-23) what's going wrong? Thanks in advance, Regards, Patrizio Frederic __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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, [EMAIL PROTECTED] 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.
[R] Solving Yis[i] = a*cos((2*pi/T)*(times[i] - Tau)) + ...
Hi everybody, I am reading the Lomb paper (Lomb, 1976) and I found an interesting equation, and I wish to resolve it using R. I am wondering if anybody has a hint. The equation is: Yis[i] = a*cos((2*pi/T)*(Times[i] - Tau)) + b*sin((2*pi/T)*(Times[i] - Tau)) ... (1) Where T and Tau are constants. I know the Times and Tis values (in fact these values come from a Time Series), and I need found the values of a and b. I can resolve the eq. (1) using a pencil and paper (expanding this as a linear system of equation), it is not a difficult problem, although I am not able to resolve it using R. Any hint or advice would be very appreciated, Thank you so much -- Josue Polanco [[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] History pruning
JGR's Copy Commands command works well for me (even if it is both fascinating and embarrassing how little is sometimes left over). It retains only commands that worked, so it is still not the minimum possible. Antony Unwin Professor of Computer-Oriented Statistics and Data Analysis, Mathematics Institute, University of Augsburg, 86135 Augsburg, Germany Tel: + 49 821 5982218 [EMAIL PROTECTED] http://stats.math.uni-augsburg.de/ [[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] Extract Element of String with R's Regex
In the example below, a straight application of strsplit() is probably the simplest solution. In a more general case where it may be desirable to match patterns, a combination of sub() or gsub() with strsplit() might do the trick: x - Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669 -965.35 patt - Best-K Gene \\d+ (\\w+) (\\w+) Noc= \\d - (\\d) LL= (.*) unlist(strsplit(gsub(patt,\\1,\\2,\\3,x,perl=TRUE),,)) [1] 211952_at RANBP52 Alternatively, you may want to take a look at the gsubfn package - it is quite useful. Still learning to use it myself... library(gsubfn) unlist(strapply(x,patt,function(x1,x2,x3) c(x1,x2,x3),backref=-3,perl=TRUE)) [1] 211952_at RANBP52 - Original Message From: Simon Blomberg [EMAIL PROTECTED] To: Edward Wijaya [EMAIL PROTECTED] Cc: r-help@r-project.org Sent: Thursday, July 31, 2008 11:48:23 PM Subject: Re: [R] Extract Element of String with R's Regex How about: unlist(strsplit(x, split= ))[c(4:5,10)] That perl script looks like a good reason to avoid perl. Simon. On Fri, 2008-08-01 at 15:13 +0900, Edward Wijaya wrote: Hi, I have this string, in which I want to extract some of it's element: x - Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669 -965.35 yielding this array [1] 211952_at RANBP5 2 In Perl we would do it this way: __BEGIN__ my @needed =(); my $str = Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669 -965.35; $str =~ /Best-K Gene \d+ (\w+) (\w+) Noc= \d - (\d) LL= (.*)/; push @needed, ($1,$2,$3); __END___ How can we achieve this with R? - E.W. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 http://www.uq.edu.au/~uqsblomb email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] optim fails when using arima
in line MAIDER MATEOS DEL PINO wrote: Hi all, I´m using the arima() function to study a time series but it gives me the following error: Error en optim(init[mask], armafn, method = BFGS, hessian = TRUE, control = optim.control, : non-finite finite-difference value [3] I know that I can change the method of the arima() to CSS instead of ML but I'm specially interested in using maximum likelihood. I have read that using the Nelder-Mead method in the optim() function could avoid this error but I think that it is not possible to change the method of optim from arima(). The arguments for 'arima' includes 'optim.control', which the 'arima' help page describes as a List of control parameters for 'optim'. Unfortunately, the following attempt to use this failed: arima(lh, order = c(1,0,0), optim.control=list(method=Nelder-Mead)) Warning messages: In optim(init[mask], armafn, method = BFGS, hessian = TRUE, control = optim.control, : unknown names in control: method If it were my problem, I might start by downloading the source for the R stats package from CRAN or listing 'arima' and copying it into a script file. A 'search' for optim in the code for 'arima' revealed that it is called in 4 different places. I then added the following lines to the start of 'optim' and changed all 4 calls to 'optim' so they said 'method = optimMtd' instead of 'method = BFGS': { if(is.null(optim.control$method)) optimMtd - 'BFGS' else { optimMtd - optim.control$method optim.control$method - NULL } } When I tried this, I found that I had to search for R_ and replace it by stats:::R_ because of object names hidden in the namespace for the stats package. When I did this, 'optim' ran successfully and gave almost identical answers to the default BFGS 'optim' method, differing by one digit on the last decimal place in one of the summary numbers from arima(lh, order = c(1,0,0)). If you try this, please let us know if it solves your problem. Hope this helps. Spencer Graves Does anyone have an idea of how could I solve this problem? Thanks and regards, Maider Mateos __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Extract Element of String with R's Regex
On Fri, Aug 1, 2008 at 7:31 AM, Stephen Tucker [EMAIL PROTECTED] wrote: In the example below, a straight application of strsplit() is probably the simplest solution. In a more general case where it may be desirable to match patterns, a combination of sub() or gsub() with strsplit() might do the trick: x - Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669 -965.35 patt - Best-K Gene \\d+ (\\w+) (\\w+) Noc= \\d - (\\d) LL= (.*) unlist(strsplit(gsub(patt,\\1,\\2,\\3,x,perl=TRUE),,)) [1] 211952_at RANBP52 Alternatively, you may want to take a look at the gsubfn package - it is quite useful. Still learning to use it myself... library(gsubfn) unlist(strapply(x,patt,function(x1,x2,x3) c(x1,x2,x3),backref=-3,perl=TRUE)) [1] 211952_at RANBP52 This last one can be slightly simplified: strapply(x, re, c, backref = -3, perl = TRUE)[[1]] [1] 211952_at RANBP52 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Newbie question: How to use tapply() on several vectors simultaneously
Dear R users, I have a newbie-question that I couldn't resolve after reading through several pieces of documentation and searching the archive. I have a data.frame containing experimental data from a group experiment in psychology. Each line represents a single participant, but participants were assigned to groups of three or four persons. One variable indicates each participants' group number (groupID). For a large number of variables, I would like to obtain the mean group value. I figured I use tapply() in the fashion of tapply(variable, groupID, mean), but that would be a tiresome task for my 150 variables. I am thus looking for a way to obtain a data.frame that contains one row for each group with the group-mean variables as columns. Example: test - as.data.frame(cbind(c(rep(1,5),rep(2,5)), rnorm(10), rnorm(10))) names(test)[1] - groupID test groupID V2 V3 11 -0.82990860 -0.61778919 21 -0.01379452 0.64609053 31 -2.64990839 -1.00570627 41 -0.07903878 -0.70864441 51 0.61483071 -1.32039565 62 -0.18913937 1.38490710 72 -0.60017953 0.15893421 82 -0.99901931 0.05963436 92 -1.46759515 0.35040283 10 2 -0.44650422 -0.08713162 tapply(test$V2, test$groupID, mean) 1 2 -0.5915639 -0.7404875 tapply(test$V3, test$groupID, mean) 1 2 -0.6012890 0.3733494 I am now looking for something that gives me groupID V2V3 1 1 -0.5915639-0.6012890 2 2 -0.74048750.3733494 Any ideas? Thank you very much, Bertolt -- Bertolt Meyer Oberassistent Sozialpsychologie, Psychologisches Institut der Universität Zürich Binzmühlestr. 14, Box 15 CH-8050 Zürich [EMAIL PROTECTED] tel: +41446357282 fax: +41446357279 mob: +41788966111 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Newbie question: How to use tapply() on several vectors simultaneously
something like that should work : aggregate(test, list(test[,1]), mean) 2008/8/1 Bertolt Meyer [EMAIL PROTECTED] Dear R users, I have a newbie-question that I couldn't resolve after reading through several pieces of documentation and searching the archive. I have a data.frame containing experimental data from a group experiment in psychology. Each line represents a single participant, but participants were assigned to groups of three or four persons. One variable indicates each participants' group number (groupID). For a large number of variables, I would like to obtain the mean group value. I figured I use tapply() in the fashion of tapply(variable, groupID, mean), but that would be a tiresome task for my 150 variables. I am thus looking for a way to obtain a data.frame that contains one row for each group with the group-mean variables as columns. Example: test - as.data.frame(cbind(c(rep(1,5),rep(2,5)), rnorm(10), rnorm(10))) names(test)[1] - groupID test groupID V2 V3 11 -0.82990860 -0.61778919 21 -0.01379452 0.64609053 31 -2.64990839 -1.00570627 41 -0.07903878 -0.70864441 51 0.61483071 -1.32039565 62 -0.18913937 1.38490710 72 -0.60017953 0.15893421 82 -0.99901931 0.05963436 92 -1.46759515 0.35040283 10 2 -0.44650422 -0.08713162 tapply(test$V2, test$groupID, mean) 1 2 -0.5915639 -0.7404875 tapply(test$V3, test$groupID, mean) 1 2 -0.6012890 0.3733494 I am now looking for something that gives me groupID V2V3 1 1 -0.5915639-0.6012890 2 2 -0.74048750.3733494 Any ideas? Thank you very much, Bertolt -- Bertolt Meyer Oberassistent Sozialpsychologie, Psychologisches Institut der Universität Zürich Binzmühlestr. 14, Box 15 CH-8050 Zürich [EMAIL PROTECTED] tel: +41446357282 fax: +41446357279 mob: +41788966111 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Newbie question: How to use tapply() on several vectors simultaneously
Hi Bertolt, by(test,INDICES=test$groupID,FUN=mean) And today's a holiday in Switzerland, so stop working already ;-) HTH Stephan Bertolt Meyer schrieb: Dear R users, I have a newbie-question that I couldn't resolve after reading through several pieces of documentation and searching the archive. I have a data.frame containing experimental data from a group experiment in psychology. Each line represents a single participant, but participants were assigned to groups of three or four persons. One variable indicates each participants' group number (groupID). For a large number of variables, I would like to obtain the mean group value. I figured I use tapply() in the fashion of tapply(variable, groupID, mean), but that would be a tiresome task for my 150 variables. I am thus looking for a way to obtain a data.frame that contains one row for each group with the group-mean variables as columns. Example: test - as.data.frame(cbind(c(rep(1,5),rep(2,5)), rnorm(10), rnorm(10))) names(test)[1] - groupID test groupID V2 V3 11 -0.82990860 -0.61778919 21 -0.01379452 0.64609053 31 -2.64990839 -1.00570627 41 -0.07903878 -0.70864441 51 0.61483071 -1.32039565 62 -0.18913937 1.38490710 72 -0.60017953 0.15893421 82 -0.99901931 0.05963436 92 -1.46759515 0.35040283 10 2 -0.44650422 -0.08713162 tapply(test$V2, test$groupID, mean) 1 2 -0.5915639 -0.7404875 tapply(test$V3, test$groupID, mean) 1 2 -0.6012890 0.3733494 I am now looking for something that gives me groupID V2V3 11 -0.5915639-0.6012890 22 -0.7404875 0.3733494 Any ideas? Thank you very much, Bertolt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Newbie question: How to use tapply() on several vectors simultaneously
one option is aggregate(), e.g., test - as.data.frame(cbind(c(rep(1,5),rep(2,5)), rnorm(10), rnorm(10))) names(test)[1] - groupID aggregate(test[c(V2, V3)], list(test$groupID), mean) I hope it helps. Best, Dimitris -- Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://perswww.kuleuven.be/dimitris_rizopoulos/ Quoting Bertolt Meyer [EMAIL PROTECTED]: Dear R users, I have a newbie-question that I couldn't resolve after reading through several pieces of documentation and searching the archive. I have a data.frame containing experimental data from a group experiment in psychology. Each line represents a single participant, but participants were assigned to groups of three or four persons. One variable indicates each participants' group number (groupID). For a large number of variables, I would like to obtain the mean group value. I figured I use tapply() in the fashion of tapply(variable, groupID, mean), but that would be a tiresome task for my 150 variables. I am thus looking for a way to obtain a data.frame that contains one row for each group with the group-mean variables as columns. Example: test - as.data.frame(cbind(c(rep(1,5),rep(2,5)), rnorm(10), rnorm(10))) names(test)[1] - groupID test groupID V2 V3 11 -0.82990860 -0.61778919 21 -0.01379452 0.64609053 31 -2.64990839 -1.00570627 41 -0.07903878 -0.70864441 51 0.61483071 -1.32039565 62 -0.18913937 1.38490710 72 -0.60017953 0.15893421 82 -0.99901931 0.05963436 92 -1.46759515 0.35040283 10 2 -0.44650422 -0.08713162 tapply(test$V2, test$groupID, mean) 1 2 -0.5915639 -0.7404875 tapply(test$V3, test$groupID, mean) 1 2 -0.6012890 0.3733494 I am now looking for something that gives me groupID V2V3 1 1 -0.5915639-0.6012890 2 2 -0.74048750.3733494 Any ideas? Thank you very much, Bertolt -- Bertolt Meyer Oberassistent Sozialpsychologie, Psychologisches Institut der Universität Zürich Binzmühlestr. 14, Box 15 CH-8050 Zürich [EMAIL PROTECTED] tel: +41446357282 fax: +41446357279 mob: +41788966111 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.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] Best way to select good points in a noisy signal ?
Hello, When I plot y=f(x) from the file xy.txt ( http://www.nabble.com/file/p18773387/xy.txt xy.txt ), I can clearly see a trend. Is there a function or a package able to take the median value of y for an interval of x (x +/- a defined value) to plot nice graph (at least a better one) ? Thanks in advance, Have a nice week-end, Ptit Bleu. -- View this message in context: http://www.nabble.com/Best-way-to-select-good-points-in-a-noisy-signal---tp18773387p18773387.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] Newbie question: How to use tapply() on several vectorssimultaneously
Another option is ?by test - as.data.frame(cbind(c(rep(1,5),rep(2,5)), rnorm(10), rnorm(10))) names(test)[1] - groupID test$groupID - factor(test$groupID) by(test[, -1], test$groupID, mean) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens David Hajage Verzonden: vrijdag 1 augustus 2008 15:21 Aan: Bertolt Meyer CC: r-help@r-project.org Onderwerp: Re: [R] Newbie question: How to use tapply() on several vectorssimultaneously something like that should work : aggregate(test, list(test[,1]), mean) 2008/8/1 Bertolt Meyer [EMAIL PROTECTED] Dear R users, I have a newbie-question that I couldn't resolve after reading through several pieces of documentation and searching the archive. I have a data.frame containing experimental data from a group experiment in psychology. Each line represents a single participant, but participants were assigned to groups of three or four persons. One variable indicates each participants' group number (groupID). For a large number of variables, I would like to obtain the mean group value. I figured I use tapply() in the fashion of tapply(variable, groupID, mean), but that would be a tiresome task for my 150 variables. I am thus looking for a way to obtain a data.frame that contains one row for each group with the group-mean variables as columns. Example: test - as.data.frame(cbind(c(rep(1,5),rep(2,5)), rnorm(10), rnorm(10))) names(test)[1] - groupID test groupID V2 V3 11 -0.82990860 -0.61778919 21 -0.01379452 0.64609053 31 -2.64990839 -1.00570627 41 -0.07903878 -0.70864441 51 0.61483071 -1.32039565 62 -0.18913937 1.38490710 72 -0.60017953 0.15893421 82 -0.99901931 0.05963436 92 -1.46759515 0.35040283 10 2 -0.44650422 -0.08713162 tapply(test$V2, test$groupID, mean) 1 2 -0.5915639 -0.7404875 tapply(test$V3, test$groupID, mean) 1 2 -0.6012890 0.3733494 I am now looking for something that gives me groupID V2V3 1 1 -0.5915639-0.6012890 2 2 -0.74048750.3733494 Any ideas? Thank you very much, Bertolt -- Bertolt Meyer Oberassistent Sozialpsychologie, Psychologisches Institut der Universität Zürich Binzmühlestr. 14, Box 15 CH-8050 Zürich [EMAIL PROTECTED] tel: +41446357282 fax: +41446357279 mob: +41788966111 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] allocMatrix limits
VK == Vadim Kutsyy [EMAIL PROTECTED] on Thu, 31 Jul 2008 15:43:56 -0700 writes: I am getting an error allocMatrix: too many elements specified when I am trying to create large matrix or vector (about 1 billion elements). How can I find out limits on allocMatrix? Can I increase them? ?Memory-limits, and you cannot increase them unless you have a system which has larger signed integers. VK Thank you for pointing out this. VK The problem is in array.c, where allocMatrix check for VK if ((double)nrow * (double)ncol INT_MAX). But why VK itn is used and not long int for indexing? (max int is VK 2147483647, max long int is 9223372036854775807) Well, Brian gave you all info: Did you really carefully read ?Memory-limits ?? BTW: The package 'Matrix' has many facilities to work with sparse matrices; and these facilities are used in lme4 and more than a dozen other CRAN packages to work with sparse matrices in the order of 10^5 x 10^5, sometimes even 10^6 x 10^6, *but* with sparse content. Martin Maechler, ETH Zurich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] chron objects: input/output
Hi list, I have some questions regarding 1) conversion of date + time characters to chron 2) formatting chron object printing Regarding (1), Gabor's Rnews 2004 4/1 article has been indispensible, but I often work with files where dates and times are contained in a single field. In this case, I would like to control input/output of chron objects when each observation of date and time is stored as a single string. So here are some procedures that I've tried: ## define character vector x - c(07/01/2001 12:00:00,07/17/2001 15:00:00) ## method 1 library(chron) chron(substring(x,1,10),substring(x,12)) [1] (07/01/01 12:00:00) (07/17/01 15:00:00) ## method 2 (recently inspired by Gabor's post) do.call(c,strapply(x,(.*) (.*),chron,backref=-2)) [1] (07/01/01 12:00:00) (07/17/01 15:00:00) ## method 3 (chronObj - as.chron(strptime(x,%m/%d/%Y %T))) [1] (07/01/01 12:00:00) (07/17/01 15:00:00) Could there be any gotchas with the third method (as.chron(strptime(...)))? The 'tz' attribute for POSIXlt objects are ignored, but I am not sure if there are any implications of the '$isdst' field are for conversions. I do like this alternative for the conciseness-flexibility tradeoff; in my experience, I have not had any problems - but wanted to inquire if at some point the '$isdst' field (or possibly something else) could give me trouble. Regarding the printing of chron objects, this behavior is peculiar to me: format(chronObj,format=c(m/d,h:m)) [1] (0701 1200) (0717 1500) The special characters (/,:) are not printed - I've tried changing the attribute of the chron object, looked at the format.chron() method (getS3method(format,chron)), etc. and am still confused; the chron() documentation says its specification should be similar the input format. Could I have missed something? Thanks! ST __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Solving Yis[i] = a*cos((2*pi/T)*(times[i] - Tau)) + ...
Treat it as an over-determined linear system, that is: A - cbind(cos((2*pi/T)*(Times - Tau)), sin((2*pi/T)*(Times - Tau))) qr.solve(A, Yis) because 'solve' will only handle square matrices. Hans W. Borchers Josué Polanco wrote: Hi everybody, I am reading the Lomb paper (Lomb, 1976) and I found an interesting equation, and I wish to resolve it using R. I am wondering if anybody has a hint. The equation is: Yis[i] = a*cos((2*pi/T)*(Times[i] - Tau)) + b*sin((2*pi/T)*(Times[i] - Tau)) ... (1) Where T and Tau are constants. I know the Times and Tis values (in fact these values come from a Time Series), and I need found the values of a and b. I can resolve the eq. (1) using a pencil and paper (expanding this as a linear system of equation), it is not a difficult problem, although I am not able to resolve it using R. Any hint or advice would be very appreciated, Thank you so much -- Josue Polanco -- View this message in context: http://www.nabble.com/Solving-Yis-i--%3D-a*cos%28%282*pi-T%29*%28times-iTau%29%29-%2B-...-tp18771850p18774613.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] RE : bwplot with Date object
Hello and thank you for your reply. My dummy example was a bit too simple... I'm having difficulty correctly specifying the 'at' component since my real situation concerns a multipanel display with ' relation=free '. To illustrate : dates-as.Date(32768:32895,origin=1900-01-01) plouf-data.frame(days=dates,group=factor(rep(1:2,times=128/2))) plouf$group2-factor(rep(1:2,each=2)) plouf$days[plouf$group2==2]-plouf$days[plouf$group2==2]+50 bwplot(group~as.numeric(days)|group2,data=plouf,scales=list(x=list(at=mean(x),relation=free))) I would have liked one tick at the mean of the x values in each panel... Which isn't what I obtain. How do I customize the location of the tick marks for each panel ? Thanks again. David De: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Date: ven. 01/08/2008 00:12 À: GOUACHE David Cc: [EMAIL PROTECTED] Objet : Re: [R] bwplot with Date object On Thu, Jul 31, 2008 at 12:54 PM, GOUACHE David [EMAIL PROTECTED] wrote: Hello R-helpers, I would like to produce a boxplot for dates, using lattice. Here is a dummy example : dates-as.Date(32768:32895,origin=1900-01-01) plouf-data.frame(days=dates,group=factor(rep(1:2,times=128/2))) bwplot(group~days,data=plouf) # doesn't work, whereas : bwplot(group~as.numeric(days),data=plouf) # does, but is obviously not good looking when it comes to axis legends... Is there a way to pull off a boxplot with dates ? The automatic calculation of tick positions clearly gives less than useful results. You should be able to supply locations explicitly using bwplot(..., scales=list(x = list(at = ...)) ) -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 through Rserve
Hi Jeff, You are absolutely right. In all the mess, I forgot that my Rserve was started by a different user! Sometimes it's the simplest solution, isn't it? Thanks a lot. -Prasad -Original Message- From: Jeffrey Horner [mailto:[EMAIL PROTECTED] Sent: Thursday, July 31, 2008 5:14 PM To: Patil, Prasad Cc: r-help@r-project.org Subject: Re: [R] 'system' command through Rserve This probably has to do with your ssh configuration and nothing to do with R. How are you starting Rserve? Is it run with the same user privileges as when you run R manually? Best, Jeff Patil, Prasad wrote on 07/31/2008 02:51 PM: Hello, I've installed an Rserve instance on a remote server. I have no problem interfacing with it and running most commands. I have loaded some R scripts on the remote server, and one of them contains a system command to copy a file (created by the script) onto another server. When I run the script on the remote server itself, the script works as I intend: it creates a .csv file and uses scp to copy it onto another server. When I run the script remotely (through an Rconnection in Java), the .csv is created but the file is not copied onto the other server. Is there any reason why a system command would work when called locally but not when called remotely? The format is as follows: # create array write.csv(array, array.csv) system(scp /{path}/array.csv {remote server}:/{path2}) Again, the script works correctly when run through R on the remote server, but when I run it through Rserve, everything works except for the 'system' command. Any insights would be greatly appreciated. Thanks a lot, Prasad [[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. -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] drop1() seems to give unexpected results compare to anova()
Interestingly, if I fitted the model using glm() rather than lm(), drop1() would behave as expected: summary(model.glm - glm(y ~ ., data = sim.set, family = 'gaussian')) summary(model.lm - lm(y ~ ., data = sim.set)) drop1(model.glm, test = 'F') drop1(model.lm, test = 'F') model.glm - step(model.glm, direction = 'both', test = 'F') model.lm - step(model.lm, direction = 'both', test = 'F') summary(model.glm) summary(model.lm) Although it is debatable whether one should use glm(family = 'gaussian') rather than lm() for fitting models with normal distribution residuals. This raises the suspicion that there could be a bug in drop1() and step(), which I think uses add1() and drop1() repeatedly. Thomas P C Chu AOL Email goes Mobile! You can now read your AOL Emails whilst on the move. Sign up for a free AOL Email account with unlimited storage today. ** See what's new at http://www.aol.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] Is R's fast fourier transform function different from fft2 in Matlab?
Yep you are totally right. I looked at the graphs to do the analysis quickly, and sacrificed correctness. z - rnorm(5000) z.ts - ts(z) f - fft(z.ts) d - fft(f, inverse=T) plot(z.ts, d/5000) #this is how far off the algorithm was from recreating the series. After it is divided by the signal length. plot((z.ts)-(d/5000)) Does this hold for longer signals, too? On Thu, Jul 31, 2008 at 11:30 PM, Rolf Turner [EMAIL PROTECTED] wrote: On 1/08/2008, at 2:56 PM, stephen sefick wrote: z - rnorm(5000) f - fft(z) d - fft(f, inverse=T) plot(z, d) z - rnorm(5000) z.ts - ts(z) f - fft(z.ts) d - fft(f, inverse=T) plot(z.ts, d) temp - matrix(c(1,4,2, 20), nrow=2) d - fft(temp) f - fft(d, inverse=T) plot(temp, f) this, looks to me, to be the same. Then I think you'd better get your eyes checked, mate! you have to take the inverse of the fft to get the original series. No you ***don't*** get the original series; you get n*(the original series) where n is the series length. I.e. the fft in R (and in S/Splus) does not apply any normalizing factor, so that the inverse transform only ``inverts'' up to a constant multiple. cheers, Rolf Turner ## Attention:This e-mail message is privileged and confidential. If you are not theintended recipient please delete the message and notify the sender.Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshalwww.marshalsoftware.com ## -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Major difference in the outcome between SPSS and R statistical programs
Dear collegues, I have used R statistical program, package 'lmer', several times already. I never encountered major differences in the outcome between SPSS and R. ...untill my last analyses. Would some know were the huge differences come from. Thanks in advance, Ronald In SPSS the Pearson correlation between variable 1 and variable 2 is 31% p0.001. In SPSS binary logistic regression gives us an OR=4.9 (95% CI 2.7-9.0), p0.001, n=338. OR lower upper gender 1,120 0,565 2,221 age 0,985 0,956 1,015 variable 2 4,937 2,698 9,032 In R multilevel logistic regression using statistical package 'lmer' gives us an OR=10.2 (95% CI 6.3-14), p=0.24, n=338, groups: group 1, 98; group 2 84. OR lower upper gender 2,295-2,840 7,430 age 0,003-70,047 70,054 variable 2 10,176 6,295 14,056 The crosstabs gives us: variable A Var B 0 1 0 156 108 1 17 57 Would somebody know how it is possible that in SPSS we get p0.001 and in R we get p=0.24? [[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] Diffusion maps and isomaps
Hi, I was just woundering if there is in R a stable package for: - Diffusion maps [1] - Isomaps [2] 1: http://www.cs.tau.ac.il/~shekler/Seminar2007a/DM%20GH%20and%20App/dm_elsevier.pdf 2: http://isomap.stanford.edu/ Thanks Peter -- http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] allocMatrix limits
Martin Maechler wrote: VK The problem is in array.c, where allocMatrix check for VK if ((double)nrow * (double)ncol INT_MAX). But why VK itn is used and not long int for indexing? (max int is VK 2147483647, max long int is 9223372036854775807) Well, Brian gave you all info: exactly, and given that most modern system used for computations (i.e. 64bit system) have long int which is much larger than int, I am wondering why long int is not used for indexing (I don't think that 4 bit vs 8 bit storage is an issue). Did you really carefully read ?Memory-limits ?? Yes, it is specify that 4 bit int is used for indexing in all version of R, but why? I think 2147483647 elements for a single vector is OK, but not as total number of elements for the matrix. I am running out of indexing at mere 10% memory consumption. BTW: The package 'Matrix' has many facilities to work with sparse matrices; Is is a very good package, but I don't see a relation to a limitation in array.c (and I don't have scarce matrices). Thanks, Vadim PS: I have no problem to go and modify C code, but I am just wondering what are the reasons for having such limitation. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] parent in Creating environment object
Hi, I would like to convert a simple list into an environment object. It seems I have to create an environment object with new.env() and assign the single values afterwards. Now what I did not really understand from the guides until now is, how the parent environment supplied to the new.env() function influence the final environment. So: 1. Do I ALWAYS have to supply a parent during creation? 2. If yes, what would that be, when all I want is a conversion from a simple list? Best regards Benjamin == Benjamin Otto University Hospital Hamburg-Eppendorf Institute For Clinical Chemistry Martinistr. 52 D-20246 Hamburg Tel.: +49 40 42803 1908 Fax.: +49 40 42803 4971 == -- Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universitätsklinikum Hamburg-Eppendorf Körperschaft des öffentlichen Rechts Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Jörg F. Debatin (Vorsitzender) Dr. Alexander Kirstein Ricarda Klein Prof. Dr. Dr. Uwe Koch-Gromus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 : bwplot with Date object
I ended up finding one solution to my 2nd question. Here it is : http://tolstoy.newcastle.edu.au/R/help/04/01/0649.html Sorry for the bother. David De: GOUACHE David Date: ven. 01/08/2008 15:50 À: Deepayan Sarkar Cc: [EMAIL PROTECTED] Objet : RE : [R] bwplot with Date object Hello and thank you for your reply. My dummy example was a bit too simple... I'm having difficulty correctly specifying the 'at' component since my real situation concerns a multipanel display with ' relation=free '. To illustrate : dates-as.Date(32768:32895,origin=1900-01-01) plouf-data.frame(days=dates,group=factor(rep(1:2,times=128/2))) plouf$group2-factor(rep(1:2,each=2)) plouf$days[plouf$group2==2]-plouf$days[plouf$group2==2]+50 bwplot(group~as.numeric(days)|group2,data=plouf,scales=list(x=list(at=mean(x),relation=free))) I would have liked one tick at the mean of the x values in each panel... Which isn't what I obtain. How do I customize the location of the tick marks for each panel ? Thanks again. David De: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Date: ven. 01/08/2008 00:12 À: GOUACHE David Cc: [EMAIL PROTECTED] Objet : Re: [R] bwplot with Date object On Thu, Jul 31, 2008 at 12:54 PM, GOUACHE David [EMAIL PROTECTED] wrote: Hello R-helpers, I would like to produce a boxplot for dates, using lattice. Here is a dummy example : dates-as.Date(32768:32895,origin=1900-01-01) plouf-data.frame(days=dates,group=factor(rep(1:2,times=128/2))) bwplot(group~days,data=plouf) # doesn't work, whereas : bwplot(group~as.numeric(days),data=plouf) # does, but is obviously not good looking when it comes to axis legends... Is there a way to pull off a boxplot with dates ? The automatic calculation of tick positions clearly gives less than useful results. You should be able to supply locations explicitly using bwplot(..., scales=list(x = list(at = ...)) ) -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] parent in Creating environment object
On 8/1/2008 9:46 AM, Benjamin Otto wrote: Hi, I would like to convert a simple list into an environment object. It seems I have to create an environment object with new.env() and assign the single values afterwards. Now what I did not really understand from the guides until now is, how the parent environment supplied to the new.env() function influence the final environment. So: Environments aren't just lists of objects, they also specify where to look if a particular entry is not found, i.e. they say to look in the parent. 1. Do I ALWAYS have to supply a parent during creation? No, you'll get a default one, which is the current evaluation environment. For example, f - function() { +x - 123 +return(new.env()) + } e - f() e$x NULL Using the $ notation does *not* look in the parent. get(x, e) [1] 123 Using get() does, unless get(x, e, inherits=FALSE) Error in get(x, e, inherits = FALSE) : variable x was not found you say inherits=FALSE. Duncan Murdoch 2. If yes, what would that be, when all I want is a conversion from a simple list? Best regards Benjamin == Benjamin Otto University Hospital Hamburg-Eppendorf Institute For Clinical Chemistry Martinistr. 52 D-20246 Hamburg Tel.: +49 40 42803 1908 Fax.: +49 40 42803 4971 == __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] allocMatrix limits
VK == Vadim Kutsyy [EMAIL PROTECTED] on Fri, 01 Aug 2008 07:35:01 -0700 writes: VK Martin Maechler wrote: VK The problem is in array.c, where allocMatrix check for VK if ((double)nrow * (double)ncol INT_MAX). But why VK itn is used and not long int for indexing? (max int is VK 2147483647, max long int is 9223372036854775807) Well, Brian gave you all info: VK exactly, and given that most modern system used for VK computations (i.e. 64bit system) have long int which is VK much larger than int, I am wondering why long int is not VK used for indexing (I don't think that 4 bit vs 8 bit VK storage is an issue). Did you really carefully read ?Memory-limits ?? VK Yes, it is specify that 4 bit int is used for indexing VK in all version of R, but why? I think 2147483647 VK elements for a single vector is OK, but not as total VK number of elements for the matrix. I am running out of VK indexing at mere 10% memory consumption. Hmm, do you have 160 GBytes of RAM? But anyway, let's move this topic from R-help to R-devel. [...] VK PS: I have no problem to go and modify C code, but I am VK just wondering what are the reasons for having such VK limitation. This limitation and its possible remedies are an interesting topic, but really not for R-help: It will be a lot about C programming the internal represenation of R objects, etc. Very fascinating but for R-devel. See you there! Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to get the p-value from lmer on a longitudinal analysis
Hi, I have a modelo like this: Yvar - c(0, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, 1, 2, 3, 6, 6, 3, 3, 4) TIME - 4:22 ID - rep(PlotA,19) m - lmer(Yvar~TIME+(TIME|ID),family=poisson) anova(m) summary(m) How to get the p-value for this case? Thanks Ronaldo -- Just because you're paranoid doesn't mean they AREN'T after you. -- Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Biologia Computacional | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8187 | [EMAIL PROTECTED] | [EMAIL PROTECTED] | http://www.ppgcb.unimontes.br/lbc | ICQ#: 5692561 | LinuxUser#: 205366 -- Favor NÃO ENVIAR arquivos do Word ou Powerpoint Prefira enviar em PDF, Texto, OpenOffice (ODF), HTML, or RTF. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get the p-value from lmer on a longitudinal analysis
on 08/01/2008 10:11 AM Ronaldo Reis Junior wrote: Hi, I have a modelo like this: Yvar - c(0, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, 1, 2, 3, 6, 6, 3, 3, 4) TIME - 4:22 ID - rep(PlotA,19) m - lmer(Yvar~TIME+(TIME|ID),family=poisson) anova(m) summary(m) How to get the p-value for this case? Thanks Ronaldo Unless something has changed recently: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-p_002dvalues-not-displayed-when-using-lmer_0028_0029_003f HTH, 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.
[R] Plotting ordered nominal data
Hi I'm sure this question has been asked before but I can't find it in the archives. I have a data frame which includes interval and ordered nominal results. It looks something like Measured Eyeball 46.5 Normal 43.5 Mild 56.2 Normal 41.1 Mild 37.8 Moderate 12.6 Severe 17.3 Moderate 39.1 Normal 26.7 Mild NULL Normal 27.9 NULL 68.1 Normal I want to plot the Measured value against the Eyeball value but if I simply plot it the Eyeball values are plotted in alphabetical order. I do not want to change the names as Normal, Mild, Moderate, Severe are standard but I want to plot them in the order Normal, Mild, Moderate, Severe so that the trend (or not) is obvious. Any help would be much appreciated. Many thanks Sandy *** This message may contain confidential and privileged information. If you are not the intended recipient you should not disclose, copy or distribute information in this e-mail or take any action in reliance on its contents. To do so is strictly prohibited and may be unlawful. Please inform the sender that this message has gone astray before deleting it. Thank you. 2008 marks the 60th anniversary of the NHS. It's an opportunity to pay tribute to the NHS staff and volunteers who help shape the service, and celebrate their achievements. If you work for the NHS and would like an NHSmail email account, go to: www.connectingforhealth.nhs.uk/nhsmail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Unexpected nls behaviour
Hi everyone, I thought that for a selfStart function, these two should be exactly equivalent nls(Aform, DF) nls(Aform, DF, start=getInitial(Aform, DF)) but in this example that is not the case in R (although it is in S-plus V6.2) -- SSbatch-selfStart( model=function(Batch, Coeffs) { Coeffs[Batch] } ,initial=function(mCall, data, LHS) { # Estimate coefficients as mean of each batch xy - sortedXyData(mCall[[Batch]], LHS, data) Batch - data[[as.character(mCall[[Batch]])]] # check Batch is successive integers starting at 1 if ((min(xy$x) !=1) | (any(diff(xy$x)!=1))) stop( Batch is not a successive integers sequence) Lval - list(xy$y) names(Lval) - mCall[Coeffs] Lval } ) DF - data.frame(A=c(0.9, 1.1, 1.9, 2.0, 2.1, 2.9, 3.0), Batch=c(1,1,2,2,2,3,3)) Aform - formula(A~SSbatch(Batch,cA)) nls(Aform, DF, start=getInitial(Aform, DF)) nls(Aform, DF) Don't ask why I'd want such a silly selfStart, that's a long story. I guess wherever I would have used nls(Aform, DF) I could use nls(Aform, DF, start=getInitial(Aform, DF)) but that seems clumsy. Can anyone point out my mistake? Or is this a limitation of nls in R (I hesitate to use the b*g word). Thanks in advance, Keith Jewell -- I don't think it's relevant but, for completeness: sessionInfo() version 2.7.0 (2008-04-22) i386-pc-mingw32 locale: LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252 attached base packages: [1] stats graphics grDevices datasets tcltk utils methods base other attached packages: [1] xlsReadWrite_1.3.2 svSocket_0.9-5 svIO_0.9-5 R2HTML_1.58 svMisc_0.9-5 svIDE_0.9-5 loaded via a namespace (and not attached): [1] tools_2.7.0 VGAM_0.7-7 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Major difference in the outcome between SPSS and R statisticalprograms
The biggest problem is that SPSS cannot fit a generalized linear mixed model but lmer does. So, why would you expect the GLM in SPSS and the GLMM in lmer to match anyhow? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Draga, R. Sent: Friday, August 01, 2008 10:19 AM To: r-help@r-project.org Subject: [R] Major difference in the outcome between SPSS and R statisticalprograms Dear collegues, I have used R statistical program, package 'lmer', several times already. I never encountered major differences in the outcome between SPSS and R. ...untill my last analyses. Would some know were the huge differences come from. Thanks in advance, Ronald In SPSS the Pearson correlation between variable 1 and variable 2 is 31% p0.001. In SPSS binary logistic regression gives us an OR=4.9 (95% CI 2.7-9.0), p0.001, n=338. OR lower upper gender 1,120 0,565 2,221 age 0,985 0,956 1,015 variable 2 4,937 2,698 9,032 In R multilevel logistic regression using statistical package 'lmer' gives us an OR=10.2 (95% CI 6.3-14), p=0.24, n=338, groups: group 1, 98; group 2 84. OR lower upper gender 2,295-2,840 7,430 age 0,003-70,047 70,054 variable 2 10,176 6,295 14,056 The crosstabs gives us: variable A Var B 0 1 0 156 108 1 17 57 Would somebody know how it is possible that in SPSS we get p0.001 and in R we get p=0.24? [[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] creating image using RGB values
Hi R users, I would like to create an image using three matrices which contain the values of Red, Green, and Blue of each pixel, i.e. one matrix which has values of red, one which has values of green, and one which has values of blue. The values are between 0 and 1 instead of 0-255. I have obtained the matrices using the getChannels of pixmap library. I wonder if anyone knows how to create the image using RGB matrices. Thanks for your help. Thanks, Rostam [[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] bug in readRAST6 function in package spgrass6
Hi if I try to import a raster layer which consists only of NULL values from grass by using the readRAST6, I get an error message: readRAST6(HSericea_seedsDisperse_2007) ERROR: Invalid value for null (integers only) Error in readBinGrid(rtmpfl11, colname = vname[i], proj4string = p4, integer = to_int) : no such file: /home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/.tmp/ecolmod/HSericea_seedsDisperse_2007 Thanks Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Faculty of Science Natural Sciences Building Private Bag X1 University of Stellenbosch Matieland 7602 South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] creating image using RGB values
Hi Rostam, did you check ?rgb already? Hope this helps, Roland rostam shahname wrote: Hi R users, I would like to create an image using three matrices which contain the values of Red, Green, and Blue of each pixel, i.e. one matrix which has values of red, one which has values of green, and one which has values of blue. The values are between 0 and 1 instead of 0-255. I have obtained the matrices using the getChannels of pixmap library. I wonder if anyone knows how to create the image using RGB matrices. Thanks for your help. Thanks, Rostam [[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] drop1() seems to give unexpected results compare to anova()
Thomas Chu wrote: Neither of those 3 lines of commands managed to drop x4 and its P value magically decreased from 0.94 to almost 0! I am also baffled by how R calculated those RSS. Maybe it is using a different type of SS. If i have a lm() model, and i do: options(contrasts=c(contr.sum, contr.poly)); anovafit - drop1(model,attributes(model$terms)$term.labels,test=F); then i get identical SS, F and p values as in SPSS. Maybe http://www.nabble.com/set-type-of-SS-in-anova()-to18287076.html#a18287076 this post is helpfull. Also check out the post on http://myowelt.blogspot.com/ this blog from 2008-05-24: Obtaining the same ANOVA results in R as in SPSS - the difficulties with Type II and Type III sums of squares . -- View this message in context: http://www.nabble.com/drop1%28%29-seems-to-give-unexpected-results-compare-to-anova%28%29-tp18770635p1813.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] Major difference in the outcome between SPSS and R statisticalprograms
First off, Marc Schwartz posted this link earlier today, read it. http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-p_002dvalues-not-di splayed-when-using-lmer_0028_0029_003f Second, your email is not really descriptive enough. I have no idea what OR is, so I have no reaction. Third, you're comparing estimates from different methods of estimation. lmer will give standard errors that account for the correlation of individuals within similar units whereas the SPSS procedure will not. The lmer standard errors better capture the true sampling variance of the parameters and SPSS doesn't. -Original Message- From: Draga, R. [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2008 11:45 AM To: Doran, Harold Subject: RE: [R] Major difference in the outcome between SPSS and R statisticalprograms Thanks for the reaction I know, I would not expect the outcomes to be the same. But, I have never before encountered such a difference in outcomes between SPSS and R; mostly the OR's and p-values differed a little bit. Strange is that R shows a OR of 10,176 and 95% CI of 6,295-14,056. Then the p-value must be 0.05 doesn't it? For age the OR's differ dramatically between SPSS and R, 0.985 and 0.003. I just can not explain it. Ronald -Oorspronkelijk bericht- Van: Doran, Harold [mailto:[EMAIL PROTECTED] Verzonden: vrijdag 1 augustus 2008 17:36 Aan: Draga, R.; r-help@r-project.org Onderwerp: RE: [R] Major difference in the outcome between SPSS and R statisticalprograms The biggest problem is that SPSS cannot fit a generalized linear mixed model but lmer does. So, why would you expect the GLM in SPSS and the GLMM in lmer to match anyhow? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Draga, R. Sent: Friday, August 01, 2008 10:19 AM To: r-help@r-project.org Subject: [R] Major difference in the outcome between SPSS and R statisticalprograms Dear collegues, I have used R statistical program, package 'lmer', several times already. I never encountered major differences in the outcome between SPSS and R. ...untill my last analyses. Would some know were the huge differences come from. Thanks in advance, Ronald In SPSS the Pearson correlation between variable 1 and variable 2 is 31% p0.001. In SPSS binary logistic regression gives us an OR=4.9 (95% CI 2.7-9.0), p0.001, n=338. OR lower upper gender 1,120 0,565 2,221 age 0,985 0,956 1,015 variable 2 4,937 2,698 9,032 In R multilevel logistic regression using statistical package 'lmer' gives us an OR=10.2 (95% CI 6.3-14), p=0.24, n=338, groups: group 1, 98; group 2 84. OR lower upper gender 2,295-2,840 7,430 age 0,003-70,047 70,054 variable 2 10,176 6,295 14,056 The crosstabs gives us: variable A Var B 0 1 0 156 108 1 17 57 Would somebody know how it is possible that in SPSS we get p0.001 and in R we get p=0.24? [[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] bug in readRAST6 function in package spgrass6
On Fri, Aug 1, 2008 at 6:03 PM, Roger Bivand [EMAIL PROTECTED] wrote: On Fri, 1 Aug 2008, Rainer M Krug wrote: Hi if I try to import a raster layer which consists only of NULL values from grass by using the readRAST6, I get an error message: readRAST6(HSericea_seedsDisperse_2007) ERROR: Invalid value for null (integers only) Error in readBinGrid(rtmpfl11, colname = vname[i], proj4string = p4, integer = to_int) : no such file: /home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/.tmp/ecolmod/HSericea_seedsDisperse_2007 Please use the statgrass list for questions like this. Thank's for the pro,mpt response - I'll do so th next time. Examination of readRAST6() shows that if the NODATA= argument is not given, it is set to one less than the minimum data value. You have no data at all, so the heuristic fails. Set NODATA= and it should work. Thanks for the tip. Not a bug, rasters can reasonably be assumed to have data. If you like, on the appropriate list document a small case for which the heuristic should be changed to assign an arbitrary NODATA= (outside the range of the data) using information from r.info or other GRASS commands I'll do so in a few minute. Roger Thanks Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Faculty of Science Natural Sciences Building Private Bag X1 University of Stellenbosch Matieland 7602 South Africa -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Faculty of Science Natural Sciences Building Private Bag X1 University of Stellenbosch Matieland 7602 South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Memory Problems with a Simple Bootstrap
I have a data file called inputdata.csv that looks something like this ID YearResult Month Date 1 71741954 103 540301 2 7174195443 540322 3 20924 1967 4 2 670223 4 20924 1967 -75 670518 5 20924 1967 -37 670706 ... 67209 ... i.e., it goes on for 67209 rows (~2 Mb file). When I run the following bootstrap session I get the indicated error: library(boot) setwd(C:/Documents and Settings/Tom/Desktop) data.in - read.csv(inputdata.csv,header=T,as.is=T) per95 - function( annual.data, b.index) { + sample.data - annual.data[b.index,] + return(quantile(sample.data$Result,probs=c(0.95))) } m - 1 for (i in 1:39) { + annual.data - data.in[data.in$Year == (i+1949),] + B - boot(data=annual.data,statistic=per95,R=m) + print(i) + print(memory.size()) + } [1] 1 [1] 20.26163 [1] 2 [1] 61.6352 [1] 3 [1] 134.4187 [1] 4 [1] 149.4704 [1] 5 [1] 290.3090 [1] 6 [1] 376.7017 [1] 7 [1] 435.7683 [1] 8 [1] 463.7404 [1] 9 [1] 497.7946 Error: cannot allocate vector of size 568.8 Mb I am running this on a Windows XP Pro machine with 4 Gb of memory. The same problem occurs when the code is executed on the same box running Ubuntu 8.04. Does anyone see any obvious reason why this should run out of memory? I would be happy to email the data file to anyone who cares to try it on their computer. Tom -- View this message in context: http://www.nabble.com/Memory-Problems-with-a-Simple-Bootstrap-tp18777897p18777897.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] bug in readRAST6 function in package spgrass6
On Fri, 1 Aug 2008, Rainer M Krug wrote: Hi if I try to import a raster layer which consists only of NULL values from grass by using the readRAST6, I get an error message: readRAST6(HSericea_seedsDisperse_2007) ERROR: Invalid value for null (integers only) Error in readBinGrid(rtmpfl11, colname = vname[i], proj4string = p4, integer = to_int) : no such file: /home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/.tmp/ecolmod/HSericea_seedsDisperse_2007 Please use the statgrass list for questions like this. Examination of readRAST6() shows that if the NODATA= argument is not given, it is set to one less than the minimum data value. You have no data at all, so the heuristic fails. Set NODATA= and it should work. Not a bug, rasters can reasonably be assumed to have data. If you like, on the appropriate list document a small case for which the heuristic should be changed to assign an arbitrary NODATA= (outside the range of the data) using information from r.info or other GRASS commands Roger Thanks Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Faculty of Science Natural Sciences Building Private Bag X1 University of Stellenbosch Matieland 7602 South Africa -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] standardize ggplot and lattice themes
Dear list, I'm writing a long document (thesis) and as much as I would like to use only ggplot2 for the graphics, some features are still a bit undocumented so I often end up choosing either ggplot2, lattice, or base plots (which i know better) depending on the particular graph to produce. With the default settings, this does not make for a consistent look I would like to see throughout the document. I really like most default settings in ggplot's theme (grid, labels spacing, background, ...), and I would like to produce a similar theme for use with lattice. I've made such an attempt in base graphics – see beow, it's just silly – but I think i could get away with using only lattice and ggplot2. I don't know lattice well (just started using it, really), so I'm sort of lost in the jungle of parameters. Can anyone help me set up a lattice theme for the following example? Best wishes, baptiste library(ggplot2) library(lattice) # example data x - seq(0, 10, len = 100) y1 - jitter(sin(x), 1000) y2 - 0.5*jitter(cos(x), 1000) # custom colors greyDark - grey(0.5) greyLight - grey(0.9) myColors - c( #E41A1C, #377EB8) palette(myColors) # here is the ggplot2 version df - melt(data.frame(x=x, one=y1, two=y2), id=x) p - qplot(x,value, data=df,colour=variable, linetype=variable, main=ggplot2 (almost) defaults) p - p + scale_colour_manual(values = myColors) print(p) # lattice version strip.background - trellis.par.get(strip.background) background - trellis.par.get(background) plot.symbol - trellis.par.get(plot.symbol) trellis.par.set(strip.background = list(col = grey(7:1/8))) trellis.par.set(plot.symbol = list(col = myColors, pch=16)) trellis.par.set(background = list(col = greyLight)) # this does not clip to the plot region ... p2 - xyplot(value ~ x, data=df) print(p2) # example using base graphics old.par - par() par(cex=1, bty = n,fg = greyDark, col.lab = black, xpd = FALSE, mar = old.par$mar + c(-2,-1,-1,3), mgp=c(1.8, 0.5, 0), col=black) plot(x, y1, new=TRUE, t=n) # plots nothing, needed to find the dimensions lims - par(usr) subGrid1 - axTicks(1) + mean(diff(axTicks(1)))/2 # position of the grid sub-divisions subGrid2 - axTicks(2) + mean(diff(axTicks(2)))/2 plot(x, y1, col=1, xlab = x, ylab = value, xaxt = n, yaxt = n, pch=16, cex=0.8, panel.first = { rect(lims[1], lims[3], lims[2], lims[4],bord = NA, col = greyLight); # grey background segments(axTicks(1),lims[3], axTicks(1), lims[4], col = white , lwd=1.2); # main grid segments(lims[2], axTicks(2),lims[3], axTicks(2), col = white , lwd=1.2); segments(subGrid1,lims[3], subGrid1, lims[4], col = white , lwd=0.5); # secondary grid segments(lims[2], subGrid2,lims[3], subGrid2, col = white , lwd=0.5); axis(1, lty = solid, lwd = 1, col = greyDark, col.axis = greyDark, tcl=-0.4, cex.axis = 0.8); # axis axis(2, lty = solid, lwd = 1, col = greyDark, col.axis = greyDark, las=1, tcl=-0.4, cex.axis = 0.8);}) par(bty=o) box(col=white, lwd=3) # draws in white over the axes points(x, y2, col = 2, cex=0.8, pch=16) # some more plotting as usual par(xpd = TRUE) # legend is outside legend(1.1*max(x), mean(y1), pch=16, col=1:2, c(one, two), bty=n, title=variable) title(main = ggplot theme with base graphics) par(old.par) _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Best way to select good points in a noisy signal ?
I'm not quite sure if this is what you mean but have a look at ?lowess or ?smooth. I think you might get want you want if you play around with the parameters in lowess --- On Fri, 8/1/08, Ptit_Bleu [EMAIL PROTECTED] wrote: From: Ptit_Bleu [EMAIL PROTECTED] Subject: [R] Best way to select good points in a noisy signal ? To: r-help@r-project.org Received: Friday, August 1, 2008, 8:28 AM Hello, When I plot y=f(x) from the file xy.txt ( http://www.nabble.com/file/p18773387/xy.txt xy.txt ), I can clearly see a trend. Is there a function or a package able to take the median value of y for an interval of x (x +/- a defined value) to plot nice graph (at least a better one) ? Thanks in advance, Have a nice week-end, Ptit Bleu. -- View this message in context: http://www.nabble.com/Best-way-to-select-good-points-in-a-noisy-signal---tp18773387p18773387.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. __ [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Plotting ordered nominal data
Sandy, You can re-order a factor with df$Eyeball-factor(df$Eyeball, levels=c(Normal, Mild, Moderate, Severe), ordered=T) (assuming df is your data frame and that you want an _ordered_ factor; the latter is not essential to your plots) Incidentally, NULL isn't a particularly friendly item to find in a data frame. NULL often implies I'm not here at all while NA says I exist but I'm a missing value. For an example of when it might matter, try length(c(1,2,NULL,3)) #versus length(c(1,2,NA,3)) Steve E Sandy Small [EMAIL PROTECTED] 01/08/2008 16:21:29 Hi I'm sure this question has been asked before but I can't find it in the archives. I want to plot them in the order Normal, Mild, Moderate, Severe so that the trend (or not) is obvious. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Exporting data to a text file
HI R users With clara function I get a data frame (maybe this is not the exact word, I'm new to R) with the following variables: names(myclara) [1] sample medoidsi.med clustering objective [6] clusinfo diss call silinfodata I want to export clustering and data to a new text file so I try write.table(myclara$data,cluster.dat) write.table(myclara$clustering,cluster.dat,append=TRUE) Variable data is properly exported but clustering is not appended to the output file. Please, where is the mistake? is it possible to export the two variables in just a sentence? thanks in advance Paco -- _ El ponent la mou, el llevant la plou Usuari Linux registrat: 363952 --- Fotos: http://picasaweb.google.es/pacomet [[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] Plotting ordered nominal data
on 08/01/2008 10:21 AM Sandy Small wrote: Hi I'm sure this question has been asked before but I can't find it in the archives. I have a data frame which includes interval and ordered nominal results. It looks something like Measured Eyeball 46.5 Normal 43.5 Mild 56.2 Normal 41.1 Mild 37.8 Moderate 12.6 Severe 17.3 Moderate 39.1 Normal 26.7 Mild NULL Normal 27.9 NULL 68.1 Normal I want to plot the Measured value against the Eyeball value but if I simply plot it the Eyeball values are plotted in alphabetical order. I do not want to change the names as Normal, Mild, Moderate, Severe are standard but I want to plot them in the order Normal, Mild, Moderate, Severe so that the trend (or not) is obvious. Any help would be much appreciated. Many thanks Sandy We are going to need a bit more info. What type of plot? Point estimates of the means per level of severity? Boxplot? Some possibilities: # Read in the data from the clipboard, converting the NULLs to NAs DF - read.table(clipboard, header = TRUE, na.strings = NULL) DF Measured Eyeball 1 46.5 Normal 2 43.5 Mild 3 56.2 Normal 4 41.1 Mild 5 37.8 Moderate 6 12.6 Severe 7 17.3 Moderate 8 39.1 Normal 9 26.7 Mild 10 NA Normal 11 27.9 NA 12 68.1 Normal # Change the factor ordering and include NA as a level DF$Eyeball - factor(DF$Eyeball, levels = c(Normal, Mild, Moderate, Severe, NA), exclude = NULL) # Do a boxplot boxplot(Measured ~ Eyeball, data = DF) # Plot means by severity Res - tapply(DF$Measured, list(DF$Eyeball), mean, na.rm = TRUE) plot(Res, pch = 19, ylab = Mean, xlab = Severity, xaxt = n) axis(1, at = 1:5, paste(names(Res))) See ?factor, ?plot.default, ?boxplot and ?axis HTH, 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] Memory Problems with a Simple Bootstrap
Use gc() in the loop to possibly free up any fragmented memory. You might also print out the size of B (object.size(B)) since that appears to be the only variable in your loop that might be growing. On Fri, Aug 1, 2008 at 12:09 PM, Tom La Bone [EMAIL PROTECTED] wrote: I have a data file called inputdata.csv that looks something like this ID YearResult Month Date 1 71741954 103 540301 2 7174195443 540322 3 20924 1967 4 2 670223 4 20924 1967 -75 670518 5 20924 1967 -37 670706 ... 67209 ... i.e., it goes on for 67209 rows (~2 Mb file). When I run the following bootstrap session I get the indicated error: library(boot) setwd(C:/Documents and Settings/Tom/Desktop) data.in - read.csv(inputdata.csv,header=T,as.is=T) per95 - function( annual.data, b.index) { + sample.data - annual.data[b.index,] + return(quantile(sample.data$Result,probs=c(0.95))) } m - 1 for (i in 1:39) { + annual.data - data.in[data.in$Year == (i+1949),] + B - boot(data=annual.data,statistic=per95,R=m) + print(i) + print(memory.size()) + } [1] 1 [1] 20.26163 [1] 2 [1] 61.6352 [1] 3 [1] 134.4187 [1] 4 [1] 149.4704 [1] 5 [1] 290.3090 [1] 6 [1] 376.7017 [1] 7 [1] 435.7683 [1] 8 [1] 463.7404 [1] 9 [1] 497.7946 Error: cannot allocate vector of size 568.8 Mb I am running this on a Windows XP Pro machine with 4 Gb of memory. The same problem occurs when the code is executed on the same box running Ubuntu 8.04. Does anyone see any obvious reason why this should run out of memory? I would be happy to email the data file to anyone who cares to try it on their computer. Tom -- View this message in context: http://www.nabble.com/Memory-Problems-with-a-Simple-Bootstrap-tp18777897p18777897.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Smartest way to evaluate question forms
Hi, I'm trying to help a friend who is doing a thesis in a nurse college, to evaluate medical question forms. There are about 30 questions giving more than 110 parameters to describe each responding person's (gender, health etc.) and there are about 120 question forms to evaluate. I have basically 2 questions. 1. What to search for. 2. How to evaluate it statisticaly. As for No. 1. I have these ideas. To search for significant groups. Meaning, that i would like to find all significant groups that have a certain criteria in common. F.e. All men, that have a good doctor patient relationship. The idea is to fix 1,2,3,4 or five parameters f.e. white divorced men in their 60s and to look for any other significant parameters (meaning one or multiple) they have in common (where I can set some significance boundary) Later on, i would like to look up question forms with the highest number of common parameters and find the parameters with the highest and lowest rate of divergence. Eventually it might be interesting to look for some correlations between 2 and more parameters. As for No. 2 I would like to know if there is a R module having performing this kind of tasks. I think the problem could be analyzed by treating all the params as a binomial tree and then measure length and repetition of certain path segments I have written a simple prog in VBasic to do the first part of the analysis, but i would be thankful for any hint or advice regarding this problem, especially any info about existing solutions with R. -- View this message in context: http://www.nabble.com/Smartest-way-to-evaluate-question-forms-tp18776233p18776233.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] graph
Hello. I don't know how to do to ouput segments between points like the chart attached. Can you help me please? Thanks. _ Envo__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] graph
Hello. I don't know how to do to ouput segments between points like the chart attached. Can you help me please? Thanks. .yahoo.fr__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R CMD INSTALL error, R-2.7.1
Hi, I am getting the following error when using R CMD INSTALL ever since I upgraded to R-2.7.1: hhc: not found CHM compile failed: HTML Help Workshop not intalled? As indicated, the package is installed but without CHM help files. I have downloaded the latest version of Rtools and I have tried uninstalling and reinstalling HTML Help Workshop. I have also tried rebuilding the package several times. I was able to build and install the package without problems with R-2.7.0. Any ideas? Thanks. Richard platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 7.1 year 2008 month 06 day23 svn rev45970 language R version.string R version 2.7.1 (2008-06-23) -- Richard Chandler, PhD student Department of Natural Resources Conservation UMass Amherst (413)545-1237 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Plotting ordered nominal data
I'm not really clear on what you want here. Are you talking about plotting multiple data points for each value ? In that case something like boxplot might be what you want. Otherwise if you just wish to plot a data point for each occurance of Normal etc then this will work but I'm not sure how appropriate it is as a way to look at the data. If the graph looks a bit squashed, just stretch it. x - 'Measured Eyeball 46.5 Normal 43.5 Mild 56.2 Normal 41.1 Mild 37.8 Moderate 12.6 Severe 17.3 Moderate 39.1 Normal 26.7 Mild NA Normal 27.9 NA 68.1 Normal' xx - read.table(textConnection(x), header=TRUE, as.is=TRUE); xx df1 - data.frame(Eyeball= c(Normal, Mild, Moderate, Severe), nums= c(1:4)) df2 - merge(xx, df1, by=Eyeball, all=TRUE) plot(df2[,2], xaxt=n, xlab=Eyeball, ylab=Measured) mtext(1, text=df2[,1], at=1:length(df2[,1]), line = 1 , cex=.7 ) __ [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] chron objects: input/output
Just recently the ability to handle POSIXt style formats in as.chron was added: x - c(07/01/2001 12:00:00,07/17/2001 15:00:00) y - as.chron(x, %m/%d/%Y %H:%M:%S) y [1] (07/01/01 12:00:00) (07/17/01 15:00:00) # Here is a workaround format(as.POSIXct(y), tz = GMT, format = %m/%d %H:%M) [1] 07/01 12:00 07/17 15:00 On Fri, Aug 1, 2008 at 9:48 AM, Stephen Tucker [EMAIL PROTECTED] wrote: Hi list, I have some questions regarding 1) conversion of date + time characters to chron 2) formatting chron object printing Regarding (1), Gabor's Rnews 2004 4/1 article has been indispensible, but I often work with files where dates and times are contained in a single field. In this case, I would like to control input/output of chron objects when each observation of date and time is stored as a single string. So here are some procedures that I've tried: ## define character vector x - c(07/01/2001 12:00:00,07/17/2001 15:00:00) ## method 1 library(chron) chron(substring(x,1,10),substring(x,12)) [1] (07/01/01 12:00:00) (07/17/01 15:00:00) ## method 2 (recently inspired by Gabor's post) do.call(c,strapply(x,(.*) (.*),chron,backref=-2)) [1] (07/01/01 12:00:00) (07/17/01 15:00:00) ## method 3 (chronObj - as.chron(strptime(x,%m/%d/%Y %T))) [1] (07/01/01 12:00:00) (07/17/01 15:00:00) Could there be any gotchas with the third method (as.chron(strptime(...)))? The 'tz' attribute for POSIXlt objects are ignored, but I am not sure if there are any implications of the '$isdst' field are for conversions. I do like this alternative for the conciseness-flexibility tradeoff; in my experience, I have not had any problems - but wanted to inquire if at some point the '$isdst' field (or possibly something else) could give me trouble. Regarding the printing of chron objects, this behavior is peculiar to me: format(chronObj,format=c(m/d,h:m)) [1] (0701 1200) (0717 1500) The special characters (/,:) are not printed - I've tried changing the attribute of the chron object, looked at the format.chron() method (getS3method(format,chron)), etc. and am still confused; the chron() documentation says its specification should be similar the input format. Could I have missed something? Thanks! ST __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Exporting data to a text file
try str(myclara) to see what you have - a data frame , matrix etc Are you getting any error messages? I tried your write.table commands and they work okay. --- On Fri, 8/1/08, pacomet [EMAIL PROTECTED] wrote: From: pacomet [EMAIL PROTECTED] Subject: [R] Exporting data to a text file To: r-help@r-project.org Received: Friday, August 1, 2008, 12:49 PM HI R users With clara function I get a data frame (maybe this is not the exact word, I'm new to R) with the following variables: names(myclara) [1] sample medoids i.med clustering objective [6] clusinfo diss call silinfo data I want to export clustering and data to a new text file so I try write.table(myclara$data,cluster.dat) write.table(myclara$clustering,cluster.dat,append=TRUE) Variable data is properly exported but clustering is not appended to the output file. Please, where is the mistake? is it possible to export the two variables in just a sentence? thanks in advance Paco -- _ El ponent la mou, el llevant la plou Usuari Linux registrat: 363952 --- Fotos: http://picasaweb.google.es/pacomet [[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 get the p-value from lmer on a longitudinal analysis
Em Sex 01 Ago 2008, Marc Schwartz escreveu: on 08/01/2008 10:11 AM Ronaldo Reis Junior wrote: Hi, I have a modelo like this: Yvar - c(0, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, 1, 2, 3, 6, 6, 3, 3, 4) TIME - 4:22 ID - rep(PlotA,19) m - lmer(Yvar~TIME+(TIME|ID),family=poisson) anova(m) summary(m) How to get the p-value for this case? Thanks Ronaldo Unless something has changed recently: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-p_002dvalues-not-displ ayed-when-using-lmer_0028_0029_003f HTH, Marc Schwartz Hi Marc, thanks for the link. I knowed about this discussion, but I can't use the solution for this example. Look: Yvar - c(0, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, 1, 2, 3, 6, 6, 3, 3, 4) TIME - 4:22 ID - rep(PlotA,19) m - lmer(Yvar~TIME+(TIME|ID),family=poisson) anova(m) Analysis of Variance Table Df Sum Sq Mean Sq TIME 1 21.674 21.674 m2 - update(m,.~.-TIME) anova(m,m2) Data: Models: m2: Yvar ~ (TIME | ID) m: Yvar ~ TIME + (TIME | ID) Df AIC BIC logLik Chisq Chi Df Pr(Chisq) m2 4 m 5 23.8628 28.5850 -6.93141 # From the net # And an emperical p-value using a function supplied by Douglas Bates # to the R-help mailing list is another possibility: mcmcpvalue - function(samp) + { + ## elementary version that creates an empirical p-value for the + ## hypothesis that the columns of samp have mean zero versus a + ## general multivariate distribution with elliptical contours. + ## differences from the mean standardized by the observed + ## variance-covariance factor + std - backsolve(chol(var(samp)), +cbind(0, t(samp)) - colMeans(samp), +transpose = TRUE) + sqdist - colSums(std * std) + sum(sqdist[-1] sqdist[1])/nrow(samp) + } # Required package to perform mcmc-sampling: require(coda) # Perform sampling - NOTE: it takes a minute or two!: set.seed(12321) # To make the random numbers repeatable m3 - mcmcsamp(m, 1) # generate sample Erro: inconsistent degrees of freedom and dimension Erro em t(.Call(glmer_MCMCsamp, GSpt, saveb, n, trans, verbose, deviance)) : error in evaluating the argument 'x' in selecting a method for function 't' What is wrong? Thanks Ronaldo -- Also, the Scots are said to have invented golf. Then they had to invent Scotch whiskey to take away the pain and frustration. -- Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Biologia Computacional | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8187 | [EMAIL PROTECTED] | [EMAIL PROTECTED] | http://www.ppgcb.unimontes.br/lbc | ICQ#: 5692561 | LinuxUser#: 205366 -- Favor NÃO ENVIAR arquivos do Word ou Powerpoint Prefira enviar em PDF, Texto, OpenOffice (ODF), HTML, or RTF. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] nested calls, variable scope
Dear Bert: Thank you for your reply. But the eval.parent function does not seem to solve the problem. Below is the code. I have tried running it with eval.parent(myknot) as well as with integers from 0 through 4, as in eval.parent(myknot, 4) Each attempt produces the same error: Error in eval(expr, p) : object myknot not found I'm replying to the list in case someone can explain this. Jake fnJunk -function(myknot=44 , myMER ) { # Fit lmer (mer, lme4) models for WSER project, using spline (ns), and plot them for newdata. library(lme4) library(splines) if(missing(myMER)){ cat(myknot=, myknot) cat(fit another MER??) readline() myMER-lmer(formula=Finished ~ Sex01 + ns(DAT$Age, knots= eval.parent(myknot, 0) ) + MinCC + PzC + (1 | NAME ) + (1 | Year), data=(DAT), family=binomial) } # more stuff below here } On Thu, Jul 17, 2008 at 6:19 PM, Bert Gunter [EMAIL PROTECTED] wrote: As you may be aware, this is a case of FAQ for R 3.31, lexicographic scoping. It **can** be tricky, especially in a complex situation like yours. Typically eval() and/or substitute are what you need in such situations, to force evaluation in the appropriate environment. So try changing your ns(Dat$Age,knots=myknot) ## to ns(Dat$Age,knots=eval.parent(myknot)) If that doesn't work, await wiser advice. Cheers, Bert Gunter Genentech -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jacob Wegelin Sent: Thursday, July 17, 2008 1:58 PM To: [EMAIL PROTECTED] Subject: [R] nested calls, variable scope Below is an example of a problem I encounter repeatedly when I write functions. A call works at the command line, but it does not work inside a function, even when I have made sure that all required variables are available within the function. The only way I know to solve it is to make the required variable global, which of course is dangerous. What is the elegant or appropriate way to solve this? # The call to ns works at the command line: junk-ns(DAT$Age, knots=74) # The call to lmer works at the command line, with the call to ns nested within it: junk2-lmer(formula=Finished ~ Sex01 + ns(DAT$Age, knots= 74 ) + MinCC + PzC + (1 | NAME ) + (1 | Year), data=myDATonly, family=binomial) But now I want to do this within a function such as the following: myfn function(myknot=74) { library(lme4) library(splines) cat(myknot=, myknot, \n) myMER-lmer(formula=Finished ~ Sex01 + ns(DAT$Age, knots= myknot) + MinCC + PzC + (1 | NAME ) + (1 | Year), data=myDATonly, family=binomial) } myfn(74) myknot= 74 Error in ns(DAT$Age, knots = myknot) : object myknot not found # The bad way to do it: revise myfn to make myknot a global variable: myfn function(myknot=74) { library(lme4) library(splines) cat(myknot=, myknot, \n) myknot-myknot myMER-lmer(formula=Finished ~ Sex01 + ns(DAT$Age, knots= myknot ) + MinCC + PzC + (1 | NAME ) + (1 | Year), data=myDATonly, family=binomial) } z-myfn(74) myknot= 74 # Runs fine but puts a global variable into .GlobalEnv. sessionInfo() R version 2.6.2 (2008-02-08) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] splines stats graphics grDevices datasets utils methods base other attached packages: [1] lme4_0.999375-13 Matrix_0.999375-9 lattice_0.17-6 loaded via a namespace (and not attached): [1] boot_1.2-32 grid_2.6.2 Thanks for any insight. Jacob A. Wegelin [EMAIL PROTECTED] Assistant Professor Department of Biostatistics Virginia Commonwealth University 730 East Broad Street Room 3006 P. O. Box 980032 Richmond VA 23298-0032 U.S.A. http://www.people.vcu.edu/~jwegelin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Memory Problems with a Simple Bootstrap
Same problem. The Windows Task Manager indicated that Rgui.exe was using 1,249,722 K of memory when the error occurred. This is R 2.7.1 by the way. library(boot) setwd(C:/Documents and Settings/Tom/Desktop) data.in - read.csv(inputdata.csv,header=T,as.is=T) per95 - function( annual.data, b.index) { + sample.data - annual.data[b.index,] + return(quantile(sample.data$Result,probs=c(0.95))) } m - 1 for (i in 1:39) { + annual.data - data.in[data.in$Year == (i+1949),] + B - boot(data=annual.data,statistic=per95,R=m) + gc() + print(i) + print(object.size(B)) + print(memory.size()) + } [1] 1 [1] 90352 [1] 12.35335 [1] 2 [1] 111032 [1] 12.39024 [1] 3 [1] 155544 [1] 12.48451 [1] 4 [1] 159064 [1] 11.10526 [1] 5 [1] 243456 [1] 11.23505 [1] 6 [1] 280592 [1] 12.74642 [1] 7 [1] 302416 [1] 11.33087 [1] 8 [1] 319752 [1] 12.84377 [1] 9 [1] 351448 [1] 11.42264 Error: cannot allocate vector of size 284.4 Mb jholtman wrote: Use gc() in the loop to possibly free up any fragmented memory. You might also print out the size of B (object.size(B)) since that appears to be the only variable in your loop that might be growing. On Fri, Aug 1, 2008 at 12:09 PM, Tom La Bone [EMAIL PROTECTED] wrote: I have a data file called inputdata.csv that looks something like this ID YearResult Month Date 1 71741954 103 540301 2 7174195443 540322 3 20924 1967 4 2 670223 4 20924 1967 -75 670518 5 20924 1967 -37 670706 ... 67209 ... i.e., it goes on for 67209 rows (~2 Mb file). When I run the following bootstrap session I get the indicated error: library(boot) setwd(C:/Documents and Settings/Tom/Desktop) data.in - read.csv(inputdata.csv,header=T,as.is=T) per95 - function( annual.data, b.index) { + sample.data - annual.data[b.index,] + return(quantile(sample.data$Result,probs=c(0.95))) } m - 1 for (i in 1:39) { + annual.data - data.in[data.in$Year == (i+1949),] + B - boot(data=annual.data,statistic=per95,R=m) + print(i) + print(memory.size()) + } [1] 1 [1] 20.26163 [1] 2 [1] 61.6352 [1] 3 [1] 134.4187 [1] 4 [1] 149.4704 [1] 5 [1] 290.3090 [1] 6 [1] 376.7017 [1] 7 [1] 435.7683 [1] 8 [1] 463.7404 [1] 9 [1] 497.7946 Error: cannot allocate vector of size 568.8 Mb I am running this on a Windows XP Pro machine with 4 Gb of memory. The same problem occurs when the code is executed on the same box running Ubuntu 8.04. Does anyone see any obvious reason why this should run out of memory? I would be happy to email the data file to anyone who cares to try it on their computer. Tom -- View this message in context: http://www.nabble.com/Memory-Problems-with-a-Simple-Bootstrap-tp18777897p18777897.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Memory-Problems-with-a-Simple-Bootstrap-tp18777897p18779433.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 help request
Hi all, I have data that looks like number|grouping I would like to preform stats for each grouping so 1|5 6|5 10|5 11|5 3|9 5|9 10|9 Say I would like to take the median for above, I should be returned 2 lines, one for group #5 and one for group #9 Does this make sense? I am sorry for the basic question, can someone give me the name of a good book as well? Thanks, Lotta [[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] viewing data in something similar to 'R Data Editor'
Hi, I would like to view matrices I am working with in a clean, easy to read, separate window. A friend showed me how to do something like I want with edit(). I can view the matrix in the 'R Data Editor': For a sample matrix: mat=matrix(1:15,ncol=3) mat [,1] [,2] [,3] [1,]16 11 [2,]27 12 [3,]38 13 [4,]49 14 [5,]5 10 15 look=function(x) invisible(edit(x)) look(mat) That opens the 'R Data Editor' with mat loaded. But I am not able to do any other actions in R while this 'R Data Editor' is open. I want to keep this open while I do other work. Is there a way to view my data in something like the 'R Data Editor' that still allows me to do work at the same time? I am looking for something other than str(), head(), and tail() which just allow me a quick peak at the object. I do not want to edit the object in the table, but be able to watch the object change while I run anything that would manipulate it. Thank you for your help. Best, Rachel Schwartz Graduate Student Researcher UCSD; Scripps Institution of Oceanography [[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] History pruning
5a) save my entire history to a text file 5b) open it up in Emacs 5c) prune any lines that don't have assignment operators Ken Williams Research Scientist The Thomson Reuters Corporation Eagan, MN No one has yet mentioned the obvious. ESS does your 5a 5b 5c with M-x ess-transcript-clean-buffer It works in either the *R* buffer or a *.rt or *.st buffer. It handles multiple-line commands correctly. Make sure the buffer is writable (C-x C-q on the *.rt buffer) M-x ess-transcript-clean-buffer Save the buffer as a *.r file. On automatic content analysis, that is tougher. I would be scared to do your 5d) prune any plotting commands that were superseded by later plots because I don't know what supersede means. I can imagine situations, for example, par(mfrow=c(1,2)) plot(y ~ x) x - x + 1 plot(y ~ x) where I want to keep both plots. You also have to trust that there are no side effects, which I wouldn't want to do, because plot() changes the value of par() parameters. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Eaxct position of specific elements in array
Hi, I am trying to get the positions in array coordinates (needed later) of certain elements in an array but I am not sure how to get them. My array is Q and the condition is dtdV, where dt and dV are arrays of exactly the same dimensions as Q. I know that I can extract the elements of Q by using Q[dtdV] but I need the array position of where this happens. I don't see how to use the which() command since some elements given by that the condition are not unique ( I tried which(Q==Q[dtdV] ,arr.ind=TRUE) but that gives me too many positions plus Warning message: In Q == Q[dt dV] : longer object length is not a multiple of shorter object length) Any help would be really appreciated! -Ralph _ [[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] viewing data in something similar to 'R Data Editor'
See ?View but I don't think it 'auto updates' per your last sentence. Maybe there's a better option? Rachel Schwartz wrote: Hi, I would like to view matrices I am working with in a clean, easy to read, separate window. A friend showed me how to do something like I want with edit(). I can view the matrix in the 'R Data Editor': For a sample matrix: mat=matrix(1:15,ncol=3) mat [,1] [,2] [,3] [1,]16 11 [2,]27 12 [3,]38 13 [4,]49 14 [5,]5 10 15 look=function(x) invisible(edit(x)) look(mat) That opens the 'R Data Editor' with mat loaded. But I am not able to do any other actions in R while this 'R Data Editor' is open. I want to keep this open while I do other work. Is there a way to view my data in something like the 'R Data Editor' that still allows me to do work at the same time? I am looking for something other than str(), head(), and tail() which just allow me a quick peak at the object. I do not want to edit the object in the table, but be able to watch the object change while I run anything that would manipulate it. Thank you for your help. Best, Rachel Schwartz Graduate Student Researcher UCSD; Scripps Institution of Oceanography [[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 get the p-value from lmer on a longitudinal analysis
Hi Ronaldo, ... lmer p-values There are two packages that may help you with this and that might work with the current implementation of lmer(). They are languageR and RLRsim. HTH, Mark. Bugzilla from [EMAIL PROTECTED] wrote: Hi, I have a modelo like this: Yvar - c(0, 0, 0, 0, 1, 0, 0, 0, 1, 2, 1, 1, 2, 3, 6, 6, 3, 3, 4) TIME - 4:22 ID - rep(PlotA,19) m - lmer(Yvar~TIME+(TIME|ID),family=poisson) anova(m) summary(m) How to get the p-value for this case? Thanks Ronaldo -- Just because you're paranoid doesn't mean they AREN'T after you. -- Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Biologia Computacional | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8187 | [EMAIL PROTECTED] | [EMAIL PROTECTED] | http://www.ppgcb.unimontes.br/lbc | ICQ#: 5692561 | LinuxUser#: 205366 -- Favor NÃO ENVIAR arquivos do Word ou Powerpoint Prefira enviar em PDF, Texto, OpenOffice (ODF), HTML, or RTF. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/How-to-get-the-p-value-from-lmer-on-a-longitudinal-analysis-tp18776696p18779630.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] Coefficients of Logistic Regression from bootstrap - how to get them?
Dear all, Your constant talking about what bootstrap is and is not suitable for made me finally verify the findings in the Pawinski et al paper. Here is the procedure and the findings: - First of all I took the raw data (that was posted earlier on this list) and estimated the AUC values using equation coefficients of their recommended model (#10). Though, I was _unable to reproduce_ the r^2, nor the predictive performance values. My results are 0.74 and 44%, respectively, while the reported figures were 0.862 and 82% (41 profiles out of 50). My scatterplot also looks different than the Fig.2 model 10 scatterplot. Weird... - Then, I fit the multiple linear model to the whole dataset (no bootstrap), using the time-points of model #10. I obtained r^2 of 0.74 (agreement), mean prediction error of 7.4% +-28.3% and predictive performance of 44%. The mean reported prediction error (PE) was 7.6% +-26.7% and predictive performance: 56% (page 1502, second column, sentence 2nd from top)! I think the difference in PE may be attributed to numerical differences between SPSS and R, though I can't explain the difference in predictive performance. - Finally, I used Gustaf's bootstrap code to fit linear regression with model #10 time-points on the resampled dataset. The r^2 of the model with median coefficients was identical to that of the model fit to entire data, and the predictive performance was better by only one profile in the range: 46%. As you see, these figures are very far from the numbers reported in the paper. I will be in discussion with the authors on how they obtained these numbers, but I am having doubts if this paper is valid at all... - Later I tested it on my own dataset (paper to appear in August), and found that the MLR model fit on entire data has identical r^2 and predictive performance as the median coefficient model from bootstrap. I must admit, guys, *that I was wrong and you were right: this bootstrap-like procedure does not improve predictions* - at least not to the extent reported in the Pawinski et al paper. I was blindly believing in this paper and I am somewhat embarrassed that I didn't verify these findings, despite that their dataset was available to me since beginning. Maybe it was too much trust in printed word and in authority of a PhD biostatistician who devised the procedure... Nevertheless, I am happy that at least this procedure is harmless, and that I can reproduce the figures reported in /my/ paper. Best regards, and apologies for being such a hard student. I am being converted to orthodox statistics. -- Michal J. Figurski HUP, Pathology Laboratory Medicine Xenobiotics Toxicokinetics Research Laboratory 3400 Spruce St. 7 Maloney Philadelphia, PA 19104 tel. (215) 662-3413 Gustaf Rydevik wrote: On Thu, Jul 31, 2008 at 4:30 PM, Michal Figurski [EMAIL PROTECTED] wrote: Frank and all, The point you were looking for was in a page that was linked from the referenced page - I apologize for confusion. Please take a look at the two last paragraphs here: http://people.revoledu.com/kardi/tutorial/Bootstrap/examples.htm Though, possibly it's my ignorance, maybe it's yours, but you actually missed the important point again. It is that you just don't estimate mean, or CI, or variance on PK profile data! It is as if you were trying to estimate mean, CI and variance of a Toccata__Fugue_in_D_minor.wav file. What for? The point is in the music! Would the mean or CI or variance tell you anything about that? Besides, everybody knows the variance (or variability?) is there and can estimate it without spending time on calculations. What I am trying to do is comparable to compressing a wave into mp3 - to predict the wave using as few data points as possible. I have a bunch of similar waves and I'm trying to find a common equation to predict them all. I am *not* looking for the variance of the mean! I could be wrong (though it seems less and less likely), but you keep talking about the same irrelevant parameters (CI, variance) on and on. Well, yes - we are at a standstill, but not because of Davison Hinkley's book. I can try reading it, though as I stated above, it is not even remotely related to what I am trying to do. I'll skip it then - life is too short. Nevertheless I thank you (all) for relevant criticism on the procedure (in the points where it was relevant). I plan to use this methodology further, and it was good to find out that it withstood your criticism. I will look into the penalized methods, though. -- Michal J. Figurski I take it you mean the sentence: For example, in here, the statistical estimator is the sample mean. Using bootstrap sampling, you can do beyond your statistical estimators. You can now get even the distribution of your estimator and the statistics (such as confidence interval, variance) of your estimator. Again you are misinterpreting text. The phrase about doing beyond your statistical estimators, is
Re: [R] History pruning
On 8/1/08 12:40 PM, Richard M. Heiberger [EMAIL PROTECTED] wrote: 5a) save my entire history to a text file 5b) open it up in Emacs 5c) prune any lines that don't have assignment operators No one has yet mentioned the obvious. ESS does your 5a 5b 5c with M-x ess-transcript-clean-buffer I think you mean just 5a 5b, right? Lines with syntax errors are (I think) removed, but that's it. That part is relatively easy to perform as the first step of a tool, just by running commands through R's parse() and discarding anything that throws an exception. On automatic content analysis, that is tougher. I would be scared to do your 5d) prune any plotting commands that were superseded by later plots True. There are lots of (perhaps relatively common) edge cases that would have to be taken into account. Perhaps a more interactive approach would be better, something like get rid of this plot command and all subsequent modifications to its canvas. Not sure. My basic philosophy on stuff like this is, given the choice of me fumbling around using tools and me fumbling around without using tools, I tend to do better when I have tools. You also have to trust that there are no side effects, which I wouldn't want to do, because plot() changes the value of par() parameters. It does? I wasn't aware of that, could you give an example? -- Ken Williams Research Scientist The Thomson Reuters Corporation Eagan, MN __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] History pruning
I meant 5a 5b 5c. Multiple-line commands are handled correctly. What is is doing is looking for and + prompts. Anything else is removed. Here is a selection from the *R* buffer and the result after cleaning. It includes an example of par(). Rich *R* options(chmhelp = FALSE) options(STERM='iESS', editor='gnuclient.exe') par()$usr [1] 0 1 0 1 plot(1:10) par()$usr [1] 0.64 10.36 0.64 10.36 a - + 3+4 After cleaning options(chmhelp = FALSE) options(STERM='iESS', editor='gnuclient.exe') par()$usr plot(1:10) par()$usr a - 3+4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Reading data in R-metrics
Hi Folks! I used the code below previously with no problems, but now I get: DTB3-read.table(C:\\Program Files\\R\\R-2.7.1\\DTB3.csv,header=TRUE,sep=,) tail(DTB3) DATE VALUE 14233 2008-07-23 1.56 14234 2008-07-24 1.62 14235 2008-07-25 1.71 14236 2008-07-28 1.70 14237 2008-07-29 1.69 14238 2008-07-30 1.67 DTB3-as.timeSeries(DTB3) tail(DTB3) TS.1 2008-07-23 100 2008-07-24 106 2008-07-25 115 2008-07-28 114 2008-07-29 113 2008-07-30 111 What might be causing the values to change when I go from read.table to as.timeSeries? Many thanks. John [[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] Reading data in R-metrics
My suspicion is that there is some value that R does not think is numeric, so the column becomes a factor, and you are seeing the codes for the factor. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Kerpel, John wrote: Hi Folks! I used the code below previously with no problems, but now I get: DTB3-read.table(C:\\Program Files\\R\\R-2.7.1\\DTB3.csv,header=TRUE,sep=,) tail(DTB3) DATE VALUE 14233 2008-07-23 1.56 14234 2008-07-24 1.62 14235 2008-07-25 1.71 14236 2008-07-28 1.70 14237 2008-07-29 1.69 14238 2008-07-30 1.67 DTB3-as.timeSeries(DTB3) tail(DTB3) TS.1 2008-07-23 100 2008-07-24 106 2008-07-25 115 2008-07-28 114 2008-07-29 113 2008-07-30 111 What might be causing the values to change when I go from read.table to as.timeSeries? Many thanks. John [[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] Reading data in R-metrics: FOLLOW UP
Apparently, the Fed changed the way they handled missing values in the interest rates files; now they use a period instead of #N/A like they did in my old files. When I do a global replace and replace the periods with a blank prior to importing in R, I get what I used to get: DTB3-read.table(C:\\Program Files\\R\\R-2.7.1\\DTB3.csv,header=TRUE,sep=,) tail(DTB3) DATE VALUE 14233 2008-07-23 1.56 14234 2008-07-24 1.62 14235 2008-07-25 1.71 14236 2008-07-28 1.70 14237 2008-07-29 1.69 14238 2008-07-30 1.67 DTB3-as.timeSeries(DTB3) tail(DTB3) TS.1 2008-07-23 1.56 2008-07-24 1.62 2008-07-25 1.71 2008-07-28 1.70 2008-07-29 1.69 2008-07-30 1.67 John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kerpel, John Sent: Friday, August 01, 2008 1:13 PM To: r-help@r-project.org Subject: [R] Reading data in R-metrics Hi Folks! I used the code below previously with no problems, but now I get: DTB3-read.table(C:\\Program Files\\R\\R-2.7.1\\DTB3.csv,header=TRUE,sep=,) tail(DTB3) DATE VALUE 14233 2008-07-23 1.56 14234 2008-07-24 1.62 14235 2008-07-25 1.71 14236 2008-07-28 1.70 14237 2008-07-29 1.69 14238 2008-07-30 1.67 DTB3-as.timeSeries(DTB3) tail(DTB3) TS.1 2008-07-23 100 2008-07-24 106 2008-07-25 115 2008-07-28 114 2008-07-29 113 2008-07-30 111 What might be causing the values to change when I go from read.table to as.timeSeries? Many thanks. John [[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] simple help request
# I am sure there is a better way than this a - c(1,6,10,11,3,5,10) group - c(5,5,5,5,9,9,9) my.df - cbind(a,group) a.5 - subset(my.df, group==5) median(a.5[,1]) a.9 - subset(my.df, group==9) median(a.9[,1]) # MASS 4 is a good book On Fri, Aug 1, 2008 at 1:30 PM, Lotta R [EMAIL PROTECTED] wrote: Hi all, I have data that looks like number|grouping I would like to preform stats for each grouping so 1|5 6|5 10|5 11|5 3|9 5|9 10|9 Say I would like to take the median for above, I should be returned 2 lines, one for group #5 and one for group #9 Does this make sense? I am sorry for the basic question, can someone give me the name of a good book as well? Thanks, Lotta [[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. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] match and as.character truncation
I know the following is documented behaviour, in the sense that the help page for as.character mentions that it truncates at about 500 characters... but wouldn't it be better if there was a warning of some sort issued? Or am I misunderstanding what's happening here? str - sample(LETTERS,301, replace=TRUE) search.list - list(str[-301],str) item - list(str)# == search.list[2] match(item, search.list) [1] 1 item - list(str[1:299]) match(item, search.list) [1] 1 item - list(str[1:29]) match(item, search.list) [1] NA version$version.string [1] R version 2.7.1 (2008-06-23) Thanks. -Eric Weese PhD candidate, Economics MIT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 replace NA values in a list
I have a matrix named spec (see below), it is a 6x3 matrix, and each element of spec is a list. For example, spec[1,wavenumber] is a list, and it contains 1876 numeric numbers and NAs. I want to replace the NAs to zero, but don't know how to change it, the difficulty may be all the elements are of the class list, so it is hard to change. Thank you for your help! matrix spec: wavenumber prescan postscan H001 Numeric,1876 Numeric,1876 Numeric,1876 H002 Numeric,1876 Numeric,1876 Numeric,1876 H003 Numeric,1876 Numeric,1876 Numeric,1876 H004 Numeric,1876 Numeric,1876 Numeric,1876 H005 Numeric,1876 Numeric,1876 Numeric,1876 H006 Numeric,1876 Numeric,1876 Numeric,1876 [[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] simple help request
?aggregate Something like this should do it. aggregate(xx[,1], list(xx[,2], median) --- On Fri, 8/1/08, stephen sefick [EMAIL PROTECTED] wrote: From: stephen sefick [EMAIL PROTECTED] Subject: Re: [R] simple help request To: Lotta R [EMAIL PROTECTED] Cc: r-help@r-project.org Received: Friday, August 1, 2008, 2:36 PM # I am sure there is a better way than this a - c(1,6,10,11,3,5,10) group - c(5,5,5,5,9,9,9) my.df - cbind(a,group) a.5 - subset(my.df, group==5) median(a.5[,1]) a.9 - subset(my.df, group==9) median(a.9[,1]) # MASS 4 is a good book On Fri, Aug 1, 2008 at 1:30 PM, Lotta R [EMAIL PROTECTED] wrote: Hi all, I have data that looks like number|grouping I would like to preform stats for each grouping so 1|5 6|5 10|5 11|5 3|9 5|9 10|9 Say I would like to take the median for above, I should be returned 2 lines, one for group #5 and one for group #9 Does this make sense? I am sorry for the basic question, can someone give me the name of a good book as well? Thanks, Lotta [[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. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Confidence intervals with nls()
I have data that looks like O.lengthO.age 176 1 179 1 182 1 ... 493 5 494 5 514 5 606 5 462 6 491 6 537 6 553 6 432 7 522 7 625 8 661 8 687 10 704 10 615 12 (truncated) with a simple VonB growth model from within nls(): plot(O.length~O.age, data=OS) Oto = nls(O.length~Linf*(1-exp(-k*(O.age-t0))), data=OS, start=list(Linf=1000, k=0.1, t0=0.1), trace=TRUE) mod - seq(0, 12) mod=seq(1,12, by=0.001) lines(mod, predict(Oto, list(O.age = mod))) I'm trying to put 95% confidence intervals on the nls() regression with code that I found in the R-help archive: se.fit - sqrt(apply(attr(predict(Oto,list(O.age=mod)),gradient, col=blue),1, function(x) sum(vcov(Oto)*outer(x,x matplot(mod, predict(Oto,list(O.age=mod))+ outer(se.fit,qnorm(c(.5, .025,.975))),type=l) Unfortunately, I get the error: Error in apply(attr(predict(Oto, list(O.age = mod)), gradient, col = blue), : dim(X) must have a positive length after the se.fit statement is submitted. My lack of R programming knowledge prohibits me from debugging this on my own. My biggest problem is not knowing what, exactly, is going on in the se.fit or matplot() statements. Any ideas as to how I can get this to work? Thanks, SR Steven H. Ranney Graduate Research Assistant (Ph.D) USGS Montana Cooperative Fishery Research Unit Montana State University PO Box 173460 Bozeman, MT 59717-3460 phone: (406) 994-6643 fax: (406) 994-7479 [[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] simple help request
Dear Lotta, Try my.df - data.frame(a - c(1,6,10,11,3,5,10), group - c(5,5,5,5,9,9,9)) tapply(my.df$a,my.df$group,median) 5 9 8 5 See ?tapply and/or ?aggregate for more information. HTH, Jorge On Fri, Aug 1, 2008 at 1:30 PM, Lotta R [EMAIL PROTECTED] wrote: Hi all, I have data that looks like number|grouping I would like to preform stats for each grouping so 1|5 6|5 10|5 11|5 3|9 5|9 10|9 Say I would like to take the median for above, I should be returned 2 lines, one for group #5 and one for group #9 Does this make sense? I am sorry for the basic question, can someone give me the name of a good book as well? Thanks, Lotta [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to replace NA values in a list
Hi, to be honest, I never created a matrix of lists before, but hopefully this code will help you? set.seed(12345) my.pool - c(NA, 0:10) n - 25 alist - list(sample(x=my.pool, size=n, replace=TRUE)) alist mymatrix - matrix(rep(alist, 6*3), nrow=6) mymatrix2 - lapply(X=mymatrix, FUN=function(x) ifelse(is.na(x),0,x)) mymatrix2 Best, Roland Shang Liu wrote: I have a matrix named spec (see below), it is a 6x3 matrix, and each element of spec is a list. For example, spec[1,wavenumber] is a list, and it contains 1876 numeric numbers and NAs. I want to replace the NAs to zero, but don't know how to change it, the difficulty may be all the elements are of the class list, so it is hard to change. Thank you for your help! matrix spec: wavenumber prescan postscan H001 Numeric,1876 Numeric,1876 Numeric,1876 H002 Numeric,1876 Numeric,1876 Numeric,1876 H003 Numeric,1876 Numeric,1876 Numeric,1876 H004 Numeric,1876 Numeric,1876 Numeric,1876 H005 Numeric,1876 Numeric,1876 Numeric,1876 H006 Numeric,1876 Numeric,1876 Numeric,1876 [[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] Distance measure for large sparse matrix
Hello, I am trying to compute a distance measure for the rows (var1) in a sparse matrix: require(Matrix) dfx = xtabs(~ var1 + var2, data = df, sparse = T, drop.unused.levels = T ) dm = dist(dfx) on my data frame. Note that I am using the xtabs function from the Matrix package, not R base. The thing is that length(unique(df$var1)) = 15000 and length(unique(df$var1)) = 1600, so the matrix is huge. Thus, when I run dist(dfx), I get the error message: Error: cannot allocate vector of size 885.1 Mb. Anyone know how I might resolve the issue? Thanks, Solomon [[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] viewing data in something similar to 'R Data Editor'
Thanks Erik, almost worked! I am a mac user and for some reason View worked perfectly for my PC using friend, but doesn't for me. When I tried: mat=matrix(1:10,ncol=2) mat [,1] [,2] [1,]16 [2,]27 [3,]38 [4,]49 [5,]5 10 View(mat) I get no error message, but nothing happens (besides spinning ball of death) and I have to force quit R. I tried a couple different variations but still no success with using View. Suggestions? On Fri, Aug 1, 2008 at 10:52 AM, Erik Iverson [EMAIL PROTECTED]wrote: See ?View but I don't think it 'auto updates' per your last sentence. Maybe there's a better option? Rachel Schwartz wrote: Hi, I would like to view matrices I am working with in a clean, easy to read, separate window. A friend showed me how to do something like I want with edit(). I can view the matrix in the 'R Data Editor': For a sample matrix: mat=matrix(1:15,ncol=3) mat [,1] [,2] [,3] [1,]16 11 [2,]27 12 [3,]38 13 [4,]49 14 [5,]5 10 15 look=function(x) invisible(edit(x)) look(mat) That opens the 'R Data Editor' with mat loaded. But I am not able to do any other actions in R while this 'R Data Editor' is open. I want to keep this open while I do other work. Is there a way to view my data in something like the 'R Data Editor' that still allows me to do work at the same time? I am looking for something other than str(), head(), and tail() which just allow me a quick peak at the object. I do not want to edit the object in the table, but be able to watch the object change while I run anything that would manipulate it. Thank you for your help. Best, Rachel Schwartz Graduate Student Researcher UCSD; Scripps Institution of Oceanography [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R CMD INSTALL error, R-2.7.1
On 8/1/2008 12:39 PM, Richard Chandler wrote: Hi, I am getting the following error when using R CMD INSTALL ever since I upgraded to R-2.7.1: hhc: not found CHM compile failed: HTML Help Workshop not intalled? As indicated, the package is installed but without CHM help files. I have downloaded the latest version of Rtools and I have tried uninstalling and reinstalling HTML Help Workshop. I have also tried rebuilding the package several times. I was able to build and install the package without problems with R-2.7.0. I believe that's a warning rather than an error, but what it indicates is that your hhc help compiler is not on the current PATH. If you just type hhc at the same command line where you were running R CMD INSTALL, you should see Usage: hhc filename where filename = an HTML Help project file Example: hhc myfile.hhp but I'm guessing you'll see hhc: not found To fix this, edit the PATH, and make sure the directory holding hhc.exe is on it. Duncan Murdoch Any ideas? Thanks. Richard platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 7.1 year 2008 month 06 day23 svn rev45970 language R version.string R version 2.7.1 (2008-06-23) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] viewing data in something similar to 'R Data Editor'
Rachel Schwartz wrote: Thanks Erik, almost worked! I am a mac user and for some reason View worked perfectly for my PC using friend, but doesn't for me. When I tried: mat=matrix(1:10,ncol=2) mat [,1] [,2] [1,]16 [2,]27 [3,]38 [4,]49 [5,]5 10 View(mat) I get no error message, but nothing happens (besides spinning ball of death) and I have to force quit R. I tried a couple different variations but still no success with using View. Suggestions? Not from me, no Mac here. Maybe someone else? Or else there is a Mac specific list, R-SIG-Mac, google for it. On Fri, Aug 1, 2008 at 10:52 AM, Erik Iverson [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: See ?View but I don't think it 'auto updates' per your last sentence. Maybe there's a better option? Rachel Schwartz wrote: Hi, I would like to view matrices I am working with in a clean, easy to read, separate window. A friend showed me how to do something like I want with edit(). I can view the matrix in the 'R Data Editor': For a sample matrix: mat=matrix(1:15,ncol=3) mat [,1] [,2] [,3] [1,]16 11 [2,]27 12 [3,]38 13 [4,]49 14 [5,]5 10 15 look=function(x) invisible(edit(x)) look(mat) That opens the 'R Data Editor' with mat loaded. But I am not able to do any other actions in R while this 'R Data Editor' is open. I want to keep this open while I do other work. Is there a way to view my data in something like the 'R Data Editor' that still allows me to do work at the same time? I am looking for something other than str(), head(), and tail() which just allow me a quick peak at the object. I do not want to edit the object in the table, but be able to watch the object change while I run anything that would manipulate it. Thank you for your help. Best, Rachel Schwartz Graduate Student Researcher UCSD; Scripps Institution of Oceanography [[alternative HTML version deleted]] __ R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Memory Problems with a Simple Bootstrap
It seems like the objects are reasonable size and the memory size also seems reasonable. That is what I usually go by to see if there are large objects in my memory. If it was showing that R had 1.2GB of memory allocated to it, I wonder if there might be a memory leak somewhere. On Fri, Aug 1, 2008 at 1:36 PM, Tom La Bone [EMAIL PROTECTED] wrote: Same problem. The Windows Task Manager indicated that Rgui.exe was using 1,249,722 K of memory when the error occurred. This is R 2.7.1 by the way. library(boot) setwd(C:/Documents and Settings/Tom/Desktop) data.in - read.csv(inputdata.csv,header=T,as.is=T) per95 - function( annual.data, b.index) { + sample.data - annual.data[b.index,] + return(quantile(sample.data$Result,probs=c(0.95))) } m - 1 for (i in 1:39) { + annual.data - data.in[data.in$Year == (i+1949),] + B - boot(data=annual.data,statistic=per95,R=m) + gc() + print(i) + print(object.size(B)) + print(memory.size()) + } [1] 1 [1] 90352 [1] 12.35335 [1] 2 [1] 111032 [1] 12.39024 [1] 3 [1] 155544 [1] 12.48451 [1] 4 [1] 159064 [1] 11.10526 [1] 5 [1] 243456 [1] 11.23505 [1] 6 [1] 280592 [1] 12.74642 [1] 7 [1] 302416 [1] 11.33087 [1] 8 [1] 319752 [1] 12.84377 [1] 9 [1] 351448 [1] 11.42264 Error: cannot allocate vector of size 284.4 Mb jholtman wrote: Use gc() in the loop to possibly free up any fragmented memory. You might also print out the size of B (object.size(B)) since that appears to be the only variable in your loop that might be growing. On Fri, Aug 1, 2008 at 12:09 PM, Tom La Bone [EMAIL PROTECTED] wrote: I have a data file called inputdata.csv that looks something like this ID YearResult Month Date 1 71741954 103 540301 2 7174195443 540322 3 20924 1967 4 2 670223 4 20924 1967 -75 670518 5 20924 1967 -37 670706 ... 67209 ... i.e., it goes on for 67209 rows (~2 Mb file). When I run the following bootstrap session I get the indicated error: library(boot) setwd(C:/Documents and Settings/Tom/Desktop) data.in - read.csv(inputdata.csv,header=T,as.is=T) per95 - function( annual.data, b.index) { + sample.data - annual.data[b.index,] + return(quantile(sample.data$Result,probs=c(0.95))) } m - 1 for (i in 1:39) { + annual.data - data.in[data.in$Year == (i+1949),] + B - boot(data=annual.data,statistic=per95,R=m) + print(i) + print(memory.size()) + } [1] 1 [1] 20.26163 [1] 2 [1] 61.6352 [1] 3 [1] 134.4187 [1] 4 [1] 149.4704 [1] 5 [1] 290.3090 [1] 6 [1] 376.7017 [1] 7 [1] 435.7683 [1] 8 [1] 463.7404 [1] 9 [1] 497.7946 Error: cannot allocate vector of size 568.8 Mb I am running this on a Windows XP Pro machine with 4 Gb of memory. The same problem occurs when the code is executed on the same box running Ubuntu 8.04. Does anyone see any obvious reason why this should run out of memory? I would be happy to email the data file to anyone who cares to try it on their computer. Tom -- View this message in context: http://www.nabble.com/Memory-Problems-with-a-Simple-Bootstrap-tp18777897p18777897.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Memory-Problems-with-a-Simple-Bootstrap-tp18777897p18779433.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] multinomRob: Error in eigen [..] infinite or missing values in 'x'
I'm interested in analysing some of my data using multinomial regression. I have been using nnet's multinom so far. However, I found that some of the data shows overdispersion and hence want to change to robust multinomial regression, package: multinomRob I have succesfully implemented Agresti's (2002) alligator example (chapter 7, p 268) using the option MLEonly=TRUE as there are too few observations to estimate overdispersed MNL (commented code provided below). However, when I tried to run my data, I get the error mesagge (commented code provided below) 'Error in eigen(hess2, symmetric = TRUE, only.values = TRUE) : infinite or missing values in 'x' ' Help on how to overcome this isuue will be most appreciated Reference: Agresti, A. 2002. Categorical Data Analysis. John Wiley Sons Operating system: Windows XP Professional Version 2002 Service Pack 2 R version 2.7.0 (2008-04-22) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 Package: multinomRob Version: 1.8-2 Packaged: Fri Feb 9 02:14:07 2007; sekhon Built: R 2.7.1; i386-pc-mingw32; 2008-06-15 22:52:42; windows Alejandro Buren Psychology Department Memorial University of Newfoundland # -- Diet Analysis BEGINS # I am modeling prey choice of a marine predator # the prey choice depends upon #A. length of the predator (categorical[1=small, 2=medium or 3=large]) #B. year (continuous), #C. depth (shallow or deep) and #D. position (north or south) # I am considering a suite of 13 prey, prey #3 is the most common and therefore used as baseline # the data is provided in a dataframe with 4 columns containing the values of the explanatory variables # and 13 columns that contain the frequency of each prey (one column per level of the dependent variable) # The data frame is provided after the code to run the model as it is quite large # and would interrupt the flow of the reading # I try running multinomRob but get the error mesagge: # 'Error in eigen(hess2, symmetric = TRUE, only.values = TRUE) : # infinite or missing values in 'x' ' library(multinomRob) mlRobDiet - multinomRob(list(p3 ~0, p1 ~ length+depth+position+year, p2 ~ length+depth+position+year, p4 ~ length+depth+position+year, p5 ~ length+depth+position+year, p6 ~ length+depth+position+year, p7 ~ length+depth+position+year, p8 ~ length+depth+position+year, p9 ~ length+depth+position+year, p10 ~ length+depth+position+year, p11 ~ length+depth+position+year, p12 ~ length+depth+position+year, p13 ~ length+depth+position+year), data=diet) `diet` - structure(list(year = c(1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1986L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L, 1987L,