Discussion: View Thread

  • 1.  Downloading R data sets to an R workplace

    Posted 08-30-2015 08:06

    I think I said that right: "Downloading R data sets to an R workplace".   I am wanting to work with standard datasets such as "Iris" dataset, etc.

     

    How do you down load them so that they are objects in R?

     

    Thanks,

     

    Greg



  • 2.  RE: Downloading R data sets to an R workplace

    Posted 08-30-2015 10:03

    The iris data already exists in the base R installation as data frames.  At the command prompt, type:

    iris

    or

    View(iris)

    to view the data.  The 2nd way presents info in a spreadsheet-style format.

    To view all the data sets that are part of the datasets package, you can use

    data()

    If you need to pull in data outside R, what is the most common format that you are opening?  Excel, comma or tab separated data, etc?


    ------------------------------
    Mark Lancaster
    Northern Kentucky University
    ------------------------------




  • 3.  RE: Downloading R data sets to an R workplace

    Posted 08-30-2015 10:43
    Yes, many common datasets are stored in base R, like IRIS and CARS.   I would look up in the R website which ones are available because they might change.  Also they are not stored in the working directory but somewhere in R.
     
    One of the big differences between R and classic packages like SAS and SPSS is that the data structure for the data frame is not a free-standing file.   Instead one or more R objects gets saved to an .RData file.   Think of the .RData file as a special folder for R objects.    I often name it by the date e.g. July17.RData, so I can go back and retrieve my work.      By default you have the option to save all your data frames, vectors and lists to the .RData file in the working directory upon exit.  But if you wish to read in a file and save it, use the save function and specify the name.   Then the next time you need a file, load that .RData file.    
     
    Someone I worked with saved all his data as functions.    The function would read in each raw file and was saved as code.    This was a little strange to me but had the advantage that he only had to deal with the default .Rdata file.
     
    I don't want to be responsible for writing R code so the best thing to do is to get a book that focuses on R for your particular need.  Also Stackoverflow.com is a good place for specific queries.  Type '[R] keyword' where keyword is the name of a function or a phrase.   Also  www.statmethods.net is a good general resource.    
     
    R is a confusing and the documentation is not for beginners.   So have patience and it will become fun.
     
    Kind regards,
     
     
    Georgette Asherman


    ------Original Message------

    The iris data already exists in the base R installation as data frames.  At the command prompt, type:

    iris

    or

    View(iris)

    to view the data.  The 2nd way presents info in a spreadsheet-style format.

    To view all the data sets that are part of the datasets package, you can use

    data()

    If you need to pull in data outside R, what is the most common format that you are opening?  Excel, comma or tab separated data, etc?


    ------------------------------
    Mark Lancaster
    Northern Kentucky University
    ------------------------------




  • 4.  RE: Downloading R data sets to an R workplace

    Posted 08-30-2015 10:48

    You should just do data(iris), for example. You can also do data() to see a list of available data setsin R and various installed packages. Then, the first time you refer to the dataset (eg, head(iris)), the data set is loaded as a data frame in your global R workspace.



    ------Original Message------

    Yes, many common datasets are stored in base R, like IRIS and CARS.   I would look up in the R website which ones are available because they might change.  Also they are not stored in the working directory but somewhere in R.
     
    One of the big differences between R and classic packages like SAS and SPSS is that the data structure for the data frame is not a free-standing file.   Instead one or more R objects gets saved to an .RData file.   Think of the .RData file as a special folder for R objects.    I often name it by the date e.g. July17.RData, so I can go back and retrieve my work.      By default you have the option to save all your data frames, vectors and lists to the .RData file in the working directory upon exit.  But if you wish to read in a file and save it, use the save function and specify the name.   Then the next time you need a file, load that .RData file.    
     
    Someone I worked with saved all his data as functions.    The function would read in each raw file and was saved as code.    This was a little strange to me but had the advantage that he only had to deal with the default .Rdata file.
     
    I don't want to be responsible for writing R code so the best thing to do is to get a book that focuses on R for your particular need.  Also Stackoverflow.com is a good place for specific queries.  Type '[R] keyword' where keyword is the name of a function or a phrase.   Also  www.statmethods.net is a good general resource.    
     
    R is a confusing and the documentation is not for beginners.   So have patience and it will become fun.
     
    Kind regards,
     
     
    Georgette Asherman




  • 5.  RE: Downloading R data sets to an R workplace

    Posted 08-30-2015 11:54

    library(datasets)

    will attach the datasets package.  Then you can use the object

    iris

    just like it is in your workspace. 

    library(help=datasets)

    will give a list of the contents of datasets.


    ------------------------------
    Margot Tollefson
    Consultant
    Vanward Statistics
    ------------------------------




  • 6.  RE: Downloading R data sets to an R workplace

    Posted 08-30-2015 23:28

    Thank you

     



    ------Original Message------

    library(datasets)

    will attach the datasets package.  Then you can use the object

    iris

    just like it is in your workspace. 

    library(help=datasets)

    will give a list of the contents of datasets.


    ------------------------------
    Margot Tollefson
    Consultant
    Vanward Statistics
    ------------------------------