0
저는 디렉토리에서 많은 파일을 읽고 각 파일에 대한 계산을하고 있습니다. 스크립트를 parralel로 만들고 싶기 때문에 lapply를 사용합니다. 목록의 각 요소에서 데이터 프레임의 차원을 볼 때 1이됩니다. 누군가가 문제를 해결하도록 도와 줄 수 있습니까?lapply를 사용할 때 내 데이터의 크기가 줄어드는 이유는 무엇입니까?
files <- list.files(path="path to file")
dfr <- lapply(files, function(x) read.table(x,header=T,sep="\n"))
for(i in drf){
Do some computation
if (ncol(i) > 1){
y <- as.matrix(i[1])
x <- as.matrix(i[2:ncol(i)])
}
.
.
}
#
> i
[[1]]
ACAA2.hsa.miR.124.AGO2.hsa.miR.124.AGO134
1 7.6561 18.5924339201 23.4560035028
2 7.2355 26.2524888635 33.6513700944
3 7.365 23.6841865928 28.2168475593
4 8.4768 22.4003094419 28.0983702155
5 5.5838 20.4838449736 26.8616064228
6 7.3123 20.8488005184 26.9155966811
7 7.2345 21.5272944711 26.2954400309
8 7.05 23.3113502366 29.3856555269
> dim(i[1])
NULL
> dim(i[[1]])
[1] 67 1
> a<-i[[1]]
> dim(a)
[1] 67 1
> a
ACAA2.hsa.miR.124.AGO2.hsa.miR.124.AGO134
1 7.6561 18.5924339201 23.4560035028
2 7.2355 26.2524888635 33.6513700944
3 7.365 23.6841865928 28.2168475593
4 8.4768 22.4003094419 28.0983702155
5 5.5838 20.4838449736 26.8616064228
6 7.3123 20.8488005184 26.915596681
but I would expect
>dim(a)
67 3
Because I loses the dimension of data, my *for loop* doesn't work