我遇到了一个转置大型数据集的奇怪问题。我想得到一个非线性飞行路线列表(即每个有30个顶点的矢量子列表)到一个数据帧中(顶点有32列)。该列表强制转换为data.frame没有问题,但在(1)转换为t(x)和(2)转换为矩阵时失败。
To illustrate:
> class(gc)
[1] "list"
> length(gc)
[1] 58278
> gc[[1]][1:30]
[1] 147.2200 147.1606 147.1012 147.0418 146.9824 146.9231 146.8638
[8] 146.8046 146.7454 146.6862 146.6270 146.5679 146.5088 146.4498
[15] 146.3908 146.3318 146.2728 146.2139 146.1550 146.0961 146.0373
[22] 145.9785 145.9197 145.8610 145.8022 145.7435 145.6849 145.6262
[29] 145.5676 145.5090
> gc2 <- data.frame(gc)
> nrow(gc2)
[1] 32
> length(gc2)
[1] 116556
> gc2[1:5,1:5]
lon lat lon.1 lat.1 lon.2
1 147.2200 -9.443383 -80.37861 43.46083 -87.90484
2 147.1606 -9.335072 -80.23135 43.52385 -87.53193
3 147.1012 -9.226751 -80.08379 43.58667 -87.15751
4 147.0418 -9.118420 -79.93591 43.64931 -86.78161
5 146.9824 -9.010080 -79.78773 43.71175 -86.40421
> gc3 <- t(gc2)
> nrow(gc3)
[1] 116556
> length(gc3)
[1] 3729792
> gc3 <- as.matrix(gc2)
> nrow(gc3)
[1] 32
> length(gc3)
[1] 3729792
3729792数字是116556 * 32 ..
感谢任何帮助!