UM-R-for-EnvSci-Registered-Student / General-Discussion

Public repo for general discussion about the course and assignments
1 stars 0 forks source link

NA's for facet grid labels #16

Closed Durell-S-Desmond closed 3 years ago

Durell-S-Desmond commented 3 years ago

I am having trouble getting the names write for the facet grid column labels. I was trying to use "labeller" function to adjust the original names. Any help would be much appreciated. Sorry for the last minute question!

I have attached the generated figure and corresponding code for the figure generation for reference...

B A

sullivandan commented 3 years ago

Here's what I did (I found this solution online here)

nutrient_labels <- c("Ammonia", "Nitrate", "Nitrite", "SRP", "Total N", "Total P")

This creates a variable with the desired nutrient labels

names(nutrient_labels) <- c("ammonia", "nitrate", "nitrite", "soluble_reactive_phosphorus_srp", 
"total_nitrogen_mixed_forms", "total_phosphorus_mixed_forms")

This then essentially assigns them to the names they're going to replace

Then for your line of code you would write (just be sure to use your respective variable names):

facet_grid(rows = vars(basin), cols = vars(nutrient), labeller = labeller(nutrient = nutrient_labels)) +
Durell-S-Desmond commented 3 years ago

Thank you! It worked...