3.3 Techniques for data entry

Tab Delimited Text file

chem_as_txt <- read.delim("data6e/Chemical.txt", sep="\t")
head(chem_as_txt)
##   PE ROR5  DE SALESGR5 EPS5 NPM1 PAYOUTR1
## 1  9 13.0 0.7     20.2 15.5  7.2     0.43
## 2  8 13.0 0.7     17.2 12.7  7.3     0.38
## 3  8 13.0 0.4     14.5 15.1  7.9     0.41
## 4  9 12.2 0.2     12.9 11.1  5.4     0.57
## 5  5 10.0 0.4     13.6  8.0  6.7     0.32
## 6  6  9.8 0.5     12.1 14.5  3.8     0.51

Comma delimited text file

chem_as_csv <- read.csv("data6e/Chemical.csv")
head(chem_as_csv)
##   PE ROR5  DE SALESGR5 EPS5 NPM1 PAYOUTR1
## 1  9 13.0 0.7     20.2 15.5  7.2     0.43
## 2  8 13.0 0.7     17.2 12.7  7.3     0.38
## 3  8 13.0 0.4     14.5 15.1  7.9     0.41
## 4  9 12.2 0.2     12.9 11.1  5.4     0.57
## 5  5 10.0 0.4     13.6  8.0  6.7     0.32
## 6  6  9.8 0.5     12.1 14.5  3.8     0.51

Spreadsheet entry

library(readxl)
chem_as_xls <- read_excel("data6e/Chemical.xlsx")
head(chem_as_xls)
## # A tibble: 6 x 7
##      PE  ROR5    DE SALESGR5  EPS5  NPM1 PAYOUTR1
##   <dbl> <dbl> <dbl>    <dbl> <dbl> <dbl>    <dbl>
## 1     9  13     0.7     20.2  15.5   7.2     0.43
## 2     8  13     0.7     17.2  12.7   7.3     0.38
## 3     8  13     0.4     14.5  15.1   7.9     0.41
## 4     9  12.2   0.2     12.9  11.1   5.4     0.57
## 5     5  10     0.4     13.6   8     6.7     0.32
## 6     6   9.8   0.5     12.1  14.5   3.8     0.51

Files from other programming languages such as STATA, SAS and SPSS can be read in using the haven package.