hopefully I'm missing no answer already given her, but nothing I found seems to fit my problem.
I want to filter a 3D-array for certain outlier values (x > .300, x < 3). I have a structure like this here, with 30 slices for each subject with 2 columns for reaction times and a integer as choice:
n_subjects <- 30
n_obs <- 250
dat <- array(NaN, dim=c(n_subjects, 2, n_obs))
dat[, 1, ] <- rexp(n_obs, 1)
dat[, 2, ] <- round(runif(n_obs, 1, 5), 0)
My first approach was to use which(),it seems to work, but gives me an unstruct
dat[which(dat[, 1, ] > 0.3 & dat[, 1, ] < 3)]
which returns filtered values, but as a vector, losing the dimensional structure.
dat[which(dat[, 1, ] > 0.3 & dat[, 1, ] < 3)]
[1] 1.44154641 0.52122836 0.75427634 0.72299465 0.52707838 0.58455269 1.01634364 0.68883200 1.15541663 1.69872059
[11] 0.57827779 0.33754890 0.91186386 1.81258378 0.79937850 1.19459413 1.19862926 3.00000000 3.00000000 4.00000000
[21] 3.00000000 3.00000000 3.00000000 3.00000000 2.00000000 2.00000000 4.00000000 5.00000000 5.00000000 4.00000000
[31] 1.00000000 2.00000000 5.00000000 3.00000000 2.00000000 4.00000000 2.00000000 0.09598808 2.26378860 1.65597480
[41] 0.97012070 1.97571758 0.56615487 0.58112680 3.74780963 1.13583855 3.11409406 0.22472111 0.44761366 4.95403062
[51] 5.66179472 0.18718267 0.69218598 0.81050307 0.35018347 0.05329958 0.23688262 0.42126038 1.16712480 2.21866501
[61] 1.00000000 5.00000000 2.00000000 3.00000000 4.00000000 4.00000000 4.00000000 4.00000000 1.00000000 1.00000000
[71] 1.00000000 3.00000000 2.00000000 2.00000000 4.00000000 3.00000000 5.00000000 5.00000000 2.00000000 0.40950035
[81] 0.70376002 2.33855435 0.81855408 1.16949376 1.50400404 2.71781548 0.71850858 0.90908760 0.24212159 0.02377835
[91] 0.15044300 0.24012386 1.00252243 0.78028357 3.50965326 0.52697154 1.54606865 0.66357898 0.76511035 0.37248749
[101] 1.00000000 4.00000000 2.00000000 4.00000000 4.00000000 3.00000000 3.00000000 1.00000000 4.00000000 2.00000000
I need to preserve the assignment of each value pair in the initial array. Is there any way, to do this with base R?