在R中有没有办法选择许多非连续的,即奇数或偶数行/列?
我正在绘制我的主成分分析的负载.我有84行数据如下:x_1 y_1 x_2.....x_42 y_42
目前我正在为x和y加载数据创建数据帧,如下所示:
data.pc = princomp(as.matrix(data))
x.loadings <- data.frame(x=data.pc$loadings[c(1, 3, 5, 7, 9, 11, 13 ,15, 17, 19,
21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41), 1])
yloadings <- data.frame(y=data.pc$loadings[c(2, 4, 6, 8, 10, 12, 14, 16, 18, 20,
22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42), 1])
Run Code Online (Sandbox Code Playgroud)
当然有更简单的方法吗?