Hi Miluj,
Perhaps you didn't get my previous email. Let your data frame be named "msdf":
block_col_summ<-function(x,step,block_size,FUN="mean") {
dimx<-dim(x)
return_value<-NA
start<-1
end<-start+block_size-1
block_count<-1
while(end <= dimx[2]) {
return_value[block_count]<-
do.call(FUN
Thanks - it made me realize that I had reversed the column and row selection
rowMeans(x[seq(1:dim(x)[1],by=4),-1])
Jim
On Thu, Nov 10, 2016 at 8:30 AM, Uwe Ligges
wrote:
>
>
> On 09.11.2016 22:06, Jim Lemon wrote:
>>
>> Hi Milu,
>> Perhaps this will help:
>>
>> apply(as.matrix(x[-1,seq(1:dim(x
On 09.11.2016 22:06, Jim Lemon wrote:
Hi Milu,
Perhaps this will help:
apply(as.matrix(x[-1,seq(1:dim(x)[1],by=4)]),1,mean)
More efficient than apply(..., 1, mean): rowMeans()
Best,
Uwe Ligges
Jim
On Thu, Nov 10, 2016 at 4:00 AM, Miluji Sb wrote:
Thanks a lot for your quick reply.
Hi Milu,
Perhaps this will help:
apply(as.matrix(x[-1,seq(1:dim(x)[1],by=4)]),1,mean)
Jim
On Thu, Nov 10, 2016 at 4:00 AM, Miluji Sb wrote:
> Thanks a lot for your quick reply. I made a mistake in the question, I
> meant to ask every 4 (or 12) rows not columns. Apologies. Thanks again!
>
> Sin
> On Nov 9, 2016, at 9:24 AM, David Winsemius wrote:
>
>
>> On Nov 9, 2016, at 9:00 AM, Miluji Sb wrote:
>>
>> Thanks a lot for your quick reply. I made a mistake in the question, I
>> meant to ask every 4 (or 12) rows not columns. Apologies. Thanks again!
>
> Then try matrix( sapply( split(
> On Nov 9, 2016, at 9:00 AM, Miluji Sb wrote:
>
> Thanks a lot for your quick reply. I made a mistake in the question, I
> meant to ask every 4 (or 12) rows not columns. Apologies. Thanks again!
Then try matrix( sapply( split( x , 0:(dim(x)[2]/4-1)*4+1] ), mean)
Again assuming that dim(x)[1]
Better is...
rowMeans(x[0:((dim(x)[1]-1)/4)*4+1, ])
On Wed, Nov 9, 2016 at 9:00 AM, Miluji Sb wrote:
> Thanks a lot for your quick reply. I made a mistake in the question, I
> meant to ask every 4 (or 12) rows not columns. Apologies. Thanks again!
>
> Sincerely,
>
> Milu
>
> On Wed, Nov 9, 2016
rowMeans(x[0:(dim(x)[1]/4-1)*4+1, ])
On Wed, Nov 9, 2016 at 9:00 AM, Miluji Sb wrote:
> Thanks a lot for your quick reply. I made a mistake in the question, I
> meant to ask every 4 (or 12) rows not columns. Apologies. Thanks again!
>
> Sincerely,
>
> Milu
>
> On Wed, Nov 9, 2016 at 5:45 PM, Dal
Thanks a lot for your quick reply. I made a mistake in the question, I
meant to ask every 4 (or 12) rows not columns. Apologies. Thanks again!
Sincerely,
Milu
On Wed, Nov 9, 2016 at 5:45 PM, Dalthorp, Daniel wrote:
> Hi Milu,
> The following should work for an array x (provided dim(x)[2] is di
Hi Milu,
The following should work for an array x (provided dim(x)[2] is divisible
by 4):
colMeans(x[,0:(dim(x)[2]/4-1)*4+1])
-Dan
On Wed, Nov 9, 2016 at 8:29 AM, Miluji Sb wrote:
> Dear all,
>
> I have a dataset with hundreds of columns, I am only providing only 12
> columns. Is it possible t
Dear all,
I have a dataset with hundreds of columns, I am only providing only 12
columns. Is it possible to take the mean of every four (or 12) columns
(value601, value602, value603, value604 etc.in this case) and repeat for
the hundreds of columns? Thank you.
Sincerely,
Milu
structure(list(va
11 matches
Mail list logo