我正在尝试导入以下文本文件:
"year" "sex" "name" "n" "prop"
"1" 1880 "F" "Mary" 7065 0.0723835869064085
"2" 1880 "F" "Anna" 2604 0.0266789611187951
"3" 1880 "F" "Emma" 2003 0.0205214896777829
"4" 1880 "F" "Elizabeth" 1939 0.0198657855642641
"5" 1880 "F" "Minnie" 1746 0.0178884278469341
"6" 1880 "F" "Margaret" 1578 0.0161672045489473
"7" 1880 "F" "Ida" 1472 0.0150811946109318
"8" 1880 "F" "Alice" 1414 0.0144869627580554
"9" 1880 "F" "Bertha" 1320 0.0135238973413247
"10"1880 "F" "Sarah" 1288 0.0131960452845653
我没有任何问题使用:
data <-read.table("~/Documents/baby_names.txt",header=TRUE,se="\t")
但是,我还没有弄清楚如何使用 readr 来做到这一点。以下命令失败:
data2 <-read_tsv("~/Documents/baby_names.txt")
我知道问题与第一行包含五个元素(标题)和其余 6 个的事实有关,但我不知道如何告诉读者忽略“1”、“2”、“3”等上。有什么建议么?