# NOT RUN {
# Generate a random matrix containing 10 continuous variables
# and a vector representing a continuous variable.
mat <- matrix(runif(200, 0, 20), 10)
y <- sample(runif(20, 0, 20))
# The correlations between y and each of row of mat are
# computed by
rowCors(mat, y)
# Generate a random binary vector and a matrix consisting
# of 10 ordinal variables with levels 0, 1, 2, where these
# values can be interpreted as scores for the differ
# categories.
mat <- matrix(sample(0:2, 500, TRUE), 10)
y <- sample(0:1, 50, TRUE)
# The values of the Cochran-Armitage trend statistic are
# computed by
rowCors(mat, y, trendStat = TRUE)
# If the values of the general test of linear trend described
# on page 87 of Agresti (2002) should be computed, then call
rowCors(mat, y, trendStat = TRUE, use.n = FALSE)
# }
Run the code above in your browser using DataLab