Huiting — Mar 30, 2014, 5:34 PM
prDat <- read.table("GSE4051_MINI.txt", header = TRUE, row.names = 1)
str(prDat)
'data.frame': 39 obs. of 6 variables:
$ sample : int 20 21 22 23 16 17 6 24 25 26 ...
$ devStage : Factor w/ 5 levels "4_weeks","E16",..: 2 2 2 2 2 2 2 4 4 4 ...
$ gType : Factor w/ 2 levels "NrlKO","wt": 2 2 2 2 1 1 1 2 2 2 ...
$ crabHammer: num 10.22 10.02 9.64 9.65 8.58 ...
$ eggBomb : num 7.46 6.89 6.72 6.53 6.47 ...
$ poisonFang: num 7.37 7.18 7.35 7.04 7.49 ...
head(prDat)
sample devStage gType crabHammer eggBomb poisonFang
Sample_20 20 E16 wt 10.220 7.462 7.370
Sample_21 21 E16 wt 10.020 6.890 7.177
Sample_22 22 E16 wt 9.642 6.720 7.350
Sample_23 23 E16 wt 9.652 6.529 7.040
Sample_16 16 E16 NrlKO 8.583 6.470 7.494
Sample_17 17 E16 NrlKO 10.140 7.065 7.005
rownames(prDat)
[1] "Sample_20" "Sample_21" "Sample_22" "Sample_23" "Sample_16"
[6] "Sample_17" "Sample_6" "Sample_24" "Sample_25" "Sample_26"
[11] "Sample_27" "Sample_14" "Sample_3" "Sample_5" "Sample_8"
[16] "Sample_28" "Sample_29" "Sample_30" "Sample_31" "Sample_1"
[21] "Sample_10" "Sample_4" "Sample_7" "Sample_32" "Sample_33"
[26] "Sample_34" "Sample_35" "Sample_13" "Sample_15" "Sample_18"
[31] "Sample_19" "Sample_36" "Sample_37" "Sample_38" "Sample_39"
[36] "Sample_11" "Sample_12" "Sample_2" "Sample_9"
# Exercise: Why do we use the header = and row.names = arguments above upon import?
# Submit the command without these arguments and note any difference in the result.
# Form the habit of reading error messages carefully and working the problem.
# Mastering the arguments of read.table() and friends is time well spent.
prDat1 <- read.table("GSE4051_MINI.txt")
str(prDat1)
'data.frame': 39 obs. of 6 variables:
$ sample : int 20 21 22 23 16 17 6 24 25 26 ...
$ devStage : Factor w/ 5 levels "4_weeks","E16",..: 2 2 2 2 2 2 2 4 4 4 ...
$ gType : Factor w/ 2 levels "NrlKO","wt": 2 2 2 2 1 1 1 2 2 2 ...
$ crabHammer: num 10.22 10.02 9.64 9.65 8.58 ...
$ eggBomb : num 7.46 6.89 6.72 6.53 6.47 ...
$ poisonFang: num 7.37 7.18 7.35 7.04 7.49 ...
head(prDat1)
sample devStage gType crabHammer eggBomb poisonFang
Sample_20 20 E16 wt 10.220 7.462 7.370
Sample_21 21 E16 wt 10.020 6.890 7.177
Sample_22 22 E16 wt 9.642 6.720 7.350
Sample_23 23 E16 wt 9.652 6.529 7.040
Sample_16 16 E16 NrlKO 8.583 6.470 7.494
Sample_17 17 E16 NrlKO 10.140 7.065 7.005
rownames(prDat1)
[1] "Sample_20" "Sample_21" "Sample_22" "Sample_23" "Sample_16"
[6] "Sample_17" "Sample_6" "Sample_24" "Sample_25" "Sample_26"
[11] "Sample_27" "Sample_14" "Sample_3" "Sample_5" "Sample_8"
[16] "Sample_28" "Sample_29" "Sample_30" "Sample_31" "Sample_1"
[21] "Sample_10" "Sample_4" "Sample_7" "Sample_32" "Sample_33"
[26] "Sample_34" "Sample_35" "Sample_13" "Sample_15" "Sample_18"
[31] "Sample_19" "Sample_36" "Sample_37" "Sample_38" "Sample_39"
[36] "Sample_11" "Sample_12" "Sample_2" "Sample_9"
## I did not notice any difference, it might due to read.table default. Let's try make header = FALSE
prDat2 <- read.table("GSE4051_MINI.txt", header = FALSE)
Error: line 1 did not have 7 elements
str(prDat2)
Error: object 'prDat2' not found
head(prDat2)
Error: object 'prDat2' not found
## can't read it now