Skip to content

Commit

Permalink
more pivot errors fixed (#765)
Browse files Browse the repository at this point in the history
more fixes to pivoting problems:
- minor changes copied from traits.build back to austraits.build process.R file
- had to add locations to Yang_2023
- Witkowski_1991 would only recognised plant ages when I wrote them in letters after trying many many other tricks: I tried '10' and '21'; I checked metadata_check_custom_R_code("Witkowski_1991) to see how it was read in; I tried retyping the cells; I tried assigning it to a different context category; I tried adding "mutate to as.character" through custom_R_code and nothing worked. All rows in the column have a value, so it isn't being read in strangely.
  • Loading branch information
ehwenk authored and dfalster committed Sep 11, 2023
1 parent 3ba2acf commit f17ff0d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 16 deletions.
10 changes: 5 additions & 5 deletions R/process.R
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ process_create_observation_id <- function(data) {
data <- data %>%
dplyr::mutate(
pop_id_segment = ifelse(
(!is.na(.data$location_name)|!is.na(.data$treatment_id)|!is.na(.data$plot_id)) & .data$entity_type %in% c("individual", "population"),
(!is.na(.data$location_name)|!is.na(.data$treatment_id)|!is.na(.data$plot_id)) & .data$entity_type %in% c("individual", "population", "metapopulation"),
process_generate_id(.data$population_id, "", sort = TRUE),
NA),
pop_id_segment = ifelse(is.na(.data$pop_id_segment) &
.data$entity_type %in% c("individual", "population"),
.data$entity_type %in% c("individual", "population", "metapopulation"),
"pop_unk", .data$pop_id_segment),
population_id = .data$pop_id_segment
)
Expand Down Expand Up @@ -373,7 +373,7 @@ process_create_observation_id <- function(data) {
dplyr::group_by(.data$dataset_id) %>%
dplyr::mutate(
observation_id =
paste(.data$taxon_name, .data$population_id, .data$individual_id, .data$temporal_id, .data$entity_type, sep="-") %>%
paste(.data$taxon_name, .data$population_id, .data$individual_id, .data$temporal_id, .data$entity_type, .data$life_stage, sep="-") %>%
process_generate_id("", sort = TRUE)
) %>%
dplyr::ungroup()
Expand Down Expand Up @@ -514,8 +514,8 @@ process_create_context_ids <- function(data, contexts) {
tidyr::unite("combined", remove = FALSE) %>%
dplyr::mutate(
combined = ifelse(.data$combined == NAs, NA, .data$combined),
id = .data$combined %>%
as.factor() %>% as.integer() %>% make_id()
id = ifelse(!is.na(.data$combined), .data$combined %>%
as.factor() %>% as.integer() %>% make_id(), NA)
) %>%
dplyr::select(-dplyr::all_of(c("combined")))

Expand Down
12 changes: 6 additions & 6 deletions data/Witkowski_1991/data.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Species,plant_age,replicates_seeds_fruit,reproductive_maturity,seed_viability_%,seed_germination_%,seed_dry_mass_mg,fire_to_flowering,fire_to_fruiting,seedset_%,fruit_set_%,post_fire_recruitment,seedling_establishment_conditions,resprouting_capacity,serotiny
Banksia baxteri,10,15,3,98.6,41,43.4,3,5,0.9,1.2,post_fire_recruitment,establish_post_fire,fire_killed, serotiny_high
Banksia baxteri,21,5,,99.3,31,,,,0.8,1,,,,
Banksia speciosa,10,15,3,99.1,47,128.6,3,3,0.5,0.7,post_fire_recruitment,establish_post_fire,fire_killed, serotiny_high
Banksia speciosa,21,5,,99.7,35,,,,0.4,0.5,,,,
Banksia coccinea,10,15,3,99.3,21,12.8,3,3,4,8.6,post_fire_recruitment,establish_post_fire establish_anytime,fire_killed, serotiny_moderate
Banksia coccinea,21,5,,99.2,18,,,,3.4,7.3,,,,
Banksia baxteri,ten,15,3,98.6,41,43.4,3,5,0.9,1.2,post_fire_recruitment,establish_post_fire,fire_killed, serotiny_high
Banksia baxteri,twentyone,5,,99.3,31,,,,0.8,1,,,,
Banksia speciosa,ten,15,3,99.1,47,128.6,3,3,0.5,0.7,post_fire_recruitment,establish_post_fire,fire_killed, serotiny_high
Banksia speciosa,twentyone,5,,99.7,35,,,,0.4,0.5,,,,
Banksia coccinea,ten,15,3,99.3,21,12.8,3,3,4,8.6,post_fire_recruitment,establish_post_fire establish_anytime,fire_killed, serotiny_moderate
Banksia coccinea,twentyone,5,,99.2,18,,,,3.4,7.3,,,,
4 changes: 2 additions & 2 deletions data/Witkowski_1991/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ contexts:
category: entity_context
var_in: plant_age
values:
- value: 10
- value: 21
- value: ten
- value: twentyone
traits:
- var_in: reproductive_maturity
unit_in: a
Expand Down
38 changes: 35 additions & 3 deletions data/Yang_2023/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ dataset:
entity_type = "species",
entity_type = ifelse(!is.na(fire_severity), "population", entity_type),
entity_type = ifelse(!is.na(fire_intensity), "population", entity_type),
entity_type = ifelse(!is.na(habitat_conditions), "population", entity_type)
entity_type = ifelse(!is.na(habitat_conditions), "population", entity_type),
entity_type = ifelse(taxon_name %in% c("Banksia ashbyi", "Grevillea pteridifolia", "Hakea marginata", "Paraprasophyllum constrictum"), "population", entity_type)
)
'
collection_date: unknown/2022
taxon_name: taxon_name
location_name: site
source_id: source_id
description: Plant fire response and other related trait data scored from Australia's
online state and national floras and the taxonomic literature.
Expand All @@ -113,7 +115,37 @@ dataset:
original_file: .na
notes: References for additional source_id's available in a column in the data.csv
file, 'references'
locations: .na
locations:
South of Shark Bay:
longitude (deg): .na.character
latitude (deg): .na.character
North of Carnarvon:
longitude (deg): .na.character
latitude (deg): .na.character
QLD, NT:
longitude (deg): .na.character
latitude (deg): .na.character
Northern NT, WA:
longitude (deg): .na.character
latitude (deg): .na.character
Southern population:
longitude (deg): .na.character
latitude (deg): .na.character
Northern population:
longitude (deg): .na.character
latitude (deg): .na.character
Adelaide Hills:
longitude (deg): .na.character
latitude (deg): .na.character
Locations other than Adelaide Hills:
longitude (deg): .na.character
latitude (deg): .na.character
Providence Ponds:
longitude (deg): .na.character
latitude (deg): .na.character
NT:
longitude (deg): .na.character
latitude (deg): .na.character
contexts:
- context_property: fire severity
category: plot
Expand Down Expand Up @@ -174,7 +206,7 @@ contexts:
description: Time from fire to flowering measured on resprouting shoots.
- find: fire_killed
value: from seed
description: Time from fire to flowering measured on plants that germinated post-fire.
description: Time from fire to flowering measured on plants that germinated post-fire.
traits:
- var_in: fire_response
unit_in: .na
Expand Down

0 comments on commit f17ff0d

Please sign in to comment.