#Rcoding

Dillon Jones - Biologistdillonthebiologist
2023-05-15

Discovered a great solution for multiple, exact word, find and replace!

Still multiple lines, but is far simpler and easier to read than the many lines of gsub() I was doing

Side note: What is the standard Text for images of code? I just placed the code in there, but im not sure if thats best practice?

I would embed in the post, but this instance doesnt have code embed (I assume). Thanks!

A screenshot of code from Rstudio that is meant to find replace. The code supplied has turtle taxonomy that is being changed to fix typos or updated taxonomy

The Code is as follows: 

shp_sp %>%
  mutate(species = species%>%tolower())%>%
  mutate(species = case_when(
    str_detect(species,"kinosternon.h") ~ "kinosternon.hirtipes",
    str_detect(species,"chelus.fimbriata") ~ "chelus.fimbriatus",
    str_detect(species,"homopus.signatus") ~ "chersobius.signatus",
    str_detect(species,"homopus.boulengeri") ~ "chersobius.boulengeri",
    str_detect(species,"homopus.solus") ~ "chersobius.solus",
    str_detect(species,"mesoclemmys.gibba") ~ "mesoclemmys.gibbus",
    str_detect(species,"cyclemys.oldhami") ~ "cyclemys.oldhamii",
    TRUE ~ species
  )) -> shp_sp
Dillon Jones - Biologistdillonthebiologist
2023-05-09

My took 7 hours to run only to immediately crash upon completion, erasing its own results

My is the pinnacle of the useless box

2022-11-27

Do you like to make maps like me or do you want to learn how to make them? I found some tutorials for those interested in making beautiful maps using R. They are free access and very understandable.

#R #Rcoding #ggplot2 #codingisfun #tidyverse #terra #osmdata #httr #XML #codinglife #giscoR #metr #elevatr #sundaymood

Link: milospopovic.net/blog

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst