Last updated: 2024-02-01

Checks: 6 1

Knit directory: LocksofLineage/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20231117) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.

absolute relative
~/Github/LocksofLineage/data/data_multiple_multiple.csv data/data_multiple_multiple.csv
~/Github/LocksofLineage/data/combined_legends.csv data/combined_legends.csv

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version e18d74c. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/.DS_Store

Untracked files:
    Untracked:  combined_legends.csv
    Untracked:  data/combined_legends.csv
    Untracked:  data/data_multiple_multiple.csv

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/expanded_trait_data.Rmd) and HTML (docs/expanded_trait_data.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd e18d74c Sarah E Taylor 2024-02-01 Added a page on cleaning my data.

Loading in Data

# Read the CSV file
data <- read_csv("~/Desktop/Primates/Full_Hair_Traits_Updated_Names.csv")
New names:
Rows: 238 Columns: 17
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," chr
(16): family, Genus, species, subspecies, Sexual_dimorphism, Sexual_Dimo... lgl
(1): ...7
ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
Specify the column types or set `show_col_types = FALSE` to quiet this message.
• `` -> `...7`

Code the Data

# Binarize the data
data_test_multiple <- data %>%
  mutate(across(c(Sexual_dimorphism, Natal_coat, Sexual_dichromatism), ~if_else(. == "Yes", 1, 0)))
#data_multiple_options <- data_test_SC_NA %>%
  #mutate(Darker = match(Darker, unique(Darker)))

data_multiple_multiple <- data_test_multiple %>%
  mutate(across(c(Darker, Direction, Natal_Coat_Type), ~match(., unique(.)) - 1))

write.csv(data_multiple_multiple, "~/Github/LocksofLineage/data/data_multiple_multiple.csv", row.names = FALSE)

#data_multiple_options <- data %>%
  #mutate(Darker = if_else(is.na(Darker), NA_integer_, match(Darker, unique(Darker))))

Create the Legend

#Create the legend function
create_legend <- function(column) {
  unique_values <- unique(column)
  encoded_values <- match(unique_values, unique_values) - 1
  legend <- tibble(Original = unique_values, Code = encoded_values)
  return(legend)
}

#Create the legends for the columns
legend_Sexual_Dimorphism <- create_legend(data$Sexual_dimorphism)
legend_SD_Direction <- create_legend(data$Direction)
legend_Natal_coat <- create_legend(data$Natal_coat)
legend_Natal_coat_type <- create_legend(data$Natal_Coat_Type)
legend_Sexual_Dichrom <- create_legend(data$Sexual_dichromatism)
legend_Sexual_Dichrom_type <- create_legend(data$Sexual_dichromatism_type)
legend_Darker <- create_legend(data$Darker)


#Add column names
legend_Sexual_Dimorphism <- legend_Sexual_Dimorphism %>% mutate(Column = 'Sexual_Dimorphism')
legend_SD_Direction <- legend_SD_Direction %>% mutate(Column = 'SD_Direction')
legend_Natal_coat <- legend_Natal_coat %>% mutate(Column = 'Natal_Coat')
legend_Natal_coat_type <- legend_Natal_coat_type %>% mutate(Column = 'Natal_Coat_Type')
legend_Sexual_Dichrom <- legend_Sexual_Dichrom %>% mutate(Column = 'Sexual_Dichromatism')
legend_Sexual_Dichrom_type <- legend_Sexual_Dichrom %>% mutate(Column = 'Sexual_Dichrom_Type')
legend_Darker <- legend_Darker %>% mutate(Column = 'Darker')

#Combine the legends
combined_legends <- bind_rows(legend_Sexual_Dimorphism, legend_SD_Direction, legend_Natal_coat, legend_Natal_coat_type, legend_Sexual_Dichrom, legend_Sexual_Dichrom_type, legend_Darker)

#Create a csv for the legend
write.csv(combined_legends, "~/Github/LocksofLineage/data/combined_legends.csv", row.names = FALSE)

sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lubridate_1.9.2 forcats_1.0.0   stringr_1.5.0   dplyr_1.1.0    
 [5] purrr_1.0.1     readr_2.1.4     tidyr_1.3.0     tibble_3.1.8   
 [9] ggplot2_3.4.1   tidyverse_2.0.0 workflowr_1.7.1

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.0 xfun_0.41        bslib_0.4.2      colorspace_2.0-3
 [5] vctrs_0.5.2      generics_0.1.3   htmltools_0.5.4  yaml_2.3.7      
 [9] utf8_1.2.2       rlang_1.0.6      jquerylib_0.1.4  later_1.3.1     
[13] pillar_1.8.1     glue_1.6.2       withr_2.5.0      bit64_4.0.5     
[17] lifecycle_1.0.3  munsell_0.5.0    gtable_0.3.1     evaluate_0.20   
[21] knitr_1.42       tzdb_0.3.0       callr_3.7.3      fastmap_1.1.0   
[25] httpuv_1.6.11    ps_1.7.2         parallel_4.2.1   fansi_1.0.3     
[29] highr_0.10       Rcpp_1.0.11      promises_1.2.1   scales_1.2.1    
[33] cachem_1.0.6     vroom_1.6.1      jsonlite_1.8.4   bit_4.0.5       
[37] fs_1.6.1         hms_1.1.2        digest_0.6.30    stringi_1.7.8   
[41] processx_3.8.0   getPass_0.2-2    rprojroot_2.0.4  grid_4.2.1      
[45] cli_3.6.0        tools_4.2.1      magrittr_2.0.3   sass_0.4.5      
[49] crayon_1.5.2     whisker_0.4.1    pkgconfig_2.0.3  ellipsis_0.3.2  
[53] timechange_0.2.0 rmarkdown_2.20   httr_1.4.4       rstudioapi_0.14 
[57] R6_2.5.1         git2r_0.32.0     compiler_4.2.1