Re: [R] Calculate Range

2013-11-17 Thread arun
Hi, You may also check: library(psych) library(plyr) df1 <- data.frame(group=rep(letters[1:3],c(5,10,15)), values=1:30) ddply(df1,.(group),mutate,Range=describe(values)$range) ##depends on how you wanted the output #or ddply(df1,.(group),summarise,Range=describe(values)$range) #or with(df1,describ

Re: [R] Calculate Range

2013-11-17 Thread jlh.membership
An approach using data tables: ### library(data.table) # dt: some data arranged by group dt <- data.table(group=c(rep("a",5), rep("b",10), rep("c",15)), values=1:30) # summarize by group smry <- dt[,list(min=min(values), max=max(values), range=diff(range(values))), by="group"] smry ### -Ori

Re: [R] Calculate Range

2013-11-16 Thread Jim Lemon
On 11/17/2013 08:49 AM, SCRIPTHAM wrote: Hi My R version is the current version as at 15 Nov 2013. I have tried to calculate range using tapply() with FUN=range. tapply() returns two fields, the ID field and a field of two text items one is the maximum and the other is the minimum. I take as th