I have arranged two different datasets in the column format:
Dataset 1:
ABCDE13 1 1.7 2 1 13 2 5.3 2 1 13 2 2 2 1 13 2 1.8 2 1 1 6 27 9 1 1 6 6.6 9 1 1 7 17 9 1 1 7 7.1 9 1 1 7 8.5 9 1 Dataset 2:
ABFG 13 1 42 1002 13 2 42 1002 13 2 42 1002 13 2 42 1002 13 3 42 1002 13 4 42 1002 13 5 42 1002 1 2 27 650 1 3 27 650 1 4 27 650 1 6 27 650 1 7 27 650 1 7 27 650 1 7 27 650 1 8 27 650 Row numbers are variables in both datasets, but they contain data for two samples (for example, column A: 13 and both days 1) of Tatas. I would like to have CD and E values of dataset 1 in Dataset 2, who have the same value as A and B in both datasets. Therefore, should be based on A and B. I need to do this for 47560 rows.
I am new in R, so be grateful if I can get the code to save the newly merged dataset in R.
Use the merge function in R
From the reference:
EDIT: At first you will need to read in the dataset, CSV is a good format
& gt; Dataset 1 & lt; - read.csv (file = "dataset1.csv", head = TRUE, sep = ",") & gt; Dataset2 & lt; - read.csv (file = "dataset2.csv", head = TRUE, sep = ",") If you just type the variable name and you should enter your dataset If you see a reading-out of ...
& gt; Dataset 1 should read your data above. Then I believe that the following should be done ... I may be wrong ...
& gt; Dataset 1_2 & lt; - Merge (dataset 1, dataset 2, by = C ("A", "B")) Edit 2:
> ; Write.table (dataset1_2, "c: /dataset1_2.txt", sep = "") context:
No comments:
Post a Comment