我必须从这些链接获取数据集: cmu:http://lib.stat.cmu.edu/S/Harrell/data/descriptions/titanic.html 讨价还价:https://www.kaggle.com/c/titanic-gettingStarted/data
当我尝试合并它们时,我的右侧列重复,我可以解决这个问题吗?我试图将“票价”与人们进行比较。主要是试图学习合并。
cmu <- read.csv("titanic_cmu.txt")
kaggle <- read.csv("titanic_kaggle.csv")
tdata <- merge(cmu, kaggle)
输出:
> head(tdata)
row.names pclass survived name age embarked home.dest room ticket boat sex
1 1 1st 1 Allen, Miss Elisabeth Walton 29.0000 Southampton St Louis, MO B-5 24160 L221 2 female
2 2 1st 0 Allison, Miss Helen Loraine 2.0000 Southampton Montreal, PQ / Chesterville, ON C26 female
3 3 1st 0 Allison, Mr Hudson Joshua Creighton 30.0000 Southampton Montreal, PQ / Chesterville, ON C26 (135) male
4 4 1st 0 Allison, Mrs Hudson J.C. (Bessie Waldo Daniels) 25.0000 Southampton Montreal, PQ / Chesterville, ON C26 female
5 5 1st 1 Allison, Master Hudson Trevor 0.9167 Southampton Montreal, PQ / Chesterville, ON C22 11 male
6 6 1st 1 Anderson, Mr Harry 47.0000 Southampton New York, NY E-12 3 male
PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Fare Cabin Embarked
1 1 0 3 Braund, Mr. Owen Harris male 22 1 0 A/5 21171 7.25 S
2 1 0 3 Braund, Mr. Owen Harris male 22 1 0 A/5 21171 7.25 S
3 1 0 3 Braund, Mr. Owen Harris male 22 1 0 A/5 21171 7.25 S
4 1 0 3 Braund, Mr. Owen Harris male 22 1 0 A/5 21171 7.25 S
5 1 0 3 Braund, Mr. Owen Harris male 22 1 0 A/5 21171 7.25 S
6 1 0 3 Braund, Mr. Owen Harris male 22 1 0 A/5 21171 7.25 S