Example: stock market

R Data Import/Export

R data Import/Export Version (2019-07-05). R Core Team This manual is for R, version (2019-07-05). Copyright c 2000 2018 R Core Team Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

1 Acknowledgements The relational databases part of this manual is based in part on an earlier manual by Douglas Bates and Saikat DebRoy. The principal author of this manual was Brian Ripley.

Tags:

  Data, Export, Import, Data import export

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of R Data Import/Export

1 R data Import/Export Version (2019-07-05). R Core Team This manual is for R, version (2019-07-05). Copyright c 2000 2018 R Core Team Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

2 Permission is granted to copy and distribute translations of this manual into an- other language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the R Core Team. i Table of Contents Acknowledgements .. 1. 1 Introduction .. 4. Imports .. 4. Encodings .. 5. export to text files.. 5. XML .. 7. 2 Spreadsheet-like data .. 8. Variations on .. 8. Fixed-width-format files.. 10. data Interchange Format (DIF) .. 10. Using scan directly .. 11. Re-shaping data .. 12.

3 Flat contingency tables .. 13. 3 Importing from other statistical systems .. 14. EpiInfo, Minitab, S-PLUS, SAS, SPSS, Stata, Systat .. 14. Octave .. 15. 4 Relational databases .. 16. Why use a database? .. 16. Overview of RDBMSs.. 16. SQL queries .. 17. data types .. 18. R interface packages .. 18. Packages using DBI .. 19. Package RODBC.. 20. 5 Binary files .. 22. Binary data formats .. 22. dBase files (DBF) .. 22. 6 Image files .. 23. 7 Connections .. 24. Types of connections .. 24. Output to connections .. 25. Input from connections.

4 25. Pushback .. 26. Listing and manipulating connections .. 26. Binary connections .. 26. Special values .. 27. ii 8 Network interfaces .. 28. Reading from sockets .. 28. Using .. 28. 9 Reading Excel spreadsheets .. 29. Appendix A References .. 30. Function and variable index.. 31. Concept index .. 33. 1. Acknowledgements The relational databases part of this manual is based in part on an earlier manual by Douglas Bates and Saikat DebRoy. The principal author of this manual was Brian Ripley. Many volunteers have contributed to the packages used here.

5 The principal authors of the packages mentioned are DBI David A. James (https: / /. CRAN . R-project . org /. package=DBI). dataframes2xls Guido van Steen (https: / /. CRAN . R-project . org /. package=dataframes2xls). foreign Thomas Lumley, Saikat DebRoy, Douglas Bates, Duncan (https: / / Murdoch and Roger Bivand CRAN . R-project . org /. package=foreign). gdata Gregory R. Warnes (https: / /. CRAN . R-project . org /. package=gdata). ncdf4 David Pierce (https: / /. CRAN . R-project . org /. package=ncdf4). rJava Simon Urbanek (https: / /.)

6 CRAN . R-project . org /. package=rJava). RJDBC Simon Urbanek (https: / /. CRAN . R-project . org /. package=RJDBC). Acknowledgements 2. RMySQL David James and Saikat DebRoy (https: / /. CRAN . R-project . org /. package=RMySQL). RNetCDF Pavel Michna (https: / /. CRAN . R-project . org /. package=RNetCDF). RODBC Michael Lapsley and Brian Ripley (https: / /. CRAN . R-project . org /. package=RODBC). ROracle David A, James (https: / /. CRAN . R-project . org /. package=ROracle). RPostgreSQL Sameer Kumar Prayaga and Tomoaki Nishiyama (https: / /.

7 CRAN . R-project . org /. package=RPostgreSQL). RSPerl Duncan Temple Lang RSPython Duncan Temple Lang RSQLite David A, James (https: / /. CRAN . R-project . org /. package=RSQLite). SJava John Chambers and Duncan Temple Lang WriteXLS Marc Schwartz (https: / /. CRAN . R-project . org /. package=WriteXLS). XLConnect Mirai Solutions GmbH. (https: / /. CRAN . R-project . org /. package=XLConnect). 3. XML Duncan Temple Lang (https: / /. CRAN . R-project . org /. package=XML). Brian Ripley is the author of the support for connections. 4.

8 1 Introduction Reading data into a statistical system for analysis and exporting the results to some other system for report writing can be frustrating tasks that can take far more time than the statistical analysis itself, even though most readers will find the latter far more appealing. This manual describes the import and export facilities available either in R itself or via packages which are available from CRAN or elsewhere. Unless otherwise stated, everything described in this manual is (at least in principle) available on all platforms running R.

9 In general, statistical systems like R are not particularly well suited to manipulations of large-scale data . Some other systems are better than R at this, and part of the thrust of this manual is to suggest that rather than duplicating functionality in R we can make another system do the work! (For example Therneau & Grambsch (2000) commented that they preferred to do data manipulation in SAS and then use package survival ( org/package=survival) in S for the analysis.) Database manipulation systems are often very suitable for manipulating and extracting data : several packages to interact with DBMSs are discussed here.

10 There are packages to allow functionality developed in languages such as Java, perl and python to be directly integrated with R code, making the use of facilities in these languages even more appropriate. (See the rJava ( ) package from CRAN and the SJava, RSPerl and RSPython packages from the Omegahat project, http://. ). It is also worth remembering that R like S comes from the Unix tradition of small re-usable tools, and it can be rewarding to use tools such as awk and perl to manipulate data before import or after export . The case study in Becker, Chambers & Wilks (1988, Chapter 9) is an example of this, where Unix tools were used to check and manipulate the data before input to S.


Related search queries