Same question:
I want to compare the median of 3d arrays along the second dimension (by index step), but the length of different arrays are usually different.
For example (same length):
dat1 <- array(seq(1, 1000), c(100, 70, 100))
dat2 <- array(seq(500, 1500), c(100, 70, 100))
data <- tibble(step = seq(1, length(dat1[1,,1])),
md1 = apply(dat1, 2, median),
md2 = apply(dat2, 2, median)) %>%
gather(md1, md2, key = "dat", value = "median")
ggplot(data, aes(step, median, color = dat)) +
geom_line()
But how to compare dat1
with different length dat3
like this:
dat3 <- array(seq(300, 1200), c(100, 55, 100))
I want to bin arrays along the second dimension by every 5% step first, then compare the median of every bin. Is there a method to do this?
Or any suggestions to compare different length 3d arrays? Or is extracting the median of every index then interpolate values to same length a better way?
Thanks.