Error in sort.list(y) ?

#1
I downloaded a dataset from the following link
https://archive.ics.uci.edu/ml/datasets/human+activity+recognition+using+smartphones

This is what I did in R, but got an error after i typed in the code use.train. what shall i do to deal with the error? Thanks very much.

use.test.x<-read.table(file.choose())
use.train.x<-read.table(file.choose())
use.train.y<-read.table(file.choose())
use.test.y<-read.table(file.choose())
use.train <- cbind(use.train.x, Outcome = factor(use.train.y))
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?
 

Dason

Ambassador to the humans
#2
Using factor on a table/data.frame is what is giving you the error. Is use.train.y a single column? If so coerce it to a vector before calling factor on it.
 

bryangoodrich

Probably A Mammal
#4
I downloaded a dataset from the following link
https://archive.ics.uci.edu/ml/datasets/human+activity+recognition+using+smartphones

This is what I did in R, but got an error after i typed in the code use.train. what shall i do to deal with the error? Thanks very much.

use.test.x<-read.table(file.choose())
use.train.x<-read.table(file.choose())
use.train.y<-read.table(file.choose())
use.test.y<-read.table(file.choose())
use.train <- cbind(use.train.x, Outcome = factor(use.train.y))
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?
I hope you're not doing file.choose repeatedly like that in your usable code.

If so, it is better to store that in a variable; if you have to rerun the code, you don't have to manually choose the file each time

Code:
# Run once
train.x.src <- file.choose()  # select the training x set
foo <- file.choose()  # another file
bar <- file.choose()  # another file
...

# Run many
use.train.x <- read.table(train.x.src)
foo.x <- read.table(foo)
bar.x <- read.table(bar)
Now you only need to rerun the read.table statements and call the file.choose block once to choose your data sources during interactive sessions.