r - If Else Statements and Vector Length -
i'm trying perform correlations between vectors of unequal length, e.g.,
cor(x , y )
i want use largest possible number of observations each. moreover, i'd sample "randomly" each of vectors.
in pseudocode:
cor( sample(x, size = length(x or y, whichever smaller), replace = false ) , sample(y, size = length(x or y, whichever smaller), replace = false ) )
any ideas on how can this?
pretty sure you're asking, question motivations of not using pairwise correlations:
x <- 1:10 y <- 15:35 min.of.xy <- min(length(x), length(y)) cor(sample(x, min.of.xy, replace = false), sample(y, min.of.xy, replace = false))
Comments
Post a Comment