Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning in xtfrm.data.frame(x) : cannot xtfrm data frames: error while ordering a dataframe numerically in R

I started learning R a couple of weeks ago, so I'm still very very new to R coding; I was trying to order a dataframe numerically, but on top of the ordered dataframe, resulted from the execution of the function order(nameofthedataframe), it appears "Warning in xtfrm.data.frame(x) : cannot xtfrm data frames". Could please anyone tell me what did I do wrong?

Thank you very much!

Examples:

order(iris[,"Petal.Width"]) # this seems fine
order(iris[,"Petal.Width",drop=FALSE]) # warning
order(iris[,c("Petal.Width","Sepal.Width")]) # warning

R version 4.1.0

like image 702
Beth Avatar asked Apr 10 '26 11:04

Beth


1 Answers

I am using the R version 4.1.0 and it seems like the order() function comes with an error check as you pointed out. You may still try using the order() function as follows,

order(dataframe[,"column"])

Here is a link to an alternative method in an article titled "It Has Always Been Wrong to Call order on a data.frame" by jmount 1

like image 133
BEATHUB Avatar answered Apr 12 '26 00:04

BEATHUB