====== Data sets ====== ===== Excel and CSV ===== Using Excel we prepare a data table as a spreadsheet {{ru:7iss:labs:excel.png}} and save it as a CSV (Comma Separated Values) file ''ex1.csv''. In it values are separated with semicolon ; . lab;U;V a;1;1 b;2;3 c;3;2 d;5;3 e;5;5 At the beginning of the file we can add some additional information - metadata. For example ''ex2.csv'' Example from 7ISS - June 2017 Vladimir Batagelj lab;U;V a;1;1 b;2;3 c;3;2 d;5;3 e;5;5 Such a file can be prepared also manually using some text editor, or as an output from some program. Using help(read.table) we learn that the right function for reading our file is read.csv2() and that we have to include some additional parameters: > H <- read.csv2("ex2.csv",skip=2,row.names=1) > H U V a 1 1 b 2 3 c 3 2 d 5 3 e 5 5 See also: - http://rprogramming.net/read-csv-in-r/ - https://stackoverflow.com/questions/3391880/how-to-get-a-csv-file-into-r Searching on Google we also learn that we could read into R also directly from the Excel file. - http://www.cookbook-r.com/Data_input_and_output/Loading_data_from_a_file/ - http://www.r-tutor.com/r-introduction/data-frame/data-import library(gdata) D <- read.xls("ex1.xls") ===== Fixed ===== In older data sets the fixed width format was often used. To read such data see - https://stackoverflow.com/questions/30085840/reading-fixed-width-format-file-in-r - https://stackoverflow.com/questions/24715894/faster-way-to-read-fixed-width-files-in-r ===== JSON ===== - [[https://cran.r-project.org/web/packages/jsonlite/vignettes/json-aaquickstart.html|Getting started with JSON and jsonlite]] - [[https://stackoverflow.com/questions/36454638/how-can-i-convert-json-to-data-frame-in-r|How can I convert Json to data frame in R ?]] - [[https://gist.github.com/gluc/5f780246d57897b57c6b|convert a nested JSON file to an R data.frame]] \\ \\ [[ru:7iss#labs|Back to 7ISS Labs]]