Displaying 2 results from an estimated 2 matches for "v2sum".
Did you mean:
x2sum
2011 Jun 17
3
rle on large data . . . without a for loop!
I think need to do something like this:
dat<-data.frame(state=sample(id=rep(1:5,each=200),1:3, 1000,
replace=T,prob=c(0.7,0.05,0.25)),V1=runif(1,10,1000),V2=rnorm(1000))
rle.dat<-rle(dat$state)
temp<-1
out<-data.frame(id=1:length(rle.dat$length))
for(i in 1:length(rle.dat$length)){
temp2<-temp+rle.dat$length[[i]]
out$V1[i]<-mean(dat$V1[temp:temp2])
2014 Nov 21
1
dplyr/summarize does not create a true data frame
..., repcnt), rows, replace=T),
+ V1 = round(runif(rows)*25, 2) + 50,
+ V2 = round(runif(rows)*1000, 2) + 50,
+ V3 = round(runif(rows)*350, 2) - 175
+ )
>
> # use dplyr/summarize to create data frame
> my.output = frm %>%
+ group_by(Sex, Height) %>%
+ summarize(V1sum=sum(V1), V2sum=sum(V2))
> # work with columns in the output data frame
> ncol(my.output)
[1] 4
> my.output[1]
Source: local data frame [6 x 1]
Groups: Sex
Sex
1 Female
2 Female
3 Female
4 Male
5 Male
6 Male
> my.output[4]
Error in eval(expr, envir, enclos) : index out of bounds #######...