How do i Match two columns of information?

Sorry another newbie question that is probably obvious but i've been trying too long and can't tell anything now!

two columns of information that i would like to match up
column_A column_second
s12345 London
s23456 Edinburgh
s34567 Glasgow

What is the best way to do this and for it to effect each entry of a particular number in column_A

Thank you for reading

Are you trying to do something like this?

library(dplyr, warn.conflicts = FALSE)
DF <- data.frame(ID = c("s23456", "s12345", "s23456", "s34567", "s12345"),
                 Value = 1:5)
CITIES <- data.frame(ID = c("s12345", "s23456", "s34567"),
                     City = c("London", "Edinburgh", "Glasgow"))
DF <- inner_join(DF, CITIES, by = "ID")
DF
#>       ID Value      City
#> 1 s23456     1 Edinburgh
#> 2 s12345     2    London
#> 3 s23456     3 Edinburgh
#> 4 s34567     4   Glasgow
#> 5 s12345     5    London

Created on 2020-08-08 by the reprex package (v0.3.0)

If you are trying to match "Column second" by "Column_A" with another table, then you can also try Joins in SQL.

library(sqldf)

df<- sqldf("select column_second from table1 inner join table2 on table1.Column_A=table2.Column_A"

Thank you i shall try that out.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.