我有以下数据框,我想按第五列(“距离”)排序。当我尝试`
df.order <- df[order(df[, 5]), ]
我总是收到以下错误消息。
Error in order(df[, 5]) : unimplemented type 'list' in 'orderVector1'`
我不知道为什么 R 将我的数据框视为列表。运行is.data.frame(df)
返回TRUE
。我不得不承认,is.list(df)
也有回报TRUE
。是否可以强制我的数据框只是一个数据框而不是列表?谢谢你的帮助。
structure(list(ID = list(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
Latitude = list(50.7368, 50.7368, 50.7368, 50.7369, 50.7369, 50.737, 50.737, 50.7371, 50.7371, 50.7371),
Longitude = list(6.0873, 6.0873, 6.0873, 6.0872, 6.0872, 6.0872, 6.0872, 6.0872, 6.0872, 6.0872),
Elevation = list(269.26, 268.99, 268.73, 268.69, 268.14, 267.87, 267.61, 267.31, 267.21, 267.02),
Distance = list(119.4396, 119.4396, 119.4396, 121.199, 121.199, 117.5658, 117.5658, 114.9003, 114.9003, 114.9003),
RxPower = list(-52.6695443922406, -52.269130891243, -52.9735258244422, -52.2116571930007, -51.7784534281727, -52.7703448813654, -51.6558862949081, -52.2892907635308, -51.8322993596551, -52.4971436682333)),
.Names = c("ID", "Latitude", "Longitude", "Elevation", "Distance", "RxPower"),
row.names = c(NA, 10L), class = "data.frame")