给出age.txt, teeth.txt的前几行,取自于一位具有统计思想的牙医的数据库:
在R里编写程序,首先读入每个文件,然后合并成一个列表写入到age_teeth.txt, 使得具有下列形式:
age <- read.table(file = "data/age.txt",header = TRUE) teeth <- read.table(file = "data/teeth.txt", header = TRUE, sep = " ") Age <- age$Age ID <- age$ID Num.Teeth <- teeth$Num.Teeth age_teeth <- data.frame(ID, Age, Num.Teeth) write.table(age_teeth, file = "data/age_teeth.txt", col.names = NA, quote = FALSE)