Weird data issue

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1053
    d1234
    Member

    Hi,

    > milk = read.csv("http://robjhyndman.com/mwh3/data/milk.csv", head=F)
    > head(milk)
    V1
    1 589
    2 561
    3 640
    4 656
    5 727
    6 697
    > head(ts(milk))
    [1] 10 2 27 30 58 43

    I don’t understand why the data gets “distorted” when creating the time series.
    I was expecting head(ts(milk)) to give 589,561, …

    #1054
    d1234
    Member

    I figured it out.
    Because the last data row is “bad” (is a string “84323”), ‘R’ interprets the set as a “factor”.
    The conversion of the “factor” type to time series, gives no warnings but the result is meaningless.

    #1055
    bryan
    Participant

    Glad you got it figured out. The stringAsFactors=TRUE is one of the most inexplicable defaults I’ve encountered.

    Here’s an interesting, short and relevant Stack Overflow question:

    http://stackoverflow.com/questions/8177921/how-to-disable-stringsasfactors-true-in-data-frame-permenantly

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.