This should be a character string that specifies a path to the file that needs to be loaded. There are two arguments to this function, but the only one we’re interested in is The way I do this is with the load() function. Let’s say I want to load the data from this file into my workspace. When I used the list.files() command to list the contents of the /Users/dan/Rbook/data directory (in Section 4.4.2), the output referred to a file called booksales.Rdata. Throughout this section I’ll first describe the (sometimes awkward) R commands that do all the work, and then I’ll show you the (much easier) way to do it using Rstudio. In this section I’ll talk about how to load a workspace file, how to import data from a CSV file, and how to save your workspace to a workspace file. I’ll discuss some of these other possibilities elsewhere in this book (Section 7.9), but for now I want to focus primarily on the two kinds of data file that you’re most likely to need. R tries hard to play nicely with other software, so it has tools that let you open and work with any of these and many others. Finally, you might have to handle databases. For instance, you might want to open Microsoft Excel spreadsheets (.xlsx files), or data files that have been saved in the native file formats for other statistics software, such as SPSS, SAS, Minitab, Stata or Systat. There are also several other kinds of data file that you might want to import into R. There are also several other types of file that R makes use of, 52 but they’re not really all that central to our interests. They’re just text files, but we won’t make use of them until Chapter 8. ![]() These aren’t data files at all rather, they’re used to save a collection of commands that you want R to execute later. It’s quite typical for people to store data in CSV files, precisely because they’re so simple. These are just regular old text files, and they can be opened with almost any software.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |