rurlreadrread-data

Read data in a url in R


I want to read the data in the following url into R but I couldn't do it. Does anyone have any idea about it?? Thanks! http://web.stanford.edu/~hastie/ElemStatLearn/ I need the data Ozone


Solution

  • The data is hosted at http://web.stanford.edu/~hastie/ElemStatLearn/datasets/ozone.data

    The values are tab-separated, so you can read it using read_tsv from the readr package:

    library(readr)
    read_tsv("http://web.stanford.edu/~hastie/ElemStatLearn/datasets/ozone.data")
    

    This will read the data directly from the website, so you won't need to download it manually yourself.