0

I have the following

remove(list = ls())
train <- read.csv("RegressionTrain.csv" )
library(dplyr)
df <- as.data.frame.matrix(train)
arrange(df$No.Cylinders) %>% glimpse()

I get

Error in UseMethod("arrange_"): no applicable method for 'arrange_' applied to an object of class "c('integer', 'numeric')"
Traceback:

1. arrange(df$No.Cylinders) %>% glimpse()
2. eval(lhs, parent, parent)
3. eval(lhs, parent, parent)
4. arrange(df$No.Cylinders)
5. arrange.default(df$No.Cylinders)
6. arrange_(.data, .dots = compat_as_lazy_dots(...))

A similar problem occurs if I try to arrange data$No.Cylinders hence I tried creating a data frame.

Kirsten
  • 15,730
  • 41
  • 179
  • 318
  • 1
    `df %>% arrange(No.Cylinders)` BTW `train` is already a dataframe so `train %>% arrange(No.Cylinders)` should work as well. – Ronak Shah Nov 05 '20 at 12:25
  • Thats it! Thank you. Would you like to write it up or should I delete the question? – Kirsten Nov 05 '20 at 12:29
  • You can keep the question, I marked it as a dupe of this broad general question https://stackoverflow.com/questions/1296646/how-to-sort-a-dataframe-by-multiple-columns – Ronak Shah Nov 05 '20 at 12:41

0 Answers0