Re: [R] Title for y-axis on right side
On 12/17/2010 10:41 PM, phils_mu...@arcor.de wrote: Hi, I want to have a title for the y-axis on the right side of the plot. I know how to do it on the left side: title(ylab=Title for y-axis) But how can I have the title on the right side? Hi Phil, You probably want to add some margin on the right before you do the plot: par(mar=c(5,4,4,4)) plot(...) then: mtext(Right side,side=4,line=2) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] bugs in R windows versie 12 ?
Dear R-users, When you perform run line or selection / Ctrl + R in a script window then the cursor of the script window does not go to the next line but at a place further downwards. R windows version 11 does the correct job (= goes to the next line) but version 12 does not. Is this correct ? Sincerely Elprama __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] testing with if: what I am doing wrong?
I am running this small program: x - factor(c(A,B,A,C)) y - c(1,2,3,4) w -data.frame(x,y) if (w$x==A){ w$z=1 } w And I obtain: x y z 1 A 1 1 2 B 2 1 3 A 3 1 4 C 4 1 And not x y z 1 A 1 1 2 B 2 NA 3 A 3 1 4 C 4 NA Like I should obtain. What am I doing wrong? Please notice that I get a warning approximately saying - translated from italian: In if (w$x == A) { : the condition length 1 and only the first element will be used Thanks, Luca __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] bugs in R windows versie 12 ?
On 19/12/2010 3:00 AM, elprama wrote: Dear R-users, When you perform run line or selection / Ctrl + R in a script window then the cursor of the script window does not go to the next line but at a place further downwards. R windows version 11 does the correct job (= goes to the next line) but version 12 does not. Is this correct ? That's distracting, but it is only the displayed cursor that is wrong: logically it is in the right place, so when you move it (e.g. by hitting an arrow key or entering text) it will appear in the right place. This has been fixed in R-patched, but unfortunately the first report came too late to make 2.12.0 or 2.12.1. Please test our pre-release versions! Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] testing with if: what I am doing wrong?
On 18/12/2010 8:34 AM, Luca Meyer wrote: I am running this small program: x- factor(c(A,B,A,C)) y- c(1,2,3,4) w-data.frame(x,y) if (w$x==A){ w$z=1 } w And I obtain: x y z 1 A 1 1 2 B 2 1 3 A 3 1 4 C 4 1 And not x y z 1 A 1 1 2 B 2 NA 3 A 3 1 4 C 4 NA Like I should obtain. What am I doing wrong? You're using if, which only looks at the first element (as the message said). See ?ifelse for a conditional that applies to each vector entry. Duncan Murdoch Please notice that I get a warning approximately saying - translated from italian: In if (w$x == A) { : the condition length 1 and only the first element will be used Thanks, Luca __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Alternative to extended recode sintax? Bug?
Something goes wrong with the week function of the lubridate package: x= as.POSIXct(factor(c(2010-12-15 17:28:27, + 2010-12-15 17:32:34, + 2010-12-15 18:48:39, + 2010-12-15 19:25:00, + 2010-12-16 08:00:00, + 2010-12-16 08:25:49, + 2010-12-16 09:00:00))) require(lubridate) weekdays(x) [1] Mercoledì Mercoledì Mercoledì Mercoledì Giovedì Giovedì Giovedì week(x) [1] 50 50 50 50 51 51 51 Please notice Mercoledì=Wednesday and Giovedì=Thursday, why would the beginning of the week start on Thursday? Also please beware that on previous weeks this does not occur, that is all weeks till 49 will all begin on Mondays and end on Sundays as required. Thanks, Luca Il giorno 18/dic/2010, alle ore 14.39, David Winsemius ha scritto: On Dec 17, 2010, at 11:08 AM, Luca Meyer wrote: x= factor(c(2009-03-30 00:00:00, 2009-04-06 00:00:00, 2009-04-13 00:00:00, 2009-04-20 00:00:00, 2009-04-27 00:00:00, 2009-05-04 00:00:00 ,2009-05-11 00:00:00, 2009-05-18 00:00:00)) require(lubridate) xd=as.POSIXct(x) week(xd) # [1] 13 14 15 16 17 18 19 20 year(xd) # [1] 2009 2009 2009 2009 2009 2009 2009 2009 paste(year(xd), W,week(xd), sep=) #[1] 2009 W13 2009 W14 2009 W15 2009 W16 2009 W17 2009 W18 2009 W19 2009 W20 David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Random selection from a subsample
Dear Mailing List I have a data set (data4) consisting of a number of factors and a response variable. I wish to randomly sample from a combination of two of those factors (GIS_station and Distance_code2) and return a new dataframe containing the original data structure (i.e. all the columns) but only containing the randomly selected rows. The number of rows in each combination of GIS_station and Distance_code2 vary (widely) and some combinations are absent. This is getting there:: with (data4,{ sub_sample10=by(data4,list(GIS_station,Distance_code2), function(x) {sample(1:nrow(x),10,replace=T)}) }) but just generates two random numbers from the range 1:nrow(x). It doesn't return the selected rows, which is what I want. I'm sure I could this could be done in an elegant manner, using a subscript e.g. sub_sample10 = data4 [sample (1:nrow (data4), size=10), ] only somehow combining it with the 'by' statement (e.g. by (data4, list (GIS_station, Distance_code2)...)) but I cannot get this to work. Any guidance on this much appreciated. Thankyou. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Ifelse stability problems?
I am just wondering why what I am showing below might occur. First I have an x data.frame: str(x) 'data.frame': 281 obs. of 2 variables: $ x1 : Factor w/ 5 levels A (50-67%),B (10-20%),..: 1 2 5 1 2 5 1 2 5 1 ... $ x2 : num 33.8 60.2 6 76.8 13.8 9.4 76.9 8 15.1 78.1 ... I need to check that for each level of factor x1 the values of x2 are (approximately) contained within a given range. In such a case I will print ok a third variable, otherwise I will write err ifelse (x$x1 == A (50-67%), x$check-ifelse(x$x268x$x249,ok,), x$check-x$check ) ifelse (x$x1 == B (10-20%), x$check-ifelse(x$x221x$x29,ok,), x$check-x$check ) ifelse (x$x1 == C (5-15%), x$check-ifelse(x$x216x$x24,ok,), x$check-x$check ) ifelse (x$x1 == D (1-5%), x$check-ifelse(x$x26x$x20,ok,), x$check-x$check ) ifelse (x$x1 == E (10-20%), x$check-ifelse(x$x221x$x29,ok,), x$check-x$check ) Now, what I obtain is not always correct - see for instance lines 111, 125, 257, 264, 272, etc in the following output: x x1 x2 check 1 A (50-67%) 33.8 2 B (10-20%) 60.2 3 E (10-20%) 6.0 4 A (50-67%) 76.8 5 B (10-20%) 13.8ok 6 E (10-20%) 9.4ok 7 A (50-67%) 76.9 8 B (10-20%) 8.0 9 E (10-20%) 15.1ok 10 A (50-67%) 78.1 11 E (10-20%) 21.9 12 A (50-67%) 96.1 13 B (10-20%) 0.6 14 E (10-20%) 3.4 15 A (50-67%) 88.4 16 B (10-20%) 8.8 17 E (10-20%) 2.8 18 A (50-67%) 93.8 19 B (10-20%) 0.0 20 E (10-20%) 6.1 21 A (50-67%) 81.3 22 B (10-20%) 5.1 23 E (10-20%) 13.6ok 24 A (50-67%) 65.9 25 B (10-20%) 14.9ok 26 E (10-20%) 19.1ok 27 A (50-67%) 81.2 28 B (10-20%) 10.2ok 29 E (10-20%) 8.6 30 A (50-67%) 70.2 31 B (10-20%) 20.7ok 32 E (10-20%) 9.2ok 33 A (50-67%) 61.4 34 B (10-20%) 7.3 35 E (10-20%) 31.4 36 A (50-67%) 77.7 37 B (10-20%) 7.9 38 E (10-20%) 14.4ok 39 A (50-67%) 95.0 40 B (10-20%) 0.2 41 E (10-20%) 4.8 42 A (50-67%) 83.3 43 B (10-20%) 3.8 44 E (10-20%) 12.9ok 45 A (50-67%) 82.2 46 B (10-20%) 6.1 47 E (10-20%) 11.7ok 48 A (50-67%) 91.8 49 B (10-20%) 0.6 50 E (10-20%) 7.5 51 A (50-67%) 83.8 52 B (10-20%) 4.0 53 E (10-20%) 12.2ok 54 A (50-67%) 94.6 55 B (10-20%) 0.4 56 E (10-20%) 5.1 57 A (50-67%) 81.4 58 B (10-20%) 6.1 59 E (10-20%) 12.5ok 60 A (50-67%) 96.4 61 E (10-20%) 3.6 62 A (50-67%) 92.0 63 B (10-20%) 0.5 64 E (10-20%) 7.5 65 A (50-67%) 81.8 66 B (10-20%) 2.5 67 E (10-20%) 15.7ok 68 A (50-67%) 38.3 69 B (10-20%) 5.9 70 C (5-15%) 41.5 71D (1-5%) 1.9 72 E (10-20%) 12.4ok 73 A (50-67%) 96.0 74 E (10-20%) 4.0 75 A (50-67%) 75.9 76 B (10-20%) 2.3 77 E (10-20%) 21.7 78 A (50-67%) 94.9 79 E (10-20%) 5.1 80 A (50-67%) 96.1 81 E (10-20%) 3.9 82 A (50-67%) 72.6 83 B (10-20%) 9.4ok 84 C (5-15%) 8.0 85D (1-5%) 2.4 86 E (10-20%) 7.5 87 A (50-67%) 48.9 88 B (10-20%) 2.4 89 C (5-15%) 25.0 90D (1-5%) 10.3ok 91 E (10-20%) 13.3ok 92 A (50-67%) 87.8 93 B (10-20%) 4.1 94 C (5-15%) 1.7 95D (1-5%) 0.9 96 E (10-20%) 5.6 97 A (50-67%) 96.9 98 E (10-20%) 3.1 99 A (50-67%) 72.2 100 B (10-20%) 13.3ok 101 C (5-15%) 5.7 102 D (1-5%) 0.3 103 E (10-20%) 8.5 104 A (50-67%) 64.1 105 B (10-20%) 9.0 106 C (5-15%) 9.5ok 107 D (1-5%) 1.9 108 E (10-20%) 15.4ok 109 A (50-67%) 45.2 110 B (10-20%) 15.3ok 111 C (5-15%) 18.3ok 112 D (1-5%) 0.3 113 E (10-20%) 20.9ok 114 A (50-67%) 61.5 115 C (5-15%) 22.9 116 D (1-5%) 10.2ok 117 E (10-20%) 5.4 118 A (50-67%) 69.0 119 B (10-20%) 6.1 120 C (5-15%) 16.9ok 121 D (1-5%) 1.0 122 E (10-20%) 6.9 123 A (50-67%) 61.2 124 B (10-20%) 10.3ok 125 C (5-15%) 5.5 126 D (1-5%) 6.9 127 E (10-20%) 16.2ok 128 A (50-67%) 61.1 129 B (10-20%) 11.5ok 130 C (5-15%) 7.0 131 D (1-5%) 3.9 132 E (10-20%) 16.5ok 133 A (50-67%) 45.9 134 B (10-20%) 24.9 135 C (5-15%) 0.2 136 D (1-5%) 1.6 137 E (10-20%) 27.4 138 A (50-67%) 61.5 139 B (10-20%) 8.7 140 C (5-15%) 22.5 141 D (1-5%) 0.1 142 E (10-20%) 7.2 143 A (50-67%) 64.1 144 B (10-20%) 0.9 145 C (5-15%) 14.4ok 146 D (1-5%) 11.2ok
Re: [R] Alternative to extended recode sintax? Bug?
On Dec 19, 2010, at 5:11 AM, Luca Meyer wrote: Something goes wrong with the week function of the lubridate package: x= as.POSIXct(factor(c(2010-12-15 17:28:27, + 2010-12-15 17:32:34, + 2010-12-15 18:48:39, + 2010-12-15 19:25:00, + 2010-12-16 08:00:00, + 2010-12-16 08:25:49, + 2010-12-16 09:00:00))) require(lubridate) weekdays(x) [1] Mercoledì Mercoledì Mercoledì Mercoledì Giovedì Giovedì Giovedì week(x) [1] 50 50 50 50 51 51 51 But 2010-12-15 is a Wednesday and 2010-12-16 is a Thursday. -- David. Please notice Mercoledì=Wednesday and Giovedì=Thursday, why would the beginning of the week start on Thursday? Also please beware that on previous weeks this does not occur, that is all weeks till 49 will all begin on Mondays and end on Sundays as required. Thanks, Luca Il giorno 18/dic/2010, alle ore 14.39, David Winsemius ha scritto: On Dec 17, 2010, at 11:08 AM, Luca Meyer wrote: x= factor(c(2009-03-30 00:00:00, 2009-04-06 00:00:00, 2009-04-13 00:00:00, 2009-04-20 00:00:00, 2009-04-27 00:00:00, 2009-05-04 00:00:00 ,2009-05-11 00:00:00, 2009-05-18 00:00:00)) require(lubridate) xd=as.POSIXct(x) week(xd) # [1] 13 14 15 16 17 18 19 20 year(xd) # [1] 2009 2009 2009 2009 2009 2009 2009 2009 paste(year(xd), W,week(xd), sep=) #[1] 2009 W13 2009 W14 2009 W15 2009 W16 2009 W17 2009 W18 2009 W19 2009 W20 David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Random selection from a subsample
On Dec 19, 2010, at 5:31 AM, Tom Wilding wrote: Dear Mailing List I have a data set (data4) consisting of a number of factors and a response variable. I wish to randomly sample from a combination of two of those factors (GIS_station and Distance_code2) and return a new dataframe containing the original data structure (i.e. all the columns) but only containing the randomly selected rows. The number of rows in each combination of GIS_station and Distance_code2 vary (widely) and some combinations are absent. This is getting there:: with (data4,{ sub_sample10=by(data4,list(GIS_station,Distance_code2), function(x) {sample(1:nrow(x),10,replace=T)}) }) but just generates two random numbers from the range 1:nrow(x). Only 2? Your argument to sample is 10. It doesn't return the selected rows, which is what I want. And those row numbers would not refer to the order in the original sample either but would be referring within the . You have not yet done a very good job of specifying what sampling strategy is needed. At the moment you seem to be working toward a strategy that would potentially be very uneven in terms of the probabilities that members of different combinations would get into the sample, since the number being chosen is fixed and the number to be chosen from varies widely. Is that really what you want? I'm sure I could this could be done in an elegant manner, using a subscript e.g. sub_sample10 = data4 [sample (1:nrow (data4), size=10), ] (You also have not provided a reproducible data example. Next time bring data.) Theis works to sample 3 from each of the the distinct categories in the warpbreaks data object: by(warpbreaks, list(warpbreaks$wool, warpbreaks$tension), FUN=function(x) x[sample(1:nrow(x), 3), ] ) #returns a list with 6 members each of which has a three row dataframe And this would stick them back together in on dataframe: do.call(rbind, by(warpbreaks, list(warpbreaks$wool, warpbreaks $tension), FUN=function(x) x[sample(1:nrow(x), 3), ] ) ) -- David. only somehow combining it with the 'by' statement (e.g. by (data4, list (GIS_station, Distance_code2)...)) but I cannot get this to work. Any guidance on this much appreciated. Thankyou. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Resource for learning C/R interface
Date: Sun, 19 Dec 2010 01:34:28 -0500 From: mailinglist.honey...@gmail.com To: cjul...@bu.edu CC: r-help@r-project.org Subject: Re: [R] Resource for learning C/R interface Hi, On Sat, Dec 18, 2010 at 11:29 PM, Julian TszKin Chan wrote: Hi all, Is there any tutorial for learning C/R interface ? Thanks You'll find some info here: http://cran.r-project.org/doc/manuals/R-exts.pdf Thanks, I may try this when I get time. It seems R handles a lot of this automtically but how can you select a compiler? That is, let's say I want to write in c++ and then extern-C the R interface and use a highly optimizing compiler like Intel ( which I think they even make available for free in some cases). Also, take a good look at the Rcpp package: http://dirk.eddelbuettel.com/code/rcpp.html There's *a lot* of things to learn there, so ... happy reading. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Replacing the for loop for time series buid-up
Hi, is there a function that replaces the following code? n=200 boot.x[1]=odhad+boot.res[1] #(boot.x[0]=1) for (j in 1:(n-1)) { boot.x[j+1]=odhad*boot.x[j]+boot.res[j+1] } This is nested in two other loops, and I am looking for some way to improve code performance I tried sapply and cumprod but no success. Thanks Jan -- View this message in context: http://r.789695.n4.nabble.com/Replacing-the-for-loop-for-time-series-buid-up-tp3094421p3094421.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] Ifelse stability problems?
On 2010-12-19 03:50, Luca Meyer wrote: I am just wondering why what I am showing below might occur. First I have an x data.frame: str(x) 'data.frame': 281 obs. of 2 variables: $ x1 : Factor w/ 5 levels A (50-67%),B (10-20%),..: 1 2 5 1 2 5 1 2 5 1 ... $ x2 : num 33.8 60.2 6 76.8 13.8 9.4 76.9 8 15.1 78.1 ... I need to check that for each level of factor x1 the values of x2 are (approximately) contained within a given range. In such a case I will print ok a third variable, otherwise I will write err ifelse (x$x1 == A (50-67%), x$check-ifelse(x$x268x$x249,ok,), x$check-x$check ) [...snip...] Can anyone explain why this might occur? You have a bit of a logic problem in your ifelse; (look at your x$check after each of your ifelse()s); try it this way: x$check - NA x$check - ifelse (x$x1 == A (50-67%), ifelse(x$x268x$x249,ok,), x$check ) etc. Peter Ehlers Thanks, Luca Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sum with times
Hi, I have this vector: A - c(00:00:36,00:02:18) A [1] 00:00:36 00:02:18 I use as.difftime to convert this to time vector based B - as.difftime(A) B Time differences in secs [1] 36 138 attr(,tzone) [1] Now i try to make a sum sum(B) Time difference of 174 secs The sum is ok, but how to convert this result again do H:M:S format to get the result 00:02:54, that is 2 minutes and 54 seconds. work with times is aways difficult, I try the units parameter in as.difftime but dont work. Thanks Ronaldo -- 8ª lei - Colete seus dados hoje como se você soubesse que seu equipamento vai quebrar amanhã. --Herman, I. P. 2007. Following the law. NATURE, Vol 445, p. 228. Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8192 | ronaldo.r...@unimontes.br | http://www.ppgcb.unimontes.br/lecc | LinuxUser#: 205366 [[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] sum with times
Hi, Forget, the chron package work with this Thanks Ronaldo -- 8ª lei - Colete seus dados hoje como se você soubesse que seu equipamento vai quebrar amanhã. --Herman, I. P. 2007. Following the law. NATURE, Vol 445, p. 228. Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8192 |ronaldo.r...@unimontes.br |http://www.ppgcb.unimontes.br/lecc | LinuxUser#: 205366 [[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] Replacing the for loop for time series buid-up
On Dec 19, 2010, at 8:08 AM, Torch wrote: Hi, is there a function that replaces the following code? n=200 boot.x[1]=odhad+boot.res[1] #(boot.x[0]=1) No. there is no boot.x[0] ... in R anyway. for (j in 1:(n-1)) { boot.x[j+1]=odhad*boot.x[j]+boot.res[j+1] } This is nested in two other loops, and I am looking for some way to improve code performance I tried sapply and cumprod but no success. Probably because you didn't use paper and pencil to figure out what x_n was going to be. You end up with a series that looks like: boot.x[n] = odhad^n + boot.res[1]*odhad^(n-1) +boot.res[2]*odhad^(n-2) + ... boot.res[n] I'm thinking you should play around with n=20 instead of 200 because I don't know what odhad might be and I'd be afraid of overflow with the ^200 operation. Here's a failed attempt: geo_od - odhad^(19:0) geo_res - boot.res*geo_od boot.x - odhad^(1:20) + cumsum(geo_res) But that's not correct ... except for the fact that it does get the last term correct. Thanks Jan -- View this message in context: http://r.789695.n4.nabble.com/Replacing-the-for-loop-for-time-series-buid-up-tp3094421p3094421.html Sent from the R help mailing list archive at Nabble.com. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] barplot: width of label
Hello, I try to make barplots with rather wide labels. A simplified example of this: x - c(12, 33, 56, 67, 15, 66) names(x) - c('Richard with a long surname','Minnie with a long name,'Albert','Helen','Joe','Kingston') barplot(x, las = 2) Now the label 'Richard with a long surname' is too long to fit beneath the bars. A simple solution would be enlarge the space for the labels by positioning the bar region higher. But I cannot find how to do this. Please Help! Frans Marcelissen, DigiPsy fransiepansiekever...@digipsy.nl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] barplot: width of label
On 2010-12-19 07:13, fransiepansiekevertje wrote: Hello, I try to make barplots with rather wide labels. A simplified example of this: x- c(12, 33, 56, 67, 15, 66) names(x)- c('Richard with a long surname','Minnie with a long name,'Albert','Helen','Joe','Kingston') barplot(x, las = 2) Now the label 'Richard with a long surname' is too long to fit beneath the bars. A simple solution would be enlarge the space for the labels by positioning the bar region higher. But I cannot find how to do this. Please Help! Try par(mar = c(12,4,4,2)) before calling barplot(). But a better solution (still requiring a resetting of the default margins) would be to plot horizontally. Admittedly, this would provide less neck exercise for the reader. Peter Ehlers Frans Marcelissen, DigiPsy fransiepansiekever...@digipsy.nl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] barplot: width of label
On Dec 19, 2010, at 10:55 AM, Peter Ehlers wrote: On 2010-12-19 07:13, fransiepansiekevertje wrote: Hello, I try to make barplots with rather wide labels. A simplified example of this: x- c(12, 33, 56, 67, 15, 66) names(x)- c('Richard with a long surname','Minnie with a long name,'Albert','Helen','Joe','Kingston') ^ barplot(x, las = 2) Anyone pasting this code should insert the missing single-quote. Now the label 'Richard with a long surname' is too long to fit beneath the bars. A simple solution would be enlarge the space for the labels by positioning the bar region higher. But I cannot find how to do this. Please Help! Try par(mar = c(12,4,4,2)) before calling barplot(). But a better solution (still requiring a resetting of the default margins) would be to plot horizontally. Admittedly, this would provide less neck exercise for the reader. Another option is to insert \n's. x - c(12, 33, 56, 67, 15, 66) names(x) - c('Richard\n with a\n long \nsurname','Minnie\nwith a \nlong \n name','Albert','Helen','Joe','Kingston') barplot(x) And yet another option, somewhat more complex, would be to construct an x- axis with slanting labels. (Several worked examples posting in the archives.) -- David Peter Ehlers Frans Marcelissen, DigiPsy fransiepansiekever...@digipsy.nl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Layout of mulitpage conditioned lattice plots
Dear latticists, I would like to spread a lattice conditioned plot over multiple pages, keeping the same layout as if I had only one page as shown in the code below. My workaround is to divide the dataframe into subset that fit on one page, but the code is ugly. Is there a build-in way to achieve this? Dieter library(lattice) nsubj = 13 # This number is variable dt = expand.grid(time=1:20,comp=LETTERS[1:3],subj=letters[1:nsubj]) dt$val = rnorm(nrow(dt)) #pdf(file=multpageOk.pdf) # How it should look: xyplot(val~time|subj+comp, data=dt,type=l,layout=c(10,3), subset=as.integer(subj) = 10) #dev.off() # What to do if it stretches over multiple pages, but I want the same # layout as above? pdf(file=multpage.pdf) xyplot(val~time|subj+comp, data=dt,type=l,layout=c(10,3)) dev.off() -- View this message in context: http://r.789695.n4.nabble.com/Layout-of-mulitpage-conditioned-lattice-plots-tp3094581p3094581.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] Layout of mulitpage conditioned lattice plots
Hi Dieter: If I read your intention correctly, you need a third element in layout = . Here's a little example: df - data.frame(month = rep(month.abb, each = 20), time = rep(1:20, 12), y = rnorm(240)) xyplot(y ~ time | month, data = df, layout = c(2, 2, 3)) This produces 3 pages of 2 x 2 plots. Hope this is what you had in mind.. Dennis On Sun, Dec 19, 2010 at 8:23 AM, Dieter Menne dieter.me...@menne-biomed.dewrote: Dear latticists, I would like to spread a lattice conditioned plot over multiple pages, keeping the same layout as if I had only one page as shown in the code below. My workaround is to divide the dataframe into subset that fit on one page, but the code is ugly. Is there a build-in way to achieve this? Dieter library(lattice) nsubj = 13 # This number is variable dt = expand.grid(time=1:20,comp=LETTERS[1:3],subj=letters[1:nsubj]) dt$val = rnorm(nrow(dt)) #pdf(file=multpageOk.pdf) # How it should look: xyplot(val~time|subj+comp, data=dt,type=l,layout=c(10,3), subset=as.integer(subj) = 10) #dev.off() # What to do if it stretches over multiple pages, but I want the same # layout as above? pdf(file=multpage.pdf) xyplot(val~time|subj+comp, data=dt,type=l,layout=c(10,3)) dev.off() -- View this message in context: http://r.789695.n4.nabble.com/Layout-of-mulitpage-conditioned-lattice-plots-tp3094581p3094581.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Layout of mulitpage conditioned lattice plots
On Dec 19, 2010, at 11:23 AM, Dieter Menne wrote: Dear latticists, I would like to spread a lattice conditioned plot over multiple pages, keeping the same layout as if I had only one page as shown in the code below. My workaround is to divide the dataframe into subset that fit on one page, but the code is ugly. Is there a build-in way to achieve this? Dieter library(lattice) nsubj = 13 # This number is variable dt = expand.grid(time=1:20,comp=LETTERS[1:3],subj=letters[1:nsubj]) dt$val = rnorm(nrow(dt)) #pdf(file=multpageOk.pdf) # How it should look: xyplot(val~time|subj+comp, data=dt,type=l,layout=c(10,3), subset=as.integer(subj) = 10) #dev.off() # What to do if it stretches over multiple pages, but I want the same # layout as above? pdf(file=multpage.pdf) xyplot(val~time|subj+comp, data=dt,type=l,layout=c(10,3)) dev.off() What's not working? I see two pages output with the same layout. The difference is that in the second case your numbers of groups (subj x comp) is not an even multiple of your layout numbers, so the 13 subj levels push 3 of the A's onto the new row of panels and so one.and then the second page is partially filled with the 9 remaining C's. I suppose the fact that I have a default time-stamp for my lattice output could have some sort of side-effect. In my .Rprofile is this line: lattice.options(default.args = list(page = function(n) { panel.text(lab = sprintf(%s, date()), x = 0.01, y = 0.01, adj = 0, srt=90) })) -- David Winsemius, MD West Hartford, CT sessionInfo() R version 2.12.0 (2010-10-15) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid splines stats graphics grDevices utils datasets methods base other attached packages: [1] survey_3.22-4 lubridate_0.2.3 circular_0.4boot_1.2-43 ggplot2_0.8.8 proto_0.3-8 [7] reshape_0.8.3 plyr_1.2.1 gridExtra_0.7 gdata_2.8.1 Hmisc_3.8-3 survival_2.36-1 [13] sos_1.3-0 brew_1.0-4 lattice_0.19-13 loaded via a namespace (and not attached): [1] cluster_1.13.2 digest_0.4.2 gtools_2.6.2 stringr_0.4 tools_2.12.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Layout of mulitpage conditioned lattice plots
Dennis, Thank you; this helps me, too! Tom On 12/19/10 11:45 AM, Dennis Murphy wrote: Hi Dieter: If I read your intention correctly, you need a third element in layout = . Here's a little example: df- data.frame(month = rep(month.abb, each = 20), time = rep(1:20, 12), y = rnorm(240)) xyplot(y ~ time | month, data = df, layout = c(2, 2, 3)) This produces 3 pages of 2 x 2 plots. Hope this is what you had in mind.. Dennis On Sun, Dec 19, 2010 at 8:23 AM, Dieter Menne dieter.me...@menne-biomed.dewrote: Dear latticists, I would like to spread a lattice conditioned plot over multiple pages, keeping the same layout as if I had only one page as shown in the code below. My workaround is to divide the dataframe into subset that fit on one page, but the code is ugly. Is there a build-in way to achieve this? Dieter library(lattice) nsubj = 13 # This number is variable dt = expand.grid(time=1:20,comp=LETTERS[1:3],subj=letters[1:nsubj]) dt$val = rnorm(nrow(dt)) #pdf(file=multpageOk.pdf) # How it should look: xyplot(val~time|subj+comp, data=dt,type=l,layout=c(10,3), subset=as.integer(subj)= 10) #dev.off() # What to do if it stretches over multiple pages, but I want the same # layout as above? pdf(file=multpage.pdf) xyplot(val~time|subj+comp, data=dt,type=l,layout=c(10,3)) dev.off() -- View this message in context: http://r.789695.n4.nabble.com/Layout-of-mulitpage-conditioned-lattice-plots-tp3094581p3094581.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Thomas E Adams National Weather Service Ohio River Forecast Center 1901 South State Route 134 Wilmington, OH 45177 EMAIL: thomas.ad...@noaa.gov VOICE: 937-383-0528 FAX:937-383-0033 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Alternative to extended recode sintax? Bug?
On 19.12.2010 13:20, David Winsemius wrote: On Dec 19, 2010, at 5:11 AM, Luca Meyer wrote: Something goes wrong with the week function of the lubridate package: x= as.POSIXct(factor(c(2010-12-15 17:28:27, + 2010-12-15 17:32:34, + 2010-12-15 18:48:39, + 2010-12-15 19:25:00, + 2010-12-16 08:00:00, + 2010-12-16 08:25:49, + 2010-12-16 09:00:00))) require(lubridate) weekdays(x) [1] Mercoledì Mercoledì Mercoledì Mercoledì Giovedì Giovedì Giovedì week(x) [1] 50 50 50 50 51 51 51 But 2010-12-15 is a Wednesday and 2010-12-16 is a Thursday. Together with the description of ?week this shows that lubridate's week() function works as documented rather than as expected by Luca Meyer. Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Change legend position in s.value {ade4}
Looking at the code shows this is hard coded (function scatterutil.legend.square.grey or friends are used that make use of par(usr)[1] and par(usr)[3]. Hence you will have to rewrite the code or even better provide thwe package maintainer with a patch that allows for arbitrary placemant of the legend. Uwe Ligges On 17.12.2010 14:43, Nevil Amos wrote: How do I change the postion of the legend in s.value {ade4} from the defaul , bootom left? thanks Nevil Amos __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Hclust - Number of branch operations for every element
Hello everybody, I need to know how often every element in an hierarchical cluster was branched - just imagine a watering pot on the top of the hierarchical tree - the leafs should get water according to the number of branches that lie before them. For example: a - list() # initialize empty object a$merge - matrix(c(-1, -2, -3, -4, 1, 2, -5,-6, 3,4), nc=2, byrow=TRUE ) a$height - c(1, 2, 3,4,5) a$order - c(1,2,3,4,5,6) a$labels - 1:6 class(a) - hclust plot(a) The leaf 1 has was branched three times - it would get 1/2^3 = 0.125 of the total water. Same for leaf 2.Leafs 3 and 4 would each get the same (0.125). Leaf 5 and 6 would get 0.25 - Adding up to 1. Does anybody have a clue? Thanks a lot in advance! Lui __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Layout of mulitpage conditioned lattice plots
djmuseR wrote: If I read your intention correctly, you need a third element in layout = . df - data.frame(month = rep(month.abb, each = 20), time = rep(1:20, 12), y = rnorm(240)) xyplot(y ~ time | month, data = df, layout = c(2, 2, 3)) This produces 3 pages of 2 x 2 plots. Not really. Note that my example is conditioned on 2 variables, and the layout on the first page is the correct one, and by design I use nsubj=13 to show what happens if a page is not filled. Dieter -- View this message in context: http://r.789695.n4.nabble.com/Layout-of-mulitpage-conditioned-lattice-plots-tp3094581p3094724.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] Layout of mulitpage conditioned lattice plots
David Winsemius wrote: What's not working? I see two pages output with the same layout. The difference is that in the second case your numbers of groups (subj x comp) is not an even multiple of your layout numbers, so the 13 subj levels push 3 of the A's onto the new row of panels and so one.and then the second page is partially filled with the 9 remaining C's. As you noted, the last page is the problem, and nsubj=13 was chosen by design. I am currently looking if ggplot2 can handle this case without large coding overhead. Dieter -- View this message in context: http://r.789695.n4.nabble.com/Layout-of-mulitpage-conditioned-lattice-plots-tp3094581p3094732.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] levelplot blocks size
Sorry to bump this up again, but I've been continuing to look for a solution to this including a look into stats.bin but I still can't find any solution to do this within R. Any help would be much appreciated! Thanks, Jonathan -- View this message in context: http://r.789695.n4.nabble.com/levelplot-blocks-size-tp3089972p3094752.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] Replacing the for loop for time series buid-up
Torch wrote: Hi, is there a function that replaces the following code? n=200 boot.x[1]=odhad+boot.res[1] #(boot.x[0]=1) for (j in 1:(n-1)) { boot.x[j+1]=odhad*boot.x[j]+boot.res[j+1] } This is nested in two other loops, and I am looking for some way to improve code performance I tried sapply and cumprod but no success. You can have a look at filter. Test example: alpha - 0.75 N - 10 boot.res - ts(rnorm(N)) boot.res val.init - boot.res[1] + alpha boot.x - ts(val.init, start=1,end=N) for(t in 2:N) { boot.x[t] - alpha*boot.x[t-1] + boot.res[t] } boot.x boot.x.filter - ts(c(val.init,filter(boot.res[-1],filter=alpha,method=recursive,init=val.init))) boot.x.filter boot.x - boot.x.filter succes Berend -- View this message in context: http://r.789695.n4.nabble.com/Replacing-the-for-loop-for-time-series-buid-up-tp3094421p3094757.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] Layout of mulitpage conditioned lattice plots
Here is an example with ggplot2, which can also be used in a similar way with lattice. Again, the last page is the problem: the arrangement is correct here, but the last page (with 1 instead of 5 plots) has a different panel size which makes a comparison difficult. And, since I have much more points per panel: ggplot2 is slow compared to lattice. Dieter library(ggplot2) nsubj = 11 dt = expand.grid(time=1:20,comp=LETTERS[1:3],subj=letters[1:nsubj]) dt$val = rnorm(nrow(dt)) nPerPage = 5 for (i in seq(1,nsubj,by=nPerPage)) { subjs = i:max(i+nPerPage-1,nPerPage) print(subjs) p = qplot(time,val,data=subset(dt,as.integer(subj) %in% subjs )) + geom_line()+ facet_grid(comp ~ subj)+opts(aspect.ratio=1) print(p) } -- View this message in context: http://r.789695.n4.nabble.com/Layout-of-mulitpage-conditioned-lattice-plots-tp3094581p3094775.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] R.matlab memory use
Hi, I am trying to load into R a MATLAB format file (actually, as saved by octave). The file is about 300kB but R complains with a memory allocation error: library(Rcompression) library(R.matlab) Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.2.0 (2010-03-13) successfully loaded. See ?R.methodsS3 for help. R.oo v1.7.2 (2010-04-13) successfully loaded. See ?R.oo for help. R.matlab v1.3.1 (2010-04-20) successfully loaded. See ?R.matlab for help. f - readMat(freq.mat) Error: cannot allocate vector of size 296.5 Mb On the other hand, if I save the same data in ascii format (from octave: save -text), resulting in a 75MB file, then I can load it without problems with the read.octave() function from package foreign. Is this a known issue or am I doing something wrong? My R version is: R.version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 11.1 year 2010 month 05 day31 svn rev52157 language R version.string R version 2.11.1 (2010-05-31) Thanks for your help, Stefano -- Stefano Ghirlanda www.intercult.su.se/~stefano - drghirlanda.wordpress.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] levelplot blocks size
On 19/12/2010 2:10 PM, jonathan wrote: Sorry to bump this up again, but I've been continuing to look for a solution to this including a look into stats.bin but I still can't find any solution to do this within R. See ?levelplot. The number of bins of x and y is equal to the number of unique x and y values. If you want fewer, just round the values instead of using 1:1000. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] levelplot blocks size
Duncan, Thanks for the help. I'm new to R, so I'm not sure how to get R to round the values and group them into larger blocks. I have tried the following: xlim=seq(0,2000,100),ylim=seq(0,2000,100) just to see if it would work, but it doesn't... Do you think you might be able to explain how to go about rounding the values? Thanks, Jonathan -- View this message in context: http://r.789695.n4.nabble.com/levelplot-blocks-size-tp3089972p3094797.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] Hershey fonts and substitute()
Hello R users, I am new to R, so this may be a very stupid question. I need to subscript the dotted circle (Hershey escape sequence \\SO) to a string. I tried using text(.5,.5,substitute( R[disk] == 5 R[\\SO] ) ) but it turns out to be a syntax error. Do you have any suggestion? Thanks Gaetano __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Layout of mulitpage conditioned lattice plots
On Dec 19, 2010, at 1:53 PM, Dieter Menne wrote: David Winsemius wrote: What's not working? I see two pages output with the same layout. The difference is that in the second case your numbers of groups (subj x comp) is not an even multiple of your layout numbers, so the 13 subj levels push 3 of the A's onto the new row of panels and so one.and then the second page is partially filled with the 9 remaining C's. As you noted, the last page is the problem, and nsubj=13 was chosen by design. I am currently looking if ggplot2 can handle this case without large coding overhead. I'm obviously not seeing what you think would be an acceptable solution. Can you explain in words what you want, rather than what you don't want in failed code? Here's my latest guess at what you may want: pdf(file=multpage.pdf) xyplot(val~time|subj + comp, data=dt,type=l, layout=c(3,5, 3), skip=rep(c(rep(FALSE,13), TRUE, TRUE), 3) ) dev.off() -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] levelplot blocks size
On 19/12/2010 2:46 PM, jonathan wrote: Duncan, Thanks for the help. I'm new to R, so I'm not sure how to get R to round the values and group them into larger blocks. I have tried the following: xlim=seq(0,2000,100),ylim=seq(0,2000,100) just to see if it would work, but it doesn't... Do you think you might be able to explain how to go about rounding the values? I don't know what your data looks like, so this is hard. levelplot assumes you have triplets (x,y,z), where x and y only take a few values, and it plots the grid of those values using z to set the colour. In your example you read x amd y from a file. So just round them to fewer values, e.g. df$x - round(df$x, -2) # round to -2 decimal places, i.e. to hundreds df$y - round(df$y, -2) levelplot(z ~ x+y, data=df) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Hershey fonts and substitute()
On Dec 19, 2010, at 3:25 PM, pilchat wrote: Hello R users, I am new to R, so this may be a very stupid question. I need to subscript the dotted circle (Hershey escape sequence \\SO) to a string. I tried using text(.5,.5,substitute( R[disk] == 5 R[\\SO] ) ) but it turns out to be a syntax error. Do you have any suggestion? The Hershey fonts can be used in the text function: ?Hershey ... but I'm not sure they can be mixed with plotmath expressions. You wouldn't be the first person to befrustrated about this: http://tolstoy.newcastle.edu.au/R/help/02a/1877.html And note you may need:par(xpd=TRUE) Where character ends up will depend on your user coordinate system. I had just run the Hershey demo and I needed to push the location down to get it on the page: text(1.5, -2.5, \\SO, vfont=c(serif,plain) ) You may need to use phantom() in that expression using plotmath, and then zero in on the space that is open after the R using a second call to text. Thanks Gaetano __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Ifelse stability problems?
On Dec 19, 2010, at 15:01 , Peter Ehlers wrote: On 2010-12-19 03:50, Luca Meyer wrote: I am just wondering why what I am showing below might occur. First I have an x data.frame: str(x) 'data.frame': 281 obs. of 2 variables: $ x1 : Factor w/ 5 levels A (50-67%),B (10-20%),..: 1 2 5 1 2 5 1 2 5 1 ... $ x2 : num 33.8 60.2 6 76.8 13.8 9.4 76.9 8 15.1 78.1 ... I need to check that for each level of factor x1 the values of x2 are (approximately) contained within a given range. In such a case I will print ok a third variable, otherwise I will write err ifelse (x$x1 == A (50-67%), x$check-ifelse(x$x268x$x249,ok,), x$check-x$check ) [...snip...] Can anyone explain why this might occur? You have a bit of a logic problem in your ifelse; (look at your x$check after each of your ifelse()s); try it this way: x$check - NA x$check - ifelse (x$x1 == A (50-67%), ifelse(x$x268x$x249,ok,), x$check ) Yes. The whole thing can be written much more concisely, though: lw - c(49,9,4,0,9) up - c(68,21,16,6,21) x$check - ifelse(x$x2 up[x$x1] x$x2 lw[x$x1], ok, ) etc. Peter Ehlers Thanks, Luca Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] monthly median in a daily dataset
Hello, I have a multi-year dataset (see below) with date, a data value and a flag for the data value. I want to find the monthly median for each month in this dataset and then plot it. If anyone has suggestions they would be greatly apperciated. It should be noted that there are some dates with no values and they should be removed. Thanks Emily print ( str(data$flow$daily) ) 'data.frame': 16071 obs. of 3 variables: $ date :Class 'Date' num [1:16071] -1826 -1825 -1824 -1823 -1822 ... $ value: num NA NA NA NA NA NA NA NA NA NA ... $ flag : chr ... NULL 5202008-11-01 0.034 1041 2008-11-02 0.034 1562 2008-11-03 0.034 2083 2008-11-04 0.038 2604 2008-11-05 0.036 3125 2008-11-06 0.035 3646 2008-11-07 0.036 4167 2008-11-08 0.039 4688 2008-11-09 0.039 5209 2008-11-10 0.039 5730 2008-11-11 0.038 6251 2008-11-12 0.039 6772 2008-11-13 0.039 7293 2008-11-14 0.038 7814 2008-11-15 0.037 8335 2008-11-16 0.037 8855 2008-11-17 0.037 9375 2008-11-18 0.037 9895 2008-11-19 0.034B 10415 2008-11-20 0.034B 10935 2008-11-21 0.033B 11455 2008-11-22 0.034B 11975 2008-11-23 0.034B 12495 2008-11-24 0.034B 13016 2008-11-25 0.034B 13537 2008-11-26 0.033B 14058 2008-11-27 0.033B 14579 2008-11-28 0.033B 15068 2008-11-29 0.034B 15546 2008-11-30 0.035B 5212008-12-01 0.035B 1042 2008-12-02 0.034B 1563 2008-12-03 0.033B 2084 2008-12-04 0.031B 2605 2008-12-05 0.031B 3126 2008-12-06 0.031B 3647 2008-12-07 0.032B 4168 2008-12-08 0.032B 4689 2008-12-09 0.032B 5210 2008-12-10 0.033B 5731 2008-12-11 0.033B 6252 2008-12-12 0.032B 6773 2008-12-13 0.031B 7294 2008-12-14 0.030B 7815 2008-12-15 0.030B 8336 2008-12-16 0.029B 8856 2008-12-17 0.028B 9376 2008-12-18 0.028B 9896 2008-12-19 0.028B 10416 2008-12-20 0.027B 10936 2008-12-21 0.027B 11456 2008-12-22 0.028B 11976 2008-12-23 0.028B 12496 2008-12-24 0.029B 13017 2008-12-25 0.029B 13538 2008-12-26 0.029B 14059 2008-12-27 0.030B 14580 2008-12-28 0.030B 15069 2008-12-29 0.030B 15547 2008-12-30 0.031B 15851 2008-12-31 0.031B -- View this message in context: http://r.789695.n4.nabble.com/monthly-median-in-a-daily-dataset-tp3094917p3094917.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] monthly median in a daily dataset
Hi: There is a months() function associated with Date objects, so you should be able to do something like aggregate(value ~ months(date), data = data$flow$daily, FUN = median) Here's a toy example because your data are not in a ready form: df - data.frame(date = seq(as.Date('2010-01-01'), by = 'days', length = 250), val = rnorm(250)) aggregate(val ~ months(date), data = df, FUN = median) months(date) val 1April -0.18864817 2 August -0.16203705 3 February 0.03671700 4 January 0.04500988 5 July -0.12753151 6 June 0.09864811 7March 0.23652105 8 May 0.25879994 9September 0.53570764 HTH, Dennis On Sun, Dec 19, 2010 at 2:31 PM, HUXTERE emilyhux...@gmail.com wrote: Hello, I have a multi-year dataset (see below) with date, a data value and a flag for the data value. I want to find the monthly median for each month in this dataset and then plot it. If anyone has suggestions they would be greatly apperciated. It should be noted that there are some dates with no values and they should be removed. Thanks Emily print ( str(data$flow$daily) ) 'data.frame': 16071 obs. of 3 variables: $ date :Class 'Date' num [1:16071] -1826 -1825 -1824 -1823 -1822 ... $ value: num NA NA NA NA NA NA NA NA NA NA ... $ flag : chr ... NULL 5202008-11-01 0.034 1041 2008-11-02 0.034 1562 2008-11-03 0.034 2083 2008-11-04 0.038 2604 2008-11-05 0.036 3125 2008-11-06 0.035 3646 2008-11-07 0.036 4167 2008-11-08 0.039 4688 2008-11-09 0.039 5209 2008-11-10 0.039 5730 2008-11-11 0.038 6251 2008-11-12 0.039 6772 2008-11-13 0.039 7293 2008-11-14 0.038 7814 2008-11-15 0.037 8335 2008-11-16 0.037 8855 2008-11-17 0.037 9375 2008-11-18 0.037 9895 2008-11-19 0.034B 10415 2008-11-20 0.034B 10935 2008-11-21 0.033B 11455 2008-11-22 0.034B 11975 2008-11-23 0.034B 12495 2008-11-24 0.034B 13016 2008-11-25 0.034B 13537 2008-11-26 0.033B 14058 2008-11-27 0.033B 14579 2008-11-28 0.033B 15068 2008-11-29 0.034B 15546 2008-11-30 0.035B 5212008-12-01 0.035B 1042 2008-12-02 0.034B 1563 2008-12-03 0.033B 2084 2008-12-04 0.031B 2605 2008-12-05 0.031B 3126 2008-12-06 0.031B 3647 2008-12-07 0.032B 4168 2008-12-08 0.032B 4689 2008-12-09 0.032B 5210 2008-12-10 0.033B 5731 2008-12-11 0.033B 6252 2008-12-12 0.032B 6773 2008-12-13 0.031B 7294 2008-12-14 0.030B 7815 2008-12-15 0.030B 8336 2008-12-16 0.029B 8856 2008-12-17 0.028B 9376 2008-12-18 0.028B 9896 2008-12-19 0.028B 10416 2008-12-20 0.027B 10936 2008-12-21 0.027B 11456 2008-12-22 0.028B 11976 2008-12-23 0.028B 12496 2008-12-24 0.029B 13017 2008-12-25 0.029B 13538 2008-12-26 0.029B 14059 2008-12-27 0.030B 14580 2008-12-28 0.030B 15069 2008-12-29 0.030B 15547 2008-12-30 0.031B 15851 2008-12-31 0.031B -- View this message in context: http://r.789695.n4.nabble.com/monthly-median-in-a-daily-dataset-tp3094917p3094917.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Time Series of Histograms
Dear List, I have a set of distributions recorded at an equal interval of time and I would like to plot them as series of horizontal histograms (with the x-axis representing time, and y-axis representing the bins) since the distribution shifts from unimodal to multimodal in several occasions. What I would like to see is something close to a violinplot, but I do not want a kernel density estimate... Any suggestions or advice will be great! Thanks in Advance, Enrico __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Turning a Variable into String
I would like to know how to turn a variable into a string. I have tried as.symbol and as.name but it doesnt work for what I'd like to do Essentially, I'd like to feed the function below with two variables. This works fine in the bit working out number of elements in each variable. In the print(sprintf(OK with %s and %s\n, var1, var2)) line I would like var1 and var2 to be magically substituted with a string containing the name of var1 and name of var2. Thanks in advance Paolo haveSameLength - function(var1, var2) { if (length(var1)==length(var2)) { print(sprintf(OK with %s and %s\n, var1, var2)) } else { print(Problems!!) } } [[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] Turning a Variable into String
Paolo - One way to make the function do what you want is to replace the line print(sprintf(OK with %s and %s\n, var1, var2)) with cat('OK with',substitute(var1),'and',substitute(var2),'\n') With sprintf, you'd need print(sprintf(OK with %s and %s\n, deparse(substitute(var1)), deparse(substitute(var2 but since you're just printing the string returned by sprintf, I'd go with cat. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Mon, 20 Dec 2010, Paolo Rossi wrote: I would like to know how to turn a variable into a string. I have tried as.symbol and as.name but it doesnt work for what I'd like to do Essentially, I'd like to feed the function below with two variables. This works fine in the bit working out number of elements in each variable. In the print(sprintf(OK with %s and %s\n, var1, var2)) line I would like var1 and var2 to be magically substituted with a string containing the name of var1 and name of var2. Thanks in advance Paolo haveSameLength - function(var1, var2) { if (length(var1)==length(var2)) { print(sprintf(OK with %s and %s\n, var1, var2)) } else { print(Problems!!) } } [[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] Turning a Variable into String
On 19/12/2010 7:21 PM, Paolo Rossi wrote: I would like to know how to turn a variable into a string. I have tried as.symbol and as.name but it doesnt work for what I'd like to do Essentially, I'd like to feed the function below with two variables. This works fine in the bit working out number of elements in each variable. In the print(sprintf(OK with %s and %s\n, var1, var2)) line I would like var1 and var2 to be magically substituted with a string containing the name of var1 and name of var2. The name of var1 is var1, so I assume you mean the expression passed to your function and bound to var1. In that case, what you want is deparse(substitute(var1)) Watch out: if the expression is really long, that can be a vector with more than one element. See ?deparse for ways to deal with that. Duncan Murdoch Thanks in advance Paolo haveSameLength- function(var1, var2) { if (length(var1)==length(var2)) { print(sprintf(OK with %s and %s\n, var1, var2)) } else { print(Problems!!) } } [[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] system/system2 command
On 17/12/2010 4:36 PM, Jeff Breiwick wrote: All, I had a simple function call I used to open up a dos shell running R under Win XP: system(cmd.exe, wait=FALSE, invisible=FALSE). This does not work with R 2.12.1 - I get a window that briefly flashes open but then disappears. Does anyone know the method to open a DOS command window in running R with Win XP? Thank you. This is a new bug in 2.12.1, which I am about to fix in R-patched. The problem was that it was passing a null input stream to cmd.exe, which saw an immediate EOF, and quit. A similar thing happened in Rterm, where system(cmd) should drop into a command shell in the same window, but it would immediately exit. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Time Series of Histograms
Hi: You can get a violin plot in lattice rather straightforwardly. It's easiest if time is an ordered factor, but you can also do it if time is numeric; in the latter case, the code associated with Figure 10.14 in the Lattice book provides a template to start with: http://lmdvr.r-forge.r-project.org/figures/figures.html To get horizontal violin plots, use time as the y variable and start by replacing panel.boxplot with panel.violin; see the help page of the latter if more specific options are required. It also contains an example using a panel function. I don't know how you expect to get horizontal histograms without setting the time variable to be a factor. If you have enough time periods, the result will not be pretty. If you have a fairly large number of time periods, the best distributional displays are boxplots, violin plots, beanplots or some variation of that general concept. Since neither data nor code were offered, one can only speculate so far as to what your intentions might be. A reproducible example with data and code would undoubtedly elicit more useful responses. HTH, Dennis On Sun, Dec 19, 2010 at 4:03 PM, Enrico R. Crema enryu_cr...@yahoo.itwrote: Dear List, I have a set of distributions recorded at an equal interval of time and I would like to plot them as series of horizontal histograms (with the x-axis representing time, and y-axis representing the bins) since the distribution shifts from unimodal to multimodal in several occasions. What I would like to see is something close to a violinplot, but I do not want a kernel density estimate... Any suggestions or advice will be great! Thanks in Advance, Enrico __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Time Series of Histograms
Many Thanks Dennis, The distributions are simulated ordinal data all bounded in the same upper and lower limit, and I wanted to plot how the distribution changes through time. Since the distributions are often multimodal boxplots were not useful so I made some violinplots... My practical solution which I'm testing right now is to create a matrix of frequencies and then plot these as a series of horrizontal barplots (after normalising each distribution) , using the offset parameter to control the temporal sequenceIt actually works fine, but I was wondering if there were better ways... Enrico On 20 Dec 2010, at 01:47, Dennis Murphy wrote: Hi: You can get a violin plot in lattice rather straightforwardly. It's easiest if time is an ordered factor, but you can also do it if time is numeric; in the latter case, the code associated with Figure 10.14 in the Lattice book provides a template to start with: http://lmdvr.r-forge.r-project.org/figures/figures.html To get horizontal violin plots, use time as the y variable and start by replacing panel.boxplot with panel.violin; see the help page of the latter if more specific options are required. It also contains an example using a panel function. I don't know how you expect to get horizontal histograms without setting the time variable to be a factor. If you have enough time periods, the result will not be pretty. If you have a fairly large number of time periods, the best distributional displays are boxplots, violin plots, beanplots or some variation of that general concept. Since neither data nor code were offered, one can only speculate so far as to what your intentions might be. A reproducible example with data and code would undoubtedly elicit more useful responses. HTH, Dennis On Sun, Dec 19, 2010 at 4:03 PM, Enrico R. Crema enryu_cr...@yahoo.it wrote: Dear List, I have a set of distributions recorded at an equal interval of time and I would like to plot them as series of horizontal histograms (with the x-axis representing time, and y-axis representing the bins) since the distribution shifts from unimodal to multimodal in several occasions. What I would like to see is something close to a violinplot, but I do not want a kernel density estimate... Any suggestions or advice will be great! Thanks in Advance, Enrico __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Time Series of Histograms
Hi Enrico, Is this close to what you want to do? http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 HTH, Jorge On Sun, Dec 19, 2010 at 7:03 PM, Enrico R. Crema wrote: Dear List, I have a set of distributions recorded at an equal interval of time and I would like to plot them as series of horizontal histograms (with the x-axis representing time, and y-axis representing the bins) since the distribution shifts from unimodal to multimodal in several occasions. What I would like to see is something close to a violinplot, but I do not want a kernel density estimate... Any suggestions or advice will be great! Thanks in Advance, Enrico __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] monthly median in a daily dataset
I find this function useful for digging out months from Date objects Month - function(date, ...) factor(month.abb[as.POSIXlt(date)$mon + 1], levels = month.abb) For this little data set below this is what it gives with(data, tapply(value, Month(date), median, na.rm = TRUE)) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec NANANANANANANANANANA 0.035 0.030 Here is another useful little one: Year - function(date, ...) as.POSIXlt(date)$year + 1900 So if you wanted the median by year and month you could do with(data, tapply(value, list(Year(date), Month(date)), median, na.rm = TRUE)) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2008 NA NA NA NA NA NA NA NA NA NA 0.035 0.03 (The result is a matrix, which in this case has only one row, of course.) See how you go. Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of HUXTERE Sent: Monday, 20 December 2010 8:32 AM To: r-help@r-project.org Subject: [R] monthly median in a daily dataset Hello, I have a multi-year dataset (see below) with date, a data value and a flag for the data value. I want to find the monthly median for each month in this dataset and then plot it. If anyone has suggestions they would be greatly apperciated. It should be noted that there are some dates with no values and they should be removed. Thanks Emily print ( str(data$flow$daily) ) 'data.frame': 16071 obs. of 3 variables: $ date :Class 'Date' num [1:16071] -1826 -1825 -1824 -1823 -1822 ... $ value: num NA NA NA NA NA NA NA NA NA NA ... $ flag : chr ... NULL 5202008-11-01 0.034 1041 2008-11-02 0.034 1562 2008-11-03 0.034 2083 2008-11-04 0.038 2604 2008-11-05 0.036 3125 2008-11-06 0.035 3646 2008-11-07 0.036 4167 2008-11-08 0.039 4688 2008-11-09 0.039 5209 2008-11-10 0.039 5730 2008-11-11 0.038 6251 2008-11-12 0.039 6772 2008-11-13 0.039 7293 2008-11-14 0.038 7814 2008-11-15 0.037 8335 2008-11-16 0.037 8855 2008-11-17 0.037 9375 2008-11-18 0.037 9895 2008-11-19 0.034B 10415 2008-11-20 0.034B 10935 2008-11-21 0.033B 11455 2008-11-22 0.034B 11975 2008-11-23 0.034B 12495 2008-11-24 0.034B 13016 2008-11-25 0.034B 13537 2008-11-26 0.033B 14058 2008-11-27 0.033B 14579 2008-11-28 0.033B 15068 2008-11-29 0.034B 15546 2008-11-30 0.035B 5212008-12-01 0.035B 1042 2008-12-02 0.034B 1563 2008-12-03 0.033B 2084 2008-12-04 0.031B 2605 2008-12-05 0.031B 3126 2008-12-06 0.031B 3647 2008-12-07 0.032B 4168 2008-12-08 0.032B 4689 2008-12-09 0.032B 5210 2008-12-10 0.033B 5731 2008-12-11 0.033B 6252 2008-12-12 0.032B 6773 2008-12-13 0.031B 7294 2008-12-14 0.030B 7815 2008-12-15 0.030B 8336 2008-12-16 0.029B 8856 2008-12-17 0.028B 9376 2008-12-18 0.028B 9896 2008-12-19 0.028B 10416 2008-12-20 0.027B 10936 2008-12-21 0.027B 11456 2008-12-22 0.028B 11976 2008-12-23 0.028B 12496 2008-12-24 0.029B 13017 2008-12-25 0.029B 13538 2008-12-26 0.029B 14059 2008-12-27 0.030B 14580 2008-12-28 0.030B 15069 2008-12-29 0.030B 15547 2008-12-30 0.031B 15851 2008-12-31 0.031B -- View this message in context: http://r.789695.n4.nabble.com/monthly-median-in-a-daily-dataset-tp3094917p3094917.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Time Series of Histograms
Hi Jorge, Yes this was exactly what I was looking for! Many Thanks!!! E. On 20 Dec 2010, at 02:11, Jorge Ivan Velez wrote: Hi Enrico, Is this close to what you want to do? http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 HTH, Jorge On Sun, Dec 19, 2010 at 7:03 PM, Enrico R. Crema wrote: Dear List, I have a set of distributions recorded at an equal interval of time and I would like to plot them as series of horizontal histograms (with the x-axis representing time, and y-axis representing the bins) since the distribution shifts from unimodal to multimodal in several occasions. What I would like to see is something close to a violinplot, but I do not want a kernel density estimate... Any suggestions or advice will be great! Thanks in Advance, Enrico __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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.matlab memory use
Stefano Ghirlanda dr.ghirlanda at gmail.com writes: I am trying to load into R a MATLAB format file (actually, as saved by octave). The file is about 300kB but R complains with a memory allocation error: library(Rcompression) library(R.matlab) Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.2.0 (2010-03-13) successfully loaded. See ?R.methodsS3 for help. R.oo v1.7.2 (2010-04-13) successfully loaded. See ?R.oo for help. R.matlab v1.3.1 (2010-04-20) successfully loaded. See ?R.matlab for help. f - readMat(freq.mat) Error: cannot allocate vector of size 296.5 Mb On the other hand, if I save the same data in ascii format (from octave: save -text), resulting in a 75MB file, then I can load it without problems with the read.octave() function from package foreign. Is this a known issue or am I doing something wrong? My R version is: This is not a package I'm particularly familiar with, but: what commands did you use to save the file in octave? Based on 'help save' I think that 'save' by default would get you an octave format file ... you might have to do some careful reading in ?readMat (in R) and 'help save' (in octave) to figure out the correspondence between octave/MATLAB and R/MATLAB. If possible, try saving a small file and see if it works; if you still don't know what's going on, post that file somewhere for people to try. I was able to save -6 save.mat in octave and readMat(save.mat) in R successfully, saving a vector of integers from 1 to 1 million (which took about 7.7 Mb) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tabulating 2 factors weighting by a third var
Hi, This must be an easy one but so far I haven't find a way out... I have a data frame such as: $ v1: Factor w/ 5 levels $ v2: Factor w/ 2 levels $ v3: Class 'difftime' atomic [1:] basically v1 and v2 are factors, while v3 is a variable containing the duration of certain activities (values ranging from 11 to 45000 sec, no missing values) How can I get a table such that v1 levels will show as rows, v2 levels as columns and v3 is the weight by which table(v1,v2) is weighted? That is, instead of getting the count of occurences in each of the 10 cells of table(v1,v2) I would like to get the sum(v3), how can it be done? Thanks, Luca Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] package arules - 'transpose' of the transactions
Suppose this is my list of transactions: set.seed(200) tran=random.transactions(100,3) inspect(tran) itemstransactionID 1 {item80}trans1 2 {item8, item20}trans2 3 {item28}trans3 I want to get the 'transpose' of the data, i.e. transactionID items 1 {trans2}item8 2 {trans2}item20 3 {trans3}item28 4 {trans1}item80 I tried converting tran into a matrix, then transpose it, then convert it back to transactions. But my dataset is actually very very large, so I wonder if there is any faster method? Thanks -- KC [[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] tabulating 2 factors weighting by a third var
Hi, Luca, if V is you data frame, maybe with( V, tapply( v3, list( v1, v2), sum)) does what you want. Hth -- Gerrit On Mon, 20 Dec 2010, Luca Meyer wrote: Hi, This must be an easy one but so far I haven't find a way out... I have a data frame such as: $ v1: Factor w/ 5 levels $ v2: Factor w/ 2 levels $ v3: Class 'difftime' atomic [1:] basically v1 and v2 are factors, while v3 is a variable containing the duration of certain activities (values ranging from 11 to 45000 sec, no missing values) How can I get a table such that v1 levels will show as rows, v2 levels as columns and v3 is the weight by which table(v1,v2) is weighted? That is, instead of getting the count of occurences in each of the 10 cells of table(v1,v2) I would like to get the sum(v3), how can it be done? Thanks, Luca Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: tabulating 2 factors weighting by a third var
Hi r-help-boun...@r-project.org napsal dne 20.12.2010 07:07:35: Hi, This must be an easy one but so far I haven't find a way out... I have a data frame such as: $ v1: Factor w/ 5 levels $ v2: Factor w/ 2 levels $ v3: Class 'difftime' atomic [1:] basically v1 and v2 are factors, while v3 is a variable containing the duration of certain activities (values ranging from 11 to 45000 sec, no missing values) How can I get a table such that v1 levels will show as rows, v2 levels as columns and v3 is the weight by which table(v1,v2) is weighted? That is, instead of getting the count of occurences in each of the 10 cells of table (v1,v2) I would like to get the sum(v3), how can it be done? xtabs(v3~v1+v2, data=your.data.frame) is other option. Regards Petr Thanks, Luca Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.