+ Reply to Thread
Results 1 to 4 of 4

Thread: Error in sort.list(y) ?

  1. #1

    Error in sort.list(y) ?




    I downloaded a dataset from the following link
    https://archive.ics.uci.edu/ml/datas...ng+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?

  2. #2
    Devorador de queso
    Points: 97,456, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Posting AwardCommunity AwardDiscussion EnderFrequent PosterActivity Award
    Dason's Avatar
    Location
    Tampa, FL
    Posts
    12,982
    Thanks
    308
    Thanked 2,639 Times in 2,254 Posts

    Re: Error in sort.list(y) ?

    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.
    I don't have emotions and sometimes that makes me very sad.

  3. The Following User Says Thank You to Dason For This Useful Post:

    t.wang21@yahoo.com.au (07-19-2017)

  4. #3
    Points: 7,325, Level: 56
    Level completed: 88%, Points required for next Level: 25

    Posts
    116
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Re: Error in sort.list(y) ?

    Thanks very much. yes I think this is the reason. How to convert a single column (use.train.y) into a vector? Thanks a lot.

  5. #4
    Probably A Mammal
    Points: 32,065, Level: 100
    Level completed: 0%, Points required for next Level: 0
    bryangoodrich's Avatar
    Location
    Sacramento, California, United States
    Posts
    2,567
    Thanks
    398
    Thanked 618 Times in 551 Posts

    Re: Error in sort.list(y) ?


    Quote Originally Posted by t.wang21@yahoo.com.au View Post
    I downloaded a dataset from the following link
    https://archive.ics.uci.edu/ml/datas...ng+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.
    You should definitely use jQuery. It's really great and does all things.

+ Reply to Thread

           




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats