Table of Contents

Data sets

Excel and CSV

Using Excel we prepare a data table as a spreadsheet

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:

Searching on Google we also learn that we could read into R also directly from the Excel file.

library(gdata)
D <- read.xls("ex1.xls")

Fixed

JSON

ru/7iss/labs/ds.txt · Last modified: 2017/06/20 02:19 by vlado
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki