I am trying to translate to spanish the organs names in gganatogram package, a R package to plot anatograms and tissues based on ggplot2.
This run ok:
library(dplyr)
library(ggplot2)
library(gridExtra)
library(gganatogram)
I did check names and objects
str(hgMale_key)
'data.frame': 68 obs. of 4 variables:
$ organ : chr "thyroid_gland" "bone_marrow" "frontal_cortex"
"prefrontal_cortex" ...
$ type : chr "other" "other" "nervous_system" "nervous_system" ...
$ colour: chr "#41ab5d" "#41ab5d" "purple" "purple" ...
$ value : num 4.67 3.31 15.51 1.81 12.88 ...
hgMale_key%>%
filter(organ %in% c("liver", "heart", "prostate", "stomach",
"brain"))%>%
gganatogram(fillOutline="lightgray", organism="human", sex="male",
fill="value") theme_void()
##################################
I tried to translate
run ok:
hgMale_key$organ= gsub("liver", "higado",hgMale_key$organ)
This not run, the same last code to plot:
hgMale_key%>%
filter(organ %in% c("higado", "heart", "prostate", "stomach",
"brain"))%>%
gganatogram(fillOutline="lightgray", organism="human", sex="male",
fill="value") theme_void()
Error in stats::complete.cases(dat) : no input has determined the number of cases
CodePudding user response:
You would need to set up a look-up table to translate from the Spanish names to the English names of the organs (you'll need to check these, as I just ran the names through Google Translate):
es_key <- gganatogram::hgMale_key
es_key$organos <- c("glándula tiroides",
"médula ósea", "corteza frontal", "la corteza prefrontal",
"glándula pituitaria", "aorta", "unión_gastroesofágica",
"ventriculo izquierdo",
"intestino ciego", "ileon", "recto", "nariz", "seno", "lengua",
"Auricula izquierda", "válvula pulmonar", "la válvula mitral",
"pene", "faringe_nasal", "médula espinal", "garganta", "válvula tricúspide",
"diafragma", "higado", "estómago", "bazo", "duodeno", "vesicula biliar",
"páncreas", "colon", "intestino delgado", "apéndice", "músculo liso",
"vejiga_urinaria", "hueso", "cartilago", "esófago",
"glándula salival", "glándula parótida", "glándula submandibular",
"piel", "pleura", "cerebro", "corazón", "glándula suprarrenal",
"ganglio linfático", "tejido adiposo", "músculo esquelético",
"leucocito", "lóbulo temporal", "apéndice_auricular", "arteria coronaria",
"hipocampo", "vas_deferens", "vesicula seminal", "epididimo",
"amigdala", "pulmón", "amigdala", "tráquea", "bronquio", "nervio",
"cerebelo", "hemisferio_cerebeloso", "riñón", "corteza renal",
"testiculo", "próstata")
This allows you to do:
es_key %>%
filter(organos %in% c("higado", "estómago", "cerebro", "próstata")) %>%
gganatogram(fillOutline = "lightgray", organism = "human", sex = "male",
fill = "value")
theme_void()