I am trying to read in this data, but can't load in successfully, what is the problem?
height <- data.table::fread('http://www.stat.nthu.edu.tw/~swcheng/Teaching/stat5410/data/height.txt')
height
Warning message:
In data.table::fread("http://www.stat.nthu.edu.tw/~swcheng/Teaching/stat5410/data/height.txt") :
Stopped early on line 3. Expected 5 fields but found 3. Consider fill=TRUE and comment.char=. First discarded non-empty line: <<62 65.5 2>>
CodePudding user response:
It's header is pretty weird, you may try(There might be better options)
x <- read.table(url('http://www.stat.nthu.edu.tw/~swcheng/Teaching/stat5410/data/height.txt'), skip = 2, header= F)
names(x) <- c("Height of Father", "Average Height of Son", "# of Fathers")
x
Height of Father Average Height of Son # of Fathers
1 62 65.5 2
2 63 66.5 6
3 64 66.8 12
4 65 66.8 19
5 66 67.6 27
6 67 67.8 26
7 68 68.6 26
8 69 69.1 26
9 70 69.5 20
10 71 70.6 15
11 72 70.3 8
12 73 72.0 5