Difficulty merging data.frames with different row names and dplyr in R 4.3
I'm learning this framework and I'm trying to merge two data frames using `dplyr::full_join()`, but I'm running into issues because the row names in both data frames are different, and I suspect this is affecting the merge... Here's a simplified version of my data frames: ```r # Data frame A A <- data.frame(value = c(1, 2, 3), row.names = c('a', 'b', 'c')) # Data frame B B <- data.frame(value = c(4, 5), row.names = c('x', 'y')) ``` When I attempt to merge the two frames using: ```r library(dplyr) result <- full_join(A, B, by = "row.names") ``` I receive the following warning message: ``` Warning message: In `full_join()`: A row name in `x` was not found in `y`. ``` I expect the resulting data frame to retain all the rows from both data frames, but it seems like the row names are causing issues. I've tried resetting the row names of both data frames to avoid this, but it didn't help. Here's what I attempted: ```r A_clean <- A %>% rownames_to_column(var = "id") B_clean <- B %>% rownames_to_column(var = "id") result <- full_join(A_clean, B_clean, by = "id") ``` However, the output still doesn't give me meaningful results: ``` id value.x value.y 1 a 1 NA 2 b 2 NA 3 c 3 NA 4 x NA 4 5 y NA 5 ``` Instead of getting a combined data frame that shows all values, Iām getting a lot of `NA`s. Is there a better way to merge these data frames while ensuring I keep all values intact? This is my first time working with R latest. I'd be grateful for any help.