I have the column a1, a2, a3 in my matrix. Now I want to generate a1_median, a2_median, a3_median in the same matrix by calculating the median of every column.
I tried to generate it with the following code, but it didn't work. It gives me the median of a1 for every column:
data[, (paste0("a",0:4, "_median")):= median(eval(parse(text = paste0("data$f",0:4, "_ltd"))))]
Is there another way to solve it?