[R] How to create a vector by searching information in multiple data.tables in r?
Ioanna Ioannou
||54250 @end|ng |rom m@n@com
Fri Jan 31 19:06:00 CET 2020
Hello everyone,
Once again i am a bit stack. I have over 200 json files with information. I managed to manipulate them and their format is rather difficult as shown below. Unfortunately, not all these files contain the same fields. I want to extract e.g., the country from all these files. How can i add NA for the files for which the country is not mentioned?
Here is a reproducible example. Lets say i have two files, three files, two provide the country and the one does not. essentially i want a vector called country which will look like this:
Country <- c('Colombia', 'Greece', NA)
Any help much appreciated!
Best,
ioanna
A<- data.frame( name1 = c('fields', 'fields', 'fields'),
name2= c('category', 'asset', 'country'),
value = c('Structure Class', 'Building', 'Colombia')
B<- data.frame( name1 = c('fields', 'fields', 'fields'),
name2= c('category', 'asset', 'country'),
value = c('Structure Class', 'Building', 'Greece')
C<- data.frame( name1 = c('fields', 'fields', 'fields'),
name2= c('category', 'asset', 'assessment'),
value = c('Structure Class', 'Building', 'Fragility')
[[alternative HTML version deleted]]
More information about the R-help
mailing list