Re: [R] Simulate values

2015-04-07 Thread Kehl Dániel
Hi Mike, please keep conversation on the list. Your code looks wy better now. I would not name the variable variances2 but that is just a matter of taste. What you could also do as a one-liner is something like n <- 40 REPS <- 5 mu <- 10 sigma <- 5 chisq <- replicate(REPS,(n-1)*var(rnorm

Re: [R] Fast multiple match function

2015-04-07 Thread Jeff Newmiller
You might find the data.table package helpful. It uses an index sorted with a radix sort and minimizes moving the data around in memory. --- Jeff NewmillerThe . . Go Live... DCN:

Re: [R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot

2015-04-07 Thread Raghuraman Ramachandran
sessionInfo() R version 3.0.2 (2013-09-25) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 [3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C [5] LC_TIME=English_United Kingdom.1252 attached base packages: [1]

Re: [R] Fast multiple match function

2015-04-07 Thread Keshav Dhandhania
Hi all, Thanks for the responses. Herve's example is a good small size example of what I wanted. > y <- c(16, -3, -2, 15, 15, 0, 8, 15, -2) > someCoolFunc(-2, y) [1] 3 9 > someCoolFunc(15, y) [1] 4 5 8 The requirement is that I want someCoolFunc() to run in O(number of matches) time, instead of

Re: [R] Fast multiple match function

2015-04-07 Thread Hervé Pagès
Hi Keshav, findMatches() in the S4Vectors/IRanges packages (Bioconductor) I think does what you want: library(IRanges) y <- c(16L, -3L, -2L, 15L, 15L, 0L, 8L, 15L, -2L) x <- c(unique(y), 999L) hits <- findMatches(x, y) Then: > hits Hits object with 9 hits and 0 metadata columns:

Re: [R] Fast multiple match function

2015-04-07 Thread Enrico Schumann
On Mon, 06 Apr 2015, Keshav Dhandhania writes: > Hi, > > I know that one can find all occurrences of x in a vector v by doing >> which(x == v). > > However, if I need to do this again and again, where v is remaining the > same, then this is quite inefficient. In my particular case, I need to do >

Re: [R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot

2015-04-07 Thread William Dunlap
> plot(vols,plot.type="s",format="auto") > lines(vols[,2],col="red") Did you get any warning messages when you did that? I get > library(xts) > z <- xts(cbind(One=sin(1:20), Two=cos(1:20)+1.5), order.by =as.Date("2015-04-06")+(0:19)) > plot(z) Warning message: In plot.xts(z) : only the

Re: [R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot

2015-04-07 Thread Joshua Ulrich
The sessionInfo() function does not create a plot... On Tue, Apr 7, 2015 at 12:10 PM, Raghuraman Ramachandran wrote: > Thanks Josh. I am not sure if I can attach a Jpeg. Please find attached. > > On Tue, Apr 7, 2015 at 5:47 PM, Joshua Ulrich wrote: >> On Tue, Apr 7, 2015 at 11:30 AM, Raghuraman

Re: [R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot

2015-04-07 Thread Raghuraman Ramachandran
Thanks Josh. I am not sure if I can attach a Jpeg. Please find attached. On Tue, Apr 7, 2015 at 5:47 PM, Joshua Ulrich wrote: > On Tue, Apr 7, 2015 at 11:30 AM, Raghuraman Ramachandran > wrote: >> Dear guRus >> >> I have xts data as: >> str(volsA) >> An ‘xts’ object on 2014-05-13/2015-04-07 cont

Re: [R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot

2015-04-07 Thread Joshua Ulrich
On Tue, Apr 7, 2015 at 11:30 AM, Raghuraman Ramachandran wrote: > Dear guRus > > I have xts data as: > str(volsA) > An ‘xts’ object on 2014-05-13/2015-04-07 containing: > Data: num [1:221, 1:2] 18.8 18.5 18.4 22.2 22 ... > - attr(*, "dimnames")=List of 2 > ..$ : NULL > ..$ : chr [1:2] "vol1

[R] Unable to Scale/Display properly in plotting a xts/timeseries graph in a single plot

2015-04-07 Thread Raghuraman Ramachandran
Dear guRus I have xts data as: str(volsA) An ‘xts’ object on 2014-05-13/2015-04-07 containing: Data: num [1:221, 1:2] 18.8 18.5 18.4 22.2 22 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr [1:2] "vol1" "vol2" Indexed by objects of class: [Date] TZ: UTC xts Attributes: List of 1

Re: [R] Simulate values

2015-04-07 Thread Greg Snow
Thanks for your final paragraph, we sometimes see people who want us to do their homework for them and that does not go over well, but I think you situation is one where many would be happy to help. So here are some hints to help: The rnorm command expects the standard deviation, not the variance

Re: [R] Assembling output of table()

2015-04-07 Thread Rui Barradas
Hello, Maybe something like th following. lapply(jData, table) Hope this helps, Rui Barradas Em 07-04-2015 15:47, Sumitrajit Dhar escreveu: Hi folks, I am struggling with something that should be simple. Here is my data frame: head(jData[,1:8]) x study_id qx_1_v4j qx_1a_v4j qx_1b_v4j qx

[R] Assembling output of table()

2015-04-07 Thread Sumitrajit Dhar
Hi folks, I am struggling with something that should be simple. Here is my data frame: head(jData[,1:8]) x study_id qx_1_v4j qx_1a_v4j qx_1b_v4j qx_2_v4j qx_2a_v4j qx_3_v4j 1 1 MCJ10011 1 11 11 2 2 MCJ10021 1 21

Re: [R] Trim and fill procedure

2015-04-07 Thread Viechtbauer Wolfgang (STAT)
Yes, a comparison of the two objects would tell you what's been added. An object returned by the trimfill() function also has a vector added to it, named 'fill', which indicates whether the data (which are stored in the vector 'yi') are observed or augmented values. So, for example: library(met

Re: [R] strip levels

2015-04-07 Thread PIKAL Petr
Hi As Michael suggested your Year variable is probably numeric. Quick fix could be. histogram(~Width|Station*as.factor(Year), data=Raw.no10, layout=c(4,2),nin=30,xlab="Prosomal Width (mm)", strip=strip.custom(bg='white'),ylab="Frequencies",tick=-1,col='grey',as.table=TRUE) Cheers Petr >

Re: [R] Verify that a grid is uniform

2015-04-07 Thread Marc Lamblin
Yes, it could be a reasonable choice but I am not sure in general. If min(abs(diff(z))) is significant (global minimum or accentuated local minimum) my abscissa is not uniform a priori without performing the control. 2015-04-07 0:55 GMT+02:00 Bert Gunter : > Does not min(abs(diff(z))) give you th

Re: [R] strip levels

2015-04-07 Thread Michael Dewey
Dear Christine Are you sure that your variable Year is not numeric? You example plot looks to me as though it is treating it as a shingle. What does str(Raw.no10) tell you about Year? On 06/04/2015 17:40, Christine Lee wrote: Thank you very much to Both Sarah and Michael, Your responses are

Re: [R] strip levels

2015-04-07 Thread Jim Lemon
Hi Chistine, The latticeExtra package should be included with your installation of R. Enter: library(latticeExtra) in your R session to make it available. Jim On Tue, Apr 7, 2015 at 4:28 PM, David Winsemius wrote: > > On Apr 6, 2015, at 9:38 PM, Christine Lee via R-help wrote: > > > Thank yo

Re: [R] recode the same subset of variables in several list elements

2015-04-07 Thread Jim Lemon
Hi Simon, Let's see. If I wrap the code into a function: reverse.df.elements<-function(df,pattern="i",newrange=c(3,1)) { revlist<-grep(pattern,names(df),fixed=TRUE) df[,revlist]<-sapply(df[,revlist],rescale,newrange) return(df) } Then this might do the trick: lapply(list1,reverse.df.elements,

Re: [R] stripchart

2015-04-07 Thread Jim Lemon
Hi Catalin, I'm not quite sure which values you want to use, but does this start to do what you want? Jq90<-quantile(spei$J,0.9) Jq10<-quantile(spei$J,0.1) require(plotrix) plot(spei$year,spei$J,xlab="Year",ylab="Temerature anomaly", main="Temperature anomalies by year (1901 to 2013)", pch=ifels