dreamRs / esquisse

RStudio add-in to make plots interactively with ggplot2
https://dreamrs.github.io/esquisse
Other
1.78k stars 229 forks source link

Data missing once imported into esquisse #258

Closed SFreddi closed 7 months ago

SFreddi commented 1 year ago

When I import my original data frame to esquisse it works perfectly. However, when I create a new data frame in which I add new variables that categorise the data present in the original variables, a lot of values go missing. It must be something to do with how I manipulate my data (?)

FoodFalls_noblanks_norange <- read_csv("FoodFalls_noblanks_norange.csv")

Food_Falls_working <- FoodFalls_noblanks_norange %>% select(Species, Weight (kg), Scavenging rate kg/d, Depth (m), Temp (C), Salinity (Psu), O2 (ml/L)) %>% mutate(weight_range = cut(Weight (kg), breaks = c(0, 10, 100, Inf), labels = c("0-10", "10-100", ">100")), depth_range = cut(Depth (m), breaks = c(0, 200, 1000, Inf), labels = c("0-200", "200-1000", ">1000")), Animal_type = case_when( Species %in% c("Pig", "5 Cows", "Atlantic white sided dolphin (Lagenorhynchus acutus)", "Porpoise (Phocoena phocoena)", "Porpoise (Phocoena phocoena), Common dolphin (Delphinus delphis)", "Sperm whale (Physeter macrocephalus)", "Gray Whale (Eschrichtius robustus)", "Blue Whale (Balaenoptera musculus)", "Pilot whale (Globicephala melas)", "Minke whale (Balaenoptera acutorostrata)", "Grey seal (Halichoerus gypus)") ~ "Mammal", Species %in% c("Toothfish (Dissostichus eleginoides)", "Tuna (Thunnus sp)", "Mackerel (Scomber japonicus)", "Atlantic mackerel (Scomber scombrus)") ~ "Teleost", Species %in% c("White-tip shark (Charcharhinus longimanus)") ~ "Shark", Species %in% c("American alligator (Alligator mississippiensis)") ~ "Reptile", Species %in% c("Squid (Illex argentinus)", "Southern Shortfin Squid (Illex coindetii)") ~ "Squid", Species %in% c("Coronate scyphomedusa (Periphylla periphylla)", "Helmet jellyfish (Periphylla periphylla)") ~ "Jellyfish", TRUE ~ "Other" ) )

SFreddi commented 1 year ago

After a fair bit of troubleshooting I identified the symbol ">" being the issue when specifying the labels. When I imported the data in esquisse it automatically omitted all data >100 and >1000 for my 2 variables.

pvictor commented 11 months ago

Hello,

Can you provide more infos ? Result of sessioninfo::session_info(), an example of data to reproduce the issue ?

In this example I don't have an issue with the symbol > :

library(esquisse)
library(dplyr)

iris %>% 
  mutate(
    Sepal.Length_range = cut(Sepal.Length, breaks = c(0, 5, 6, Inf), labels = c("0-5", "5-6", ">6"))
  ) %>% 
    esquisser()