we seldom create the data our selves, most of the time we read the data from file. there are many ways to read the data.
Reading from Raw data
Notice the V1, V2....... these are the default variables given by the R system , so to inclue the variable name from file
or to read the data first and assign variable name later,
in some rows there are missing data..
here "." does not mean missing value. it is the input from file, so to recognize it as missing value
the default separator of read.table is " ", you can always change this in parameter sep="," or any other else.
for a complete description type ?read.table in R interface.
there are variations in read.table such as read.csv, read.delim
The another common format of raw data is fixed width format. to read that you can use read.fwf
for example if fwf1.dat contains following data
Another primitive function to read data is scan() function
Most of the time we input our raw data in spreadsheet application such as MS Excel. What I do is save the data in csv or tab delimitated txt format and read through read.table function.
Another nice package to read data directly from Excel is xlsReadWrite. to import from Excel file directly,
for more information about the parameters and default values look at
further next time