1
在下面的代碼中,我想將3431933
的值從my_data
中的第一行第六列添加到new_data
對象。從數據框中獲取值並將其添加到新的數據框中
相反,它似乎是加入號碼2
。你們能幫我找出我要出錯的地方嗎,或者我的根本誤解可能是什麼?
我的代碼:
print(my_data);
new_data <- {};
my_row <- my_data[1,];
print(my_row[1,6]);
new_data <- rbind(new_data, c(my_row[1,6]));
print(new_data);
這裏就是我看到在打印輸出:
什麼在my_data
:
V1 V2 V3 V4 V5 V6 V7 V8
1 10705 indiv7_ACTGAC 2 270 271 3431933 3442637 <NA>
2 41094 indiv7_ACTGAC 2 886 891 10296043 10337136 10297027.1114
3 18841 indiv7_ACTGAC 2 3497 3498 41414296 41433136 <NA>
V9
1 <NA>
2 10335630.1686849
3 <NA>
什麼打印出來my_row[1,6]
:
[1] 3431933
Levels: 10296043 3431933 41414296
什麼打印出來new_data
:
[,1]
[1,] 2
在附註中,在'R'中不需要分號(除非你在一行中放置多行代碼) – 2013-03-22 18:43:58