Importing Data File

To read in tabular data (e.g., .txt file), use read.table().

* Run ?read.table to see specific arguments in the function

If data is in .csv format, use read.csv().

To import data in other formats (such as SPSS data files), use functions in foreign package.

After importing the data file, you can check whether you have correctly read in the data. Below are some example functions to use.

##   method score
## 1      1    35
## 2      1    23
## 3      1    14
## 4      1    17
## 5      1    23
## 6      1    35
##    method score
## 1       1    35
## 2       1    23
## 3       1    14
## 4       1    17
## 5       1    23
## 6       1    35
## 7       1    27
## 8       1    33
## 9       1    32
## 10      1    31
##    method score
## 15      2    39
## 16      2    45
## 17      2    31
## 18      2    40
## 19      2    25
## 20      2    32
## 'data.frame':	20 obs. of  2 variables:
##  $ method: num  1 1 1 1 1 1 1 1 1 1 ...
##  $ score : num  35 23 14 17 23 35 27 33 32 31 ...
##      method        score      
##  Min.   :1.0   Min.   :14.00  
##  1st Qu.:1.0   1st Qu.:26.50  
##  Median :1.5   Median :32.00  
##  Mean   :1.5   Mean   :31.50  
##  3rd Qu.:2.0   3rd Qu.:35.25  
##  Max.   :2.0   Max.   :51.00
## $names
## [1] "method" "score" 
## 
## $class
## [1] "data.frame"
## 
## $row.names
##  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
## [1] "method" "score"
## [1] 20  2
## [[1]]
##  [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15"
## [16] "16" "17" "18" "19" "20"
## 
## [[2]]
## [1] "method" "score"
## [1] 20
## [1] 2
## [1] "data.frame"