转置后,R数据帧行名称变为空

时间:2018-02-20 21:31:12

标签: r dataframe transpose

R studio包含一个内置的数据帧mtcars,我们可以从中看到行名称

> row.names(mtcars)

 [1] "Mazda RX4"           "Mazda RX4 Wag"      
 [3] "Datsun 710"          "Hornet 4 Drive"     
 [5] "Hornet Sportabout"   "Valiant"            
 [7] "Duster 360"          "Merc 240D"          
 [9] "Merc 230"            "Merc 280"           
[11] "Merc 280C"           "Merc 450SE"         
[13] "Merc 450SL"          "Merc 450SLC"        
[15] "Cadillac Fleetwood"  "Lincoln Continental"
[17] "Chrysler Imperial"   "Fiat 128"           
[19] "Honda Civic"         "Toyota Corolla"     
[21] "Toyota Corona"       "Dodge Challenger"   
[23] "AMC Javelin"         "Camaro Z28"         
[25] "Pontiac Firebird"    "Fiat X1-9"          
[27] "Porsche 914-2"       "Lotus Europa"       
[29] "Ford Pantera L"      "Ferrari Dino"       
[31] "Maserati Bora"       "Volvo 142E"         

当转换此数据帧时,我希望将这些行名称视为列名。

  

tmtcars< - t(mtcars)

看起来不错,

> names(tmtcars)

NULL

任何人都可以给我任何建议,为什么我没有得到预期的名字?

0 个答案:

没有答案