HOME RANGE VALIDATION library(validate) data (HomeRange) dat <- HomeRange # Run tests: #1. The variable HomeRange_ha is larger than 0 #2. The variable Refs1 must be present #3. The number of rows must be at least 504 ( the total number of primate species) #4. If the variable HomeRange_ha is numeric, the variable Refs1 must be numeric #5. Two records with the same species name must have the same common name and the same genus name #6. The variable Refs1 must be larger than 0 #7. The variable Refs1 must not be larger than 370 (the total number of references) v <- validator (HomeRange_ha >0, "Refs1" %in% names(.), nrow(.) >=504, (if (is.numeric(HomeRange_ha)) is.numeric (Refs1)), Species ~ CommonName + Genus, Refs1 >0, Refs1 <=370) cf <- confront(dat, v) summary (cf) barplot(cf, main="HomeRange") ****************************************************************************** BODY MASS VALIDATION library(validate) data (BodyMass) dat <- BodyMass # Run tests: #1. The variable BodyMass_kg is larger than 0 #2. The variable BodyMass_Female_kg is larger than 0 #3. The variable Refs1 must be present #4. The number of rows must be at least 504 ( the total number of primate species) #5. If the variable BodyMass_kg is numeric, the variable Refs1 must be numeric #6. Two records with the same species name must have the same common name and the same genus name #7. The variable Refs1 must be larger than 0 #8. The variable Refs1 must not be larger than 370 (the total number of references) #9. The variable RefsBMMaleFemale must be larger than 0 #10. The variable RefsBMMaleFemale must not be larger than 370 (the total number of references) v <- validator (BodyMass_kg >0, BodyMassFemale_kg >0, "Refs1" %in% names(.), nrow(.) >=504, (if (is.numeric(BodyMass_kg)) is.numeric (Refs1)), Species ~ CommonName + Genus, Refs1 >0, Refs1 <=370, RefsBMMaleFemale >0, RefsBMMaleFemale <=370) cf <- confront(dat, v) summary (cf) barplot(cf, main="BodyMass") ****************************************************************************** DIEL ACTIVITY VALIDATION library(validate) data (DielActivity) dat <- DielActivity # Run tests: #1. The variable Refs is larger than 0 #2. The variable DielActivity must be present #3. The number of rows must be at least 504 (the total number of primate species) #4. Two records with the same species name must have the same common name and the same genus name #5. The variable Refs must be larger than 0 #6. The variable Refs must not be larger than 370 (the total number of references) v <- validator (Refs >0, "DielActivity" %in% names(.), nrow(.) >=504, Species ~ CommonName + Genus, Refs >0, Refs <=370) cf <- confront(dat, v) summary (cf) barplot(cf, main="DielActivity") ****************************************************************************** HABITAT VALIDATION library(validate) data (Habitat) dat <- Habitat # Run tests: #1&2. The variables Habitat_Forest, Habitat_Savanna, Habitat_Shrubland, Habitat_Grassland, Habitat_Wetlands, Habitat_Rocky.areas and Habitat_Desert have values of 0 or 1 #3. The variable Refs2 must be present #4. The number of rows must be at least 504 (the total number of primate species) #5. Two records with the same species name must have the same common name and the same genus name #6. The variable Refs1 must be larger than 0 #7. The variable Refs1 must not be larger than 370 (the total number of references) v <- validator (var_group(Habitat_Forest, Habitat_Savanna, Habitat_Shrubland, Habitat_Grassland, Habitat_Wetlands, Habitat_Rocky.areas, Habitat_Desert) >= 0, var_group(Habitat_Forest, Habitat_Savanna, Habitat_Shrubland, Habitat_Grassland, Habitat_Wetlands, Habitat_Rocky.areas, Habitat_Desert) <= 1, "Refs2" %in% names(.), nrow(.) >=504, Species ~ CommonName + Genus, Refs1 >0, Refs1 <=370) cf <- confront(dat, v) summary (cf) barplot(cf, main="Habitat") ****************************************************************************** IUCN, POPULATION TREND AND REALM VALIDATION library(validate) data (IUCN_Poptrend_Realm) dat <- IUCN_Poptrend_Realm # Run tests: #1. The variable Realm must be present #2. The variable Pop_T must be present #3. The variable IUCN must be present #4. The number of rows must be at least 504 (the total number of primate species) #5. Two records with the same species name must have the same common name and the same genus name v <- validator ("Realm" %in% names(.), "Pop_T" %in% names(.), "IUCN" %in% names(.), nrow(.) >=504, Species ~ CommonName + Genus) cf <- confront(dat, v) summary (cf) barplot(cf, main="IUCN_Poptrend_Realm") ****************************************************************************** LOCOMOTION VALIDATION library(validate) data (Locomotion) dat <- Locomotion # Run tests: #1. The variable Refs must be present #2. The variable Locomotion must be present #3. The number of rows must be at least 504 (the total number of primate species) #4. Two records with the same species name must have the same common name and the same genus name #5. The variable Refs must be larger than 0 #6. The variable Refs must not be larger than 370 (the total number of references) v <- validator ("Refs" %in% names(.), "Locomotion" %in% names(.), nrow(.) >=504, Species ~ CommonName + Genus, Refs >0, Refs <=370) cf <- confront(dat, v) summary (cf) barplot(cf, main="Locomotion") ****************************************************************************** TROPHIC GUILD VALIDATION library(validate) data (TrophicGuild) dat <- TrophicGuild # Run tests: #1. The variable Refs must be present #2. The variable TrophicGuild must be present #3. The number of rows must be at least 504 (the total number of primate species) #4. Two records with the same species name must have the same common name and the same genus name #5. The variable Refs must be larger than 0 #6. The variable Refs must not be larger than 370 (the total number of references) v <- validator ("Refs" %in% names(.), "TrophicGuild" %in% names(.), nrow(.) >=504, Species ~ CommonName + Genus, Refs >0, Refs <=370) cf <- confront(dat, v) summary (cf) barplot(cf, main="TrophicGuild")