4
good morning I would like to create a histogram with 26 species in the x-axis and the percentage of influence of commercial hunting in the reduction of each species (column 'depletion_rate') on the y axis. I would also like to superimpose the histograms with a certain transparency according to the trophic level of each species, that is, there would be 3 overlapping histograms referring to the herb, oni and Carn levels. I don’t know how to put these 3 columns in my script. I have tried several ways, but the most I can is to plot two variables.
Note: I didn’t want to organize the table by placing each trophic level in a column because several lines would be empty, after all a species can only belong to a trophic level.
library(ggplot2)
head(CAUSA_FINAL_FB)
Dataset<-CAUSA_FINAL_FB
# Overlaid histograms
ggplot(Dataset, aes(x=specie, fill=trofic) +
geom_histogram(binwidth=.5, alpha=.5, position="identity")
trophic depletion_rate specie
carn 0.8 Lept_serv
carn 0.8 Lyc_pict
carn 1.6 Can_mes
carn 18.4 Pant_pa
carn 11.2 Oryct_afer
carn 51.2 Croc_croc
carn 0 Pant_le
herb 72 Thry_swin
herb 23.2 Hys_afri
herb 48 Sylv_grim
herb 100 Trag_scri
herb 100 Red_aru
herb 14.4 Hipp_eq
herb 16 Trag_oryx
herb 81.6 Sync_caf
herb 1.6 Lox_afric
oni 7.2 Otol_cras
oni 1.6 Miop_tal
oni 14.4 Lep_cap
oni 0 Genet_gen
oni 20.8 Phil_mont
oni 72.8 Chlor_cyn
oni 5.6 Cerc_mit
oni 43.2 Civet_civ
oni 100 Pota_larv
oni 22.4 Hipp_amph
Hello @Fran Braga. In this case, I imagine that the most appropriate is the bar chart, agree? All your data was the one you put in the question?
– Guilherme Parreira
Hey Guilherme I have more columns referring to other causes, but I thought of setting a frame for each cause by the facet_wrap() command. Thank you so much for the suggestion (I’m wondering, why didn’t I think of this instead of insisting on the histogram rsrsrs).
– Fran Braga