Description

In this homework, I explore the differences in the traits of Palm tree species of African and American/European descent. Specifically, I take look at differences in the average fruit length and maximum stem height asking if there are any differences in these traits. The datasets used for this homework came from tidytuesday’s weekly list of datasets for the year 2025.

citation: @misc{tidytuesday, title = {Tidy Tuesday: A weekly social data project}, author = {Data Science Learning Community}, url = {https://tidytues.day}, year = {2024} }

Variables Used

  1. max_stem_height_m

  2. average_fruit_length_cm

Data Exploration and Cleaning

load the necessary libraries

library(tidyr)
library(ggbeeswarm)
## Warning: package 'ggbeeswarm' was built under R version 4.4.3
## Loading required package: ggplot2
library(cowplot)
library(ggridges)
library(ggmosaic)
## Warning: package 'ggmosaic' was built under R version 4.4.3
library(ggplot2)
library(tidyverse)
## Warning: package 'purrr' was built under R version 4.4.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ lubridate 1.9.4     ✔ tibble    3.2.1
## ✔ purrr     1.0.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter()    masks stats::filter()
## ✖ dplyr::lag()       masks stats::lag()
## ✖ lubridate::stamp() masks cowplot::stamp()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(skimr)

import the data

plm_data <- read.csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-03-18/palmtrees.csv')

str(plm_data)
## 'data.frame':    2557 obs. of  29 variables:
##  $ spec_name              : chr  "Acanthophoenix crinita" "Acanthophoenix rousselii" "Acanthophoenix rubra" "Acoelorrhaphe wrightii" ...
##  $ acc_genus              : chr  "Acanthophoenix" "Acanthophoenix" "Acanthophoenix" "Acoelorrhaphe" ...
##  $ acc_species            : chr  "crinita" "rousselii" "rubra" "wrightii" ...
##  $ palm_tribe             : chr  "Areceae" "Areceae" "Areceae" "Trachycarpeae" ...
##  $ palm_subfamily         : chr  "Arecoideae" "Arecoideae" "Arecoideae" "Coryphoideae" ...
##  $ climbing               : chr  "climbing" "climbing" "climbing" "climbing" ...
##  $ acaulescent            : chr  "acaulescent" "acaulescent" "acaulescent" "acaulescent" ...
##  $ erect                  : chr  "non-erect" "non-erect" "non-erect" "non-erect" ...
##  $ stem_solitary          : chr  "non-solitary" "non-solitary" "non-solitary" "solitary" ...
##  $ stem_armed             : chr  "non-armed" "non-armed" "non-armed" "armed" ...
##  $ leaves_armed           : chr  "non-armed" "non-armed" "non-armed" "non-armed" ...
##  $ max_stem_height_m      : num  10 25 15 9.1 12 18 0 NA 0 NA ...
##  $ max_stem_dia_cm        : num  20 30 18 15 50 35 NA NA NA NA ...
##  $ understorey_canopy     : chr  "canopy" "canopy" "canopy" "canopy" ...
##  $ max_leaf_number        : int  15 NA 20 25 30 15 NA NA 6 NA ...
##  $ max__blade__length_m   : num  2.3 3 3.1 1.3 3.5 3 NA NA 0.9 NA ...
##  $ max__rachis__length_m  : num  NA NA 3 0.7 2.5 NA NA NA 0.54 NA ...
##  $ max__petiole_length_m  : num  NA NA NA 0.65 NA 0.65 NA NA 0.51 NA ...
##  $ average_fruit_length_cm: num  0.65 2 1 0.7 4.25 2.5 2 NA 2.25 4.6 ...
##  $ min_fruit_length_cm    : num  0.6 NA NA NA 3.5 NA NA NA 1.5 3.8 ...
##  $ max_fruit_length_cm    : num  0.7 NA NA NA 5 NA NA NA 3 5.4 ...
##  $ average_fruit_width_cm : num  0.5 0.8 0.7 0.7 4.6 1.8 2 NA 2.25 4.6 ...
##  $ min_fruit_width_cm     : num  NA NA NA 0.5 3.8 NA NA NA 1.5 3.8 ...
##  $ max_fruit_width_cm     : num  NA NA NA 0.9 5.4 NA NA NA 3 5.4 ...
##  $ fruit_size_categorical : chr  "small" "small" "small" "small" ...
##  $ fruit_shape            : chr  NA "ovoid" "ovoid" "ovoid" ...
##  $ fruit_color_description: chr  "black" "black" "black" "orange-brown; becomming black" ...
##  $ main_fruit_colors      : chr  "black" "black" "black" "brown; black" ...
##  $ conspicuousness        : chr  "cryptic" "cryptic" "cryptic" "cryptic" ...
head(plm_data) 
##                  spec_name      acc_genus acc_species    palm_tribe
## 1   Acanthophoenix crinita Acanthophoenix     crinita       Areceae
## 2 Acanthophoenix rousselii Acanthophoenix   rousselii       Areceae
## 3     Acanthophoenix rubra Acanthophoenix       rubra       Areceae
## 4   Acoelorrhaphe wrightii  Acoelorrhaphe    wrightii Trachycarpeae
## 5       Acrocomia aculeata      Acrocomia    aculeata      Cocoseae
## 6         Acrocomia crispa      Acrocomia      crispa      Cocoseae
##   palm_subfamily climbing acaulescent     erect stem_solitary stem_armed
## 1     Arecoideae climbing acaulescent non-erect  non-solitary  non-armed
## 2     Arecoideae climbing acaulescent non-erect  non-solitary  non-armed
## 3     Arecoideae climbing acaulescent non-erect  non-solitary  non-armed
## 4   Coryphoideae climbing acaulescent non-erect      solitary      armed
## 5     Arecoideae climbing acaulescent non-erect  non-solitary  non-armed
## 6     Arecoideae climbing acaulescent non-erect  non-solitary  non-armed
##   leaves_armed max_stem_height_m max_stem_dia_cm understorey_canopy
## 1    non-armed              10.0              20             canopy
## 2    non-armed              25.0              30             canopy
## 3    non-armed              15.0              18             canopy
## 4    non-armed               9.1              15             canopy
## 5    non-armed              12.0              50             canopy
## 6    non-armed              18.0              35             canopy
##   max_leaf_number max__blade__length_m max__rachis__length_m
## 1              15                  2.3                    NA
## 2              NA                  3.0                    NA
## 3              20                  3.1                   3.0
## 4              25                  1.3                   0.7
## 5              30                  3.5                   2.5
## 6              15                  3.0                    NA
##   max__petiole_length_m average_fruit_length_cm min_fruit_length_cm
## 1                    NA                    0.65                 0.6
## 2                    NA                    2.00                  NA
## 3                    NA                    1.00                  NA
## 4                  0.65                    0.70                  NA
## 5                    NA                    4.25                 3.5
## 6                  0.65                    2.50                  NA
##   max_fruit_length_cm average_fruit_width_cm min_fruit_width_cm
## 1                 0.7                    0.5                 NA
## 2                  NA                    0.8                 NA
## 3                  NA                    0.7                 NA
## 4                  NA                    0.7                0.5
## 5                 5.0                    4.6                3.8
## 6                  NA                    1.8                 NA
##   max_fruit_width_cm fruit_size_categorical fruit_shape
## 1                 NA                  small        <NA>
## 2                 NA                  small       ovoid
## 3                 NA                  small       ovoid
## 4                0.9                  small       ovoid
## 5                5.4                  large       ovoid
## 6                 NA                  small     globose
##         fruit_color_description main_fruit_colors conspicuousness
## 1                         black             black         cryptic
## 2                         black             black         cryptic
## 3                         black             black         cryptic
## 4 orange-brown; becomming black      brown; black         cryptic
## 5               yellowish green             green         cryptic
## 6              yellow to orange    yellow; orange     conspicuous
tail(plm_data)
##                 spec_name acc_genus acc_species    palm_tribe palm_subfamily
## 2552   Wettinia praemorsa  Wettinia   praemorsa     Irarteeae     Arecoideae
## 2553    Wettinia quinaria  Wettinia    quinaria     Irarteeae     Arecoideae
## 2554     Wettinia radiata  Wettinia     radiata     Irarteeae     Arecoideae
## 2555 Wettinia verruculosa  Wettinia verruculosa     Irarteeae     Arecoideae
## 2556   Wodyetia bifurcata  Wodyetia   bifurcata       Areceae     Arecoideae
## 2557    Zombia antillarum    Zombia  antillarum Cryosophileae   Coryphoideae
##      climbing acaulescent     erect stem_solitary stem_armed leaves_armed
## 2552 climbing acaulescent non-erect          both      armed        armed
## 2553 climbing acaulescent non-erect  non-solitary      armed        armed
## 2554 climbing acaulescent non-erect  non-solitary      armed        armed
## 2555 climbing acaulescent non-erect  non-solitary      armed        armed
## 2556 climbing acaulescent non-erect  non-solitary      armed        armed
## 2557 climbing acaulescent non-erect      solitary      armed    non-armed
##      max_stem_height_m max_stem_dia_cm understorey_canopy max_leaf_number
## 2552                15              15             canopy               6
## 2553                15              20             canopy               6
## 2554                 9              10             canopy               6
## 2555                10              20             canopy               6
## 2556                15              25             canopy              10
## 2557                 3              10        understorey              12
##      max__blade__length_m max__rachis__length_m max__petiole_length_m
## 2552                 3.00                   3.0                    NA
## 2553                 5.50                   3.2                  1.35
## 2554                 4.33                   3.4                    NA
## 2555                 6.00                   3.7                  2.40
## 2556                 3.20                   2.3                  1.02
## 2557                 1.20                   1.0                    NA
##      average_fruit_length_cm min_fruit_length_cm max_fruit_length_cm
## 2552                    2.55                 2.2                 2.9
## 2553                    2.75                 2.0                 3.5
## 2554                    4.00                 3.0                 4.0
## 2555                    2.50                  NA                  NA
## 2556                    5.75                 5.0                 6.5
## 2557                    1.75                  NA                  NA
##      average_fruit_width_cm min_fruit_width_cm max_fruit_width_cm
## 2552                     NA                 NA                 NA
## 2553                   2.00                1.5                2.5
## 2554                   2.00                 NA                 NA
## 2555                   1.50                 NA                 NA
## 2556                   4.35                2.7                6.0
## 2557                   1.75                1.5                2.0
##      fruit_size_categorical fruit_shape        fruit_color_description
## 2552                  small     globose green to filly yellowish brown
## 2553                  small       ovoid              dark brown; green
## 2554                  large     globose                         yellow
## 2555                  small       ovoid          green to brown; green
## 2556                  large     globose                            red
## 2557                  small       ovoid                          white
##      main_fruit_colors conspicuousness
## 2552      green; brown         cryptic
## 2553      brown; green         cryptic
## 2554            yellow     conspicuous
## 2555      green; brown         cryptic
## 2556               red     conspicuous
## 2557             white         cryptic
summary(plm_data)
##   spec_name          acc_genus         acc_species         palm_tribe       
##  Length:2557        Length:2557        Length:2557        Length:2557       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##  palm_subfamily       climbing         acaulescent           erect          
##  Length:2557        Length:2557        Length:2557        Length:2557       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##  stem_solitary       stem_armed        leaves_armed       max_stem_height_m
##  Length:2557        Length:2557        Length:2557        Min.   :  0.00   
##  Class :character   Class :character   Class :character   1st Qu.:  2.50   
##  Mode  :character   Mode  :character   Mode  :character   Median :  6.00   
##                                                           Mean   : 10.86   
##                                                           3rd Qu.: 15.00   
##                                                           Max.   :170.00   
##                                                           NA's   :446      
##  max_stem_dia_cm  understorey_canopy max_leaf_number max__blade__length_m
##  Min.   :  0.00   Length:2557        Min.   : 4.00   Min.   : 0.150      
##  1st Qu.:  2.00   Class :character   1st Qu.: 8.00   1st Qu.: 1.000      
##  Median :  5.00   Mode  :character   Median :11.00   Median : 1.695      
##  Mean   : 12.38                      Mean   :14.37   Mean   : 2.374      
##  3rd Qu.: 17.00                      3rd Qu.:18.00   3rd Qu.: 3.000      
##  Max.   :175.00                      Max.   :75.00   Max.   :25.000      
##  NA's   :602                         NA's   :1251    NA's   :659         
##  max__rachis__length_m max__petiole_length_m average_fruit_length_cm
##  Min.   : 0.050        Min.   :0.0000        Min.   : 0.300         
##  1st Qu.: 0.750        1st Qu.:0.2500        1st Qu.: 1.050         
##  Median : 1.500        Median :0.5500        Median : 1.500         
##  Mean   : 1.972        Mean   :0.8517        Mean   : 2.196         
##  3rd Qu.: 2.700        3rd Qu.:1.2500        3rd Qu.: 2.500         
##  Max.   :18.500        Max.   :6.7500        Max.   :45.000         
##  NA's   :1026          NA's   :1347          NA's   :505            
##  min_fruit_length_cm max_fruit_length_cm average_fruit_width_cm
##  Min.   : 0.300      Min.   : 0.500      Min.   : 0.200        
##  1st Qu.: 1.000      1st Qu.: 1.400      1st Qu.: 0.750        
##  Median : 1.500      Median : 2.000      Median : 1.050        
##  Mean   : 2.181      Mean   : 3.102      Mean   : 1.594        
##  3rd Qu.: 2.500      3rd Qu.: 3.500      3rd Qu.: 1.800        
##  Max.   :40.000      Max.   :50.000      Max.   :20.000        
##  NA's   :1651        NA's   :1641        NA's   :563           
##  min_fruit_width_cm max_fruit_width_cm fruit_size_categorical
##  Min.   : 0.200     Min.   : 0.220     Length:2557           
##  1st Qu.: 0.700     1st Qu.: 1.000     Class :character      
##  Median : 1.000     Median : 1.500     Mode  :character      
##  Mean   : 1.479     Mean   : 2.125                           
##  3rd Qu.: 1.800     3rd Qu.: 2.500                           
##  Max.   :13.000     Max.   :20.000                           
##  NA's   :1563       NA's   :1555                             
##  fruit_shape        fruit_color_description main_fruit_colors 
##  Length:2557        Length:2557             Length:2557       
##  Class :character   Class :character        Class :character  
##  Mode  :character   Mode  :character        Mode  :character  
##                                                               
##                                                               
##                                                               
##                                                               
##  conspicuousness   
##  Length:2557       
##  Class :character  
##  Mode  :character  
##                    
##                    
##                    
## 
# check for the different types of tribes we have in our dataset
unique(plm_data$palm_tribe) # 23 tribes in total
##  [1] "Areceae"          "Trachycarpeae"    "Cocoseae"         "Phytelepheae"    
##  [5] "Caryoteae"        "Geonomateae"      "Borasseae"        "Calameae"        
##  [9] "Ceroxyleae"       "Chamaedoreeae"    "Cryosophileae"    "Chuniophoeniceae"
## [13] "Corypheae"        "Irarteeae"        "Lepidocaryeae"    "Eugeissoneae"    
## [17] "Euterpeae"        "Leopoldinieae"    "Manicarieae"      "Nypoideae"       
## [21] "Oranieae"         "Pelagodoxeae"     "Phoeniceae"       "Podococceae"     
## [25] "Cyclosphatheae"   "Reinhardtieae"    "Roystoneeae"      "Sabaleae"        
## [29] "Sclerospermeae"
# select for species in tribes from africa and america/europe based on (Baker & Dransfield, 2016 and Eiserhardt et al., 2011) 
afro_tribe <- c("Phoeniceae", "Borasseae", "Oranieae", "Sclerospermeae", "Pelagodoxeae", "Podococceae")

eu_us_tribe <- c("Cocoseae", "Phytelepheae", "Geonomateae", "Ceroxyleae", "Chamaedoreeae", "Cryosophileae", "Trachycarpeae", "Irarteeae", "Lepidocaryeae", "Euterpeae", "Eugeissoneae", "Leopoldinieae", "Manicarieae", "Reinhardtieae", "Roystoneeae", "Sabaleae", "Cyclosphatheae")

# select for tribes from africa and take out NAs
plm_data %>%
  filter(palm_tribe %in% afro_tribe) %>%
  drop_na() -> afro_palm 

head(afro_palm)
##               spec_name  acc_genus    acc_species palm_tribe palm_subfamily
## 1    Bismarckia nobilis Bismarckia        nobilis  Borasseae   Coryphoideae
## 2     Hyphaene coriacea   Hyphaene       coriacea  Borasseae   Coryphoideae
## 3       Orania disticha     Orania       disticha   Oranieae     Arecoideae
## 4 Orania lauterbachiana     Orania lauterbachiana   Oranieae     Arecoideae
## 5    Orania longisquama     Orania    longisquama   Oranieae     Arecoideae
## 6       Orania palindan     Orania       palindan   Oranieae     Arecoideae
##   climbing acaulescent     erect stem_solitary stem_armed leaves_armed
## 1 climbing acaulescent non-erect  non-solitary      armed        armed
## 2 climbing acaulescent non-erect          both      armed    non-armed
## 3 climbing acaulescent non-erect  non-solitary      armed        armed
## 4 climbing acaulescent non-erect  non-solitary      armed        armed
## 5 climbing acaulescent non-erect  non-solitary      armed        armed
## 6 climbing acaulescent non-erect  non-solitary      armed        armed
##   max_stem_height_m max_stem_dia_cm understorey_canopy max_leaf_number
## 1                25              45             canopy              30
## 2                 6              30             canopy              20
## 3                20              23             canopy              12
## 4                20              32             canopy              10
## 5                20              25             canopy              15
## 6                30              40             canopy              15
##   max__blade__length_m max__rachis__length_m max__petiole_length_m
## 1                 4.50                   1.5                  2.75
## 2                 1.17                   1.8                  0.75
## 3                 4.30                   3.0                  1.35
## 4                 5.10                   3.9                  1.25
## 5                 3.20                   2.0                  1.25
## 6                 3.50                   2.0                  1.55
##   average_fruit_length_cm min_fruit_length_cm max_fruit_length_cm
## 1                    4.40                 4.0                 4.8
## 2                    4.50                 3.0                 6.0
## 3                    5.75                 5.5                 6.0
## 4                    3.75                 2.5                 5.0
## 5                    4.75                 4.0                 5.5
## 6                    5.40                 3.3                 7.5
##   average_fruit_width_cm min_fruit_width_cm max_fruit_width_cm
## 1                  3.025                3.0               3.05
## 2                  3.250                2.5               4.00
## 3                  5.750                5.5               6.00
## 4                  3.750                2.5               5.00
## 5                  3.750                3.0               4.50
## 6                  5.250                3.0               7.50
##   fruit_size_categorical fruit_shape                  fruit_color_description
## 1                  large     globose                               dark brown
## 2                  large    elongate                                    brown
## 3                  large    elongate                                   orange
## 4                  small     globose                           reddish orange
## 5                  large       ovoid                                    green
## 6                  large       ovoid yellowish green to bright yellow; smooth
##   main_fruit_colors conspicuousness
## 1             brown         cryptic
## 2             brown         cryptic
## 3            orange     conspicuous
## 4            orange     conspicuous
## 5             green         cryptic
## 6     green; yellow     conspicuous
tail(afro_palm)
##                spec_name acc_genus acc_species   palm_tribe palm_subfamily
## 5     Orania longisquama    Orania longisquama     Oranieae     Arecoideae
## 6        Orania palindan    Orania    palindan     Oranieae     Arecoideae
## 7          Orania ravaka    Orania      ravaka     Oranieae     Arecoideae
## 8       Orania trispatha    Orania   trispatha     Oranieae     Arecoideae
## 9      Phoenix reclinata   Phoenix   reclinata   Phoeniceae   Coryphoideae
## 10 Sommieria leucophylla Sommieria leucophylla Pelagodoxeae     Arecoideae
##    climbing     acaulescent     erect stem_solitary stem_armed leaves_armed
## 5  climbing     acaulescent non-erect  non-solitary      armed        armed
## 6  climbing     acaulescent non-erect  non-solitary      armed        armed
## 7  climbing     acaulescent non-erect  non-solitary      armed        armed
## 8  climbing     acaulescent non-erect  non-solitary      armed        armed
## 9  climbing     acaulescent non-erect          both      armed    non-armed
## 10 climbing non-acaulescent     erect  non-solitary      armed        armed
##    max_stem_height_m max_stem_dia_cm understorey_canopy max_leaf_number
## 5                 20              25             canopy              15
## 6                 30              40             canopy              15
## 7                 20              20             canopy               8
## 8                 22              35             canopy              12
## 9                 15              30             canopy              40
## 10                 0               4        understorey              40
##    max__blade__length_m max__rachis__length_m max__petiole_length_m
## 5                 3.200                  2.00                  1.25
## 6                 3.500                  2.00                  1.55
## 7                 4.500                  3.21                  1.34
## 8                 5.000                  2.40                  2.70
## 9                 4.500                  4.20                  0.33
## 10                2.185                  1.80                  0.80
##    average_fruit_length_cm min_fruit_length_cm max_fruit_length_cm
## 5                     4.75                 4.0                 5.5
## 6                     5.40                 3.3                 7.5
## 7                     6.20                 5.0                 7.4
## 8                     6.50                 5.0                 8.0
## 9                     1.90                 1.8                 2.0
## 10                    1.20                 0.9                 1.5
##    average_fruit_width_cm min_fruit_width_cm max_fruit_width_cm
## 5                    3.75                3.0                4.5
## 6                    5.25                3.0                7.5
## 7                    3.50                4.0                5.0
## 8                    6.50                5.0                8.0
## 9                    1.10                0.9                1.3
## 10                   1.15                0.8                1.5
##    fruit_size_categorical fruit_shape                  fruit_color_description
## 5                   large       ovoid                                    green
## 6                   large       ovoid yellowish green to bright yellow; smooth
## 7                   large       ovoid                     yellow or pale brown
## 8                   large     globose                                    green
## 9                   small     globose   from pale yellow to orange or dull red
## 10                  small       ovoid               dark brown and bright pink
##      main_fruit_colors conspicuousness
## 5                green         cryptic
## 6        green; yellow     conspicuous
## 7        yellow; brown     conspicuous
## 8                green         cryptic
## 9  yellow; orange; red     conspicuous
## 10         brown; pink     conspicuous
# select for tribes from EU and US and take out NAs
plm_data %>% 
  filter(palm_tribe %in% eu_us_tribe) %>%
  drop_na() -> eu_us_palm 

head(eu_us_palm)
##               spec_name   acc_genus acc_species palm_tribe palm_subfamily
## 1       Aiphanes minima    Aiphanes      minima   Cocoseae     Arecoideae
## 2 Astrocaryum aculeatum Astrocaryum   aculeatum   Cocoseae     Arecoideae
## 3    Astrocaryum huaimi Astrocaryum      huaimi   Cocoseae     Arecoideae
## 4    Astrocaryum jauari Astrocaryum      jauari   Cocoseae     Arecoideae
## 5 Astrocaryum javarense Astrocaryum   javarense   Cocoseae     Arecoideae
## 6  Astrocaryum murumuru Astrocaryum    murumuru   Cocoseae     Arecoideae
##   climbing acaulescent     erect stem_solitary stem_armed leaves_armed
## 1 climbing acaulescent non-erect  non-solitary  non-armed    non-armed
## 2 climbing acaulescent non-erect  non-solitary  non-armed    non-armed
## 3 climbing acaulescent non-erect      solitary  non-armed    non-armed
## 4 climbing acaulescent non-erect          both  non-armed    non-armed
## 5 climbing acaulescent non-erect      solitary  non-armed    non-armed
## 6 climbing acaulescent non-erect          both  non-armed    non-armed
##   max_stem_height_m max_stem_dia_cm understorey_canopy max_leaf_number
## 1                18              50             canopy               9
## 2                20              25             canopy              15
## 3                 7              15             canopy              12
## 4                20              30             canopy              15
## 5                 4              18        understorey              16
## 6                15              30             canopy              16
##   max__blade__length_m max__rachis__length_m max__petiole_length_m
## 1                  4.2                   3.0                  1.25
## 2                  8.4                   6.4                  2.10
## 3                  5.5                   3.5                  2.10
## 4                  6.0                   3.6                  2.50
## 5                  5.7                   4.4                  1.35
## 6                  8.0                   6.0                  2.10
##   average_fruit_length_cm min_fruit_length_cm max_fruit_length_cm
## 1                    1.40                 1.2                 1.6
## 2                    5.50                 4.5                 6.5
## 3                    3.55                 3.2                 3.9
## 4                    3.50                 2.5                 5.0
## 5                    5.10                 3.5                 6.7
## 6                    7.25                 6.0                 8.5
##   average_fruit_width_cm min_fruit_width_cm max_fruit_width_cm
## 1                   1.55                1.4                1.7
## 2                   4.00                3.5                4.5
## 3                   2.75                2.5                3.0
## 4                   2.40                1.7                3.0
## 5                   1.60                2.2                3.0
## 6                   4.10                3.8                4.4
##   fruit_size_categorical fruit_shape
## 1                  small     globose
## 2                  large     globose
## 3                  small     globose
## 4                  small       ovoid
## 5                  large     globose
## 6                  large       ovoid
##                                fruit_color_description main_fruit_colors
## 1                                                  red               red
## 2                        orange; greenish to yellowish            orange
## 3                                  yellowish to orange            orange
## 4                         yellow or orange at maturity    yellow; orange
## 5                                          hairy brown             brown
## 6 yellow to tan; breaking open to show orange mesocarp     yellow; brown
##   conspicuousness
## 1     conspicuous
## 2     conspicuous
## 3     conspicuous
## 4     conspicuous
## 5         cryptic
## 6     conspicuous
# excellent! this would be the only data wrangling we would be doing for now. 

Data Visualization

visualizing interactions for Tribes in Africa

# mosaic plot for Average Fruit Length by tribe
# Create a binned category for fruit length
afro_palm$fruit_length_cat <- cut(afro_palm$average_fruit_length_cm,
                                  breaks = 4, 
                                  labels = c("Short", 
                                             "Medium", 
                                             "Long", 
                                             "Very Long"))

# Mosaic plot with two categorical variables
ggplot(data = afro_palm) +
  geom_mosaic(aes
              (weight = 1,
                  x = product(palm_tribe), 
                fill = fruit_length_cat)) +
  theme_classic() +
  labs(title = "Fruit Length Categories by Tribe",
       x = "Palm Tribe",
       y = "Proportion",
       fill = "Fruit Length Category")
## Warning: The `scale_name` argument of `continuous_scale()` is deprecated as of ggplot2
## 3.5.0.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The `trans` argument of `continuous_scale()` is deprecated as of ggplot2 3.5.0.
## ℹ Please use the `transform` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: `unite_()` was deprecated in tidyr 1.2.0.
## ℹ Please use `unite()` instead.
## ℹ The deprecated feature was likely used in the ggmosaic package.
##   Please report the issue at <https://github.com/haleyjeppson/ggmosaic>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

# Boxplot for Maximum Stem Height by Tribe
ggplot(afro_palm)+ 
  aes(x = palm_tribe, 
      y = max_stem_height_m, 
      fill = palm_tribe) +
  geom_col() +
  theme_cowplot() +
  labs(title = "Maximum Stem Height by Tribe", 
       x = "Tribe", 
       y = "Maximum Stem Height (m)")

visualizing interactions for Tribes in the EU and US

# ridgeline plot for Average Fruit Length across tribes
ggplot(data = eu_us_palm,
       aes(
         x    = average_fruit_length_cm,  # continuous
         y    = palm_tribe,               # grouping strip
         fill = palm_tribe                # fill by tribe
       )) +
  geom_density_ridges(alpha = 0.7, color = "white") +
  theme_classic() +
  theme(
    axis.text.y = element_text(size = 12),
    axis.text.x = element_text(angle = 45, hjust = 1, size = 12),
    legend.position = "right"
  ) +
  labs(
    title = "Distribution of Average Fruit Length by Tribe",
    x     = "Average Fruit Length (cm)",
    y     = "Tribe"
  )
## Picking joint bandwidth of 0.393

# Density ridgelines for Maximum Stem Height across tribes
ggplot(data = eu_us_palm,
       aes(
         y = max_stem_height_m,  # continuous axis
         x = palm_tribe,         # categorical strips
         color = palm_tribe          # map tribe to point color
       )) +
  geom_beeswarm(
    cex       = 3,          # controls horizontal spacing
    size      = 2,          # point size
  ) +
  theme_cowplot() +
  labs(
    title = "Maximum Stem Height by Tribe",
    x     = "Tribe",
    y     = "Maximum Stem Height (m)" 
  ) +
  theme(
    legend.position = "right",
    axis.text = element_text(size = 12, 
                              angle = 45,
                             vjust = 0.5,
                             hjust = 1)
  )

# comparing plots for the African and the American/European tribes it appears that, species in Europe and America have higher averages for Stem Height and Fruit Length. Also, it appears that our data has more records for American/European tribes than thier african counterparts. This is very interesting and needs further investigation.