X-Git-Url: https://code.communitydata.science/covid19.git/blobdiff_plain/ff96d52cb92966dd0c487e6452aeab70773cf3e6..576d882c04b4cc784cd5a6296cb3c3e5aa596d39:/keywords/example_analysis/translations_example.R diff --git a/keywords/example_analysis/translations_example.R b/keywords/example_analysis/translations_example.R new file mode 100644 index 0000000..0f0342c --- /dev/null +++ b/keywords/example_analysis/translations_example.R @@ -0,0 +1,17 @@ +## example reading latest file straight from the server +df <- read.csv("https://covid19.communitydata.science/datasets/keywords/csv/latest.csv") + +## make the data more R-friendly +df$is.alt <- df$is_alt == "True" +df$is_alt <- NULL + +## find all translations for coronavirus +coronavirus.itemids <- df[ (tolower(df$label) == "coronavirus") & + (df$langcode == 'en') + ,"itemid"] + +## there are actually 5 item ids. The one referring to the family of virus is Q57751738 +coronavirus.translations <- df[df$itemid == "http://www.wikidata.org/entity/Q57751738",] + +## let's only look at non-aliases +print(coronavirus.translations[c(coronavirus.translations$is.alt == FALSE), c("label","langcode")])