I have two data frames:
geodata<-read.csv(text='postalcode;latitude;longitude
7000;47.8415;16.5041
7000;47.8921;16.4011
7000;47.9400;16.5032
7071;47.8012;16.671
2443;47.9156;16.5179', sep=';', header=TRUE)
addresses<-read.csv(text='postalcode;address
2400;Lorem ipsum
7000;Dolor sit amet
2443;Consetetur sadipscing elitr
7000;Sed diam nonumy', sep=';', header=TRUE)
What I would need is two additional columns in the addresses dataframe with the corresponding (first match when multiple postalcodes rows exist) geodata$latitude and geodata$longitude values.
How to join (merge) data frames (inner, outer, left, right)? shows nearly what I'm looking for except that I don't want duplicated lines in the merged dataframe.
I tried something like
# code not working... #
addresses$latitude<-geodata[addresses$postalcode==geodata$postalcode]
which I know is really ugly :-(