-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
179f06e
commit 19bf6f3
Showing
2 changed files
with
118 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Species,Length,Weight,tag_row,date,tag_id | ||
Rainbow Trout,82,5.2,3,08-18-2021 13:03:42 01,3DD.003E1929FD. Row ID 3. | ||
Rainbow Trout,38,0.6,,, | ||
Rainbow Trout,36,0.6,,, | ||
Rainbow Trout,118,11.5,4,08-18-2021 13:07:52 01,3DD.003E1929E6. Row ID 4. | ||
Rainbow Trout,113,15.7,5,08-18-2021 13:10:39 01,3DD.003E1929F9. Row ID 5. | ||
Rainbow Trout,129,23,6,08-18-2021 13:15:10 01,3DD.003E1929DF. Row ID 6. | ||
Sculpin (General),78,4.4,,, | ||
Rainbow Trout,112,13.6,7,08-18-2021 13:17:22 01,3DD.003E1929D4. Row ID 7. | ||
Rainbow Trout,135,25.3,8,08-18-2021 13:19:54 01,3DD.003E1929F7. Row ID 8. | ||
Rainbow Trout,80,5.2,9,08-18-2021 13:56:36 01,3DD.003E1929F3. Row ID 9. | ||
Rainbow Trout,40,0.7,,, | ||
Rainbow Trout,43,0.8,,, | ||
Rainbow Trout,109,14,10,08-18-2021 13:58:55 01,3DD.003E1929C1. Row ID 10. | ||
Rainbow Trout,89,8.1,11,08-18-2021 14:01:05 01,3DD.003E1929F5. Row ID 11. | ||
Rainbow Trout,91,8.2,12,08-18-2021 14:03:17 01,3DD.003E1929F4. Row ID 12. | ||
Rainbow Trout,102,11.1,13,08-18-2021 15:08:39 01,3DD.003E1929EB. Row ID 13. | ||
Rainbow Trout,39,0.7,,, | ||
Sculpin (General),48,1.6,,, | ||
Rainbow Trout,99,9.6,14,08-18-2021 15:10:33 01,3DD.003E1929E9. Row ID 14. | ||
Rainbow Trout,121,18.6,15,08-18-2021 15:12:18 01,3DD.003E1929CE. Row ID 15. | ||
Rainbow Trout,130,27.8,16,08-18-2021 15:14:48 01,3DD.003E1929FE. Row ID 16. | ||
Rainbow Trout,89,7.8,17,08-18-2021 15:16:16 01,3DD.003E1929E3. Row ID 17. | ||
Rainbow Trout,101,10.6,18,08-18-2021 15:19:17 01,3DD.003E1929D9. Row ID 18. | ||
Rainbow Trout,89,7.5,19,08-18-2021 15:21:20 01,3DD.003E1929CD. Row ID 19. | ||
Rainbow Trout,78,4.9,20,08-18-2021 15:23:44 01,3DD.003E1929C9. Row ID 20. | ||
Rainbow Trout,82,6.2,21,08-18-2021 15:25:28 01,3DD.003E1929C5. Row ID 21. | ||
Rainbow Trout,72,4.1,22,08-18-2021 15:28:16 01,3DD.003E1929D7. Row ID 22. | ||
Sculpin (General),45,1.1,,, | ||
Rainbow Trout,96,9.4,23,08-18-2021 15:34:04 01,3DD.003E1929E0. Row ID 23. | ||
Rainbow Trout,115,15.9,,, | ||
Rainbow Trout,108,13.3,24,08-18-2021 15:36:25 01,3DD.003E1929DE. Row ID 24. | ||
Rainbow Trout,84,6.3,25,08-18-2021 15:38:58 01,3DD.003E1929D6. Row ID 25. | ||
Sculpin (General),68,3.5,,, | ||
Rainbow Trout,89,8,26,08-18-2021 15:41:12 01,3DD.003E1929E5. Row ID 26. | ||
Rainbow Trout,78,5.1,27,08-18-2021 15:43:00 01,3DD.003E1929FA. Row ID 27. | ||
Rainbow Trout,105,12,28,08-18-2021 16:27:54 01,3DD.003E1929AF. Row ID 28. | ||
Rainbow Trout,39,0.7,,, | ||
Rainbow Trout,43,0.9,,, | ||
Rainbow Trout,42,0.8,,, | ||
Rainbow Trout,43,0.8,,, | ||
Rainbow Trout,42,0.7,,, | ||
Rainbow Trout,44,1,,, | ||
Rainbow Trout,45,0.9,,, | ||
Rainbow Trout,34,0.5,,, | ||
Rainbow Trout,44,0.9,,, | ||
Rainbow Trout,44,0.9,,, | ||
Rainbow Trout,39,0.6,,, | ||
Rainbow Trout,40,0.7,,, | ||
Rainbow Trout,39,0.6,,, | ||
Rainbow Trout,49,1.3,,, | ||
Sculpin (General),61,2.5,,, | ||
Sculpin (General),56,1.7,,, | ||
Rainbow Trout,33,0.6,,, | ||
Rainbow Trout,45,0.8,,, | ||
Rainbow Trout,35,0.6,,, | ||
Rainbow Trout,41,0.7,,, | ||
Rainbow Trout,40,0.6,,, | ||
Rainbow Trout,45,0.9,,, | ||
Rainbow Trout,41,1,,, | ||
Rainbow Trout,39,1,,, | ||
Rainbow Trout,95,9.5,29,08-18-2021 16:29:14 01,3DD.003E1929C2. Row ID 29. | ||
Rainbow Trout,98,9.4,30,08-18-2021 16:30:50 01,3DD.003E1929BC. Row ID 30. | ||
Rainbow Trout,89,8,31,08-18-2021 16:32:13 01,3DD.003E1929DD. Row ID 31. | ||
Rainbow Trout,98,10.6,32,08-18-2021 16:33:56 01,3DD.003E1929F8. Row ID 32. | ||
Rainbow Trout,81,5.8,33,08-18-2021 16:57:23 01,3DD.003E1929AC. Row ID 33. | ||
Sculpin (General),60,2.5,,, | ||
Sculpin (General),46,1.1,,, | ||
Rainbow Trout,37,1.4,,, | ||
Rainbow Trout,129,24.8,34,08-18-2021 16:58:55 01,3DD.003E1929BE. Row ID 34. | ||
Rainbow Trout,109,14.5,35,08-18-2021 17:00:24 01,3DD.003E1929C6. Row ID 35. | ||
Rainbow Trout,110,15.8,36,08-18-2021 17:01:53 01,3DD.003E1929B9. Row ID 36. | ||
Rainbow Trout,95,9.8,37,08-18-2021 17:03:13 01,3DD.003E1929DA. Row ID 37. | ||
Rainbow Trout,84,6,38,08-18-2021 17:04:47 01,3DD.003E1929CC. Row ID 38. | ||
Rainbow Trout,89,8.3,39,, | ||
Rainbow Trout,98,9.5,,, | ||
Rainbow Trout,88,,,, | ||
Rainbow Trout,39,0.6,,, | ||
Rainbow Trout,79,,,, | ||
Rainbow Trout,109,,,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,52 @@ | ||
#combining pit tag data to individual fish data so that we can copy and paste directly into submission template | ||
# would be good to include the comments and times/camera of photos in the fish csv and then paste them to the right of the pit tag. | ||
|
||
source('scripts/packages.R') | ||
|
||
#import the pit tag csv | ||
path <- '../../repo/dff-2022/data/pars/tag_01_01.csv' | ||
# because we are working in a project our working directory is the root folder so all paths are | ||
# relative to that | ||
# path <- '../../repo/dff-2022/data/pars/tag_01_01.csv' | ||
path <- 'data/pars/tag_01_01.csv' | ||
|
||
pit_tag <- read.csv(path) | ||
# using readr is better than read.csv | ||
pit_tag <- readr::read_csv(path) %>% | ||
#separate the pit tag out from the rest of the info in the pit tag csv | ||
# https://stackoverflow.com/questions/66696779/separate-by-pattern-word-in-tidyr-and-dplyr | ||
tidyr::separate(col=tag, into=c('date', 'tag_id'), sep='\\s*TAG\\s*') %>% | ||
tibble::rowid_to_column() | ||
|
||
#separate the pit tag out from the rest of the info in the pit tag csv | ||
tags <- tidyr::separate(pit_tag, col=tag, into=c('date', 'tag_id'), sep=27) | ||
|
||
#generate row numbers | ||
rows <- dplyr::mutate(tags, id= row_number()) | ||
|
||
#import csv with fish data | ||
path2 <- '../../repo/dff-2022/data/pars/fish_data.csv' | ||
path2 <- 'data/pars/fish_data.csv' | ||
|
||
fish <- read.csv(path2) | ||
fish <- readr::read_csv(path2) | ||
|
||
#join fish csv with pit tag csv based on tag row number | ||
dplyr::left_join(tags, fish, by=c("tag_row"="rows")) | ||
|
||
|
||
fish_tags <- dplyr::left_join(fish, | ||
pit_tag, | ||
by = c("tag_row" = "rowid")) %>% | ||
# arrange columns | ||
relocate(tag_id, .after = last_col()) %>% | ||
# remove the first row because it was from the office. We need to pass the object piped to nrow as a "." | ||
# as the first object gets passed to the slice function only | ||
dplyr::slice(2:nrow(.)) %>% | ||
# add a period, a space and the row number to the pit tag to go in the comments to make it easy to pull anything out we want later | ||
dplyr::mutate(tag_id = case_when( | ||
!is.na(tag_id) ~ paste0(tag_id, '. Row ID ', tag_row, '. '), | ||
T ~ tag_id)) | ||
|
||
# select a subsample of fish (lets go 15% since the sample size is small) to review manually to be sure the | ||
# pit tags match which fish they go with | ||
# set seed for reproducible sample - try running it again without setting the seed immediately before and see how it differs | ||
set.seed(1234) | ||
sample(nrow(fish_tags), nrow(fish_tags) * 0.15) %>% | ||
# arrange the row numbers to make it easier to QA | ||
sort() | ||
|
||
# burn the csv ready to cut and paste | ||
fish_tags %>% | ||
readr::write_csv('data/pars/fish_tags_joined.csv', | ||
na = "" ) | ||
|
||
|