如何从R中的结构对象中提取数值

Cla*_*Meo 6 structure r numeric names

我需要从变量中提取数值,该变量是一个结合了数值和名称的结构

structure(c(-1.14332132657709, -1.1433213265771, -1.20580568266868, 
-1.75735158849487, -1.35614113300058), .Names = c("carbon", 
"nanotubes", "potential", "neuron", "cell", "adhesion"))
Run Code Online (Sandbox Code Playgroud)

最后,我想有一个载有这个信息的载体

c(-1.14332132657709, -1.1433213265771, -1.20580568266868, 
-1.75735158849487, -1.35614113300058)
Run Code Online (Sandbox Code Playgroud)

我该怎么做?非常感谢

Dir*_*tel 8

两者as.numeric()unname()做到这一点:

R> structure(c(-1.14332132657709, -1.1433213265771, -1.20580568266868,
+              -1.75735158849487, -1.35614113300058, NA),
+            .Names = c("carbon", "nanotubes", "potential", 
+            "neuron", "cell", "adhesion"))
   carbon nanotubes potential    neuron      cell  adhesion 
 -1.14332  -1.14332  -1.20581  -1.75735  -1.35614        NA 
R> foo
   carbon nanotubes potential    neuron      cell  adhesion 
 -1.14332  -1.14332  -1.20581  -1.75735  -1.35614        NA 
R>
R> as.numeric(foo)            ## still my 'default' approach
[1] -1.14332 -1.14332 -1.20581 -1.75735 -1.35614       NA
R>
R> unname(foo)                ## maybe preferable though
[1] -1.14332 -1.14332 -1.20581 -1.75735 -1.35614       NA
R> 
Run Code Online (Sandbox Code Playgroud)