Hello, I've used select() as before, but it give me an error. I've also tried to use reprex to debug, but there is also a confused error. Thus, I turn to community for help.
The simplified data sets I used are:
g1
ID Age Gender HDL.g1 YZ.g1 HPX.g1 Status.g1
1 1 11 m 45.3 23.4 1 1
2 2 12 f 44.5 34.1 2 3
3 3 13 f 43.7 44.8 2 5
4 4 14 f 42.9 55.5 1 4
5 5 15 f 42.1 66.2 2 2
6 6 16 m 41.3 76.9 2 4
7 7 17 f 40.5 87.6 1 1
8 8 18 m 39.7 98.3 2 3
9 9 19 m 38.9 109.0 1 4
10 10 20 m 38.1 119.7 2 2
11 11 21 f 37.3 130.4 1 4
12 12 22 f 36.5 141.1 2 1
13 13 23 f 35.7 151.8 1 1
14 14 24 m 34.9 162.5 2 3
15 15 25 f 34.1 173.2 2 5
16 16 26 m 33.3 183.9 1 4
17 17 27 m 32.5 194.6 2 3
18 18 28 m 31.7 205.3 2 3
19 19 29 m 30.9 216.0 1 5
20 20 30 m 23.0 226.7 2 4
21 21 31 m 32.0 237.4 1 3
g2
ID Age Gender A.g2 B.g2 C.g2
1 18 16 m d -1 55.5
2 19 17 f c 0 66.2
3 20 18 m a 1 76.9
4 21 19 m b 1 87.6
5 22 24 m b 1 98.3
6 6 16 m a 1 109.0
7 7 17 f c 1 119.7
8 8 18 m a 1 44.5
9 9 19 m a -1 43.7
10 10 20 m c 0 42.9
11 11 21 f d 1 42.1
12 12 22 f a 1 41.3
13 13 23 f b 1 40.5
14 14 24 m b 1 39.7
15 15 25 f a 1 38.9
16 16 26 m c -1 38.1
17 17 27 m d 0 37.3
The following is my code:
m1 <- merge(x=g1,y=g2,by="ID",all = TRUE)
m2 <- merge(x=g1,y=g2,by="ID",all = FALSE)
matched_id = m2$ID # matched id between 2 groups
matched_id_num = length(m2$ID)
num_unmatched_id = nrow(m1) - nrow(m2) # unmatched id between 2 groups
m2_x <- select(m2, ends_with(".x"))
m2_x <- cbind(m2[,"ID"],m2_x)
m2_y <- select(m2, ends_with(".y"))
m2_y <- cbind(m2[,"ID"],m2_y)
The error is:
Error in select(m2, ends_with(".x")) : unused argument (ends_with(".x"))
I really have no idea to fix it. Hope anyone can help me:sob: