数据框架中的因素和级别

时间:2017-10-02 07:32:50

标签: r dataframe

我正在尝试从我的数据中提取信息,我的数据框的一行如下所示:

str(data[[1]][143,3:10])
'data.frame':   1 obs. of  8 variables:
 $ NA..1: Factor w/ 86 levels "[Hz]","[m/s]",..: 73
 $ NA..2: Factor w/ 22 levels " ","[dB(A)]",..: 1
 $ NA..3: Factor w/ 18 levels " ","[-]","[kg/m³]",..: 1
 $ NA..4: Factor w/ 29 levels " ","[-]","[kg/m³]",..: 1
 $ NA..5: Factor w/ 19 levels "-"," ","[-]",..: 2
 $ NA..6: Factor w/ 14 levels "-"," ","[kg/m³]",..: 2
 $ NA..7: Factor w/ 14 levels " ","***=project specific tower heights applicable",..: NA
 $ NA..8: Factor w/ 20 levels " ","[kg/m³]",..: NA

当我执行以下操作时:

as.character(data[[2]][143,3])
[1] "Hub height"

as.character(data[[2]][143,4])
[1] "80 m"

as.character(data[[2]][143,5])
[1] "90 m"

as.character(data[[2]][143,6])
[1] " "

结果很好并且返回我想要的但是当我把所有这些放在一起时:

as.character(data[[2]][143,3:6])
[1] "88" "30" "81" "1"

它不再起作用了?!!! 我对此没有任何解释!我怎么能纠正这种行为?

0 个答案:

没有答案