I am dealing with a large dataset of 3D imaging data that I have loaded in to R using ff()
.
require(ff)
nSubj <- 125
vol_dim <- c(139,137,87)
ff_qmap <- ff(0, dim=c(vol_dim,nSubj)
Simple calls like getting an average array/"volume" back work fine:
mean_qmap_vol <- ffapply(X=ff_qmap,MARGIN=c(1,2,3),AFUN=mean,RETURN=TRUE)
However, in some instances I would like to return more than one array/"volume" back in a single ffapply
call; for instance, when performing some basic regression e.g. against age:
pval_vol <- ffapply( AFUN=f <- function(x) {
df$voxel <- x
fe1 <- lm(formula = voxel ~ age, df)
summary_fe1 <- summary(fe1)
fe1_estimate <- summary_fe1$coefficients[2,1]
fe1_pval <- summary_fe1$coefficients[2,4]
return(fe1_pval)
}, X = ff_qmap, MARGIN = c(1,2,3), RETURN = TRUE)
This works for returning a single volume back, i.e. fe1_pval
.
Is there a way to return both the fe1_estimate
and fe1_pval
(and perhaps more estimates) in one ffapply call?
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS
...
other attached packages:
[1] ff_2.2-13 bit_1.1-12 lme4_1.1-17 Matrix_1.2-8 ggplot2_2.2.1 fslr_2.12 neurobase_1.13.2
[8] oro.nifti_0.9.1