Dividing an array by an array column in R -
my data following:
print(xr) [1] 1.1235685 1.0715964 0.2043725 4.0639341 > class(xr) [1] "array" i'm trying divide values of columns in array value given 1st column (ie, 1.1235685). resulting array be:
1.000 0.953 0.181 3.616 how in r, given r-data object type? columns not have names, because of datatype. (if there's way can assign column names before dividing them, that's better.)
i'm new r, apologies simple question.
thank you.
some people answered in comments, i'll try provide more comprehensive one. code want pretty simple.
xr <- array(data = c(1.1235685, 1.0715964, 0.2043725, 4.0639341)) xr/xr[1] however, if created array 1 dimension, recommend use numeric vector instead, has no "dim" attribute. you'd create follows:
xr <- c(1.1235685, 1.0715964, 0.2043725, 4.0639341)) xr/xr[1]
Comments
Post a Comment