require(httr)
require(jsonlite)
require(tidyverse)
VectorByte Dataset Access Script
Pulling data into R
using the VecTraits API (Application Programming Interface)
This section will cover: Retrieving data from the VecTraits database with the API
Load some packages and run some functions …
<- function(dataURL) {
getWebData if (!"httr" %in% installed.packages()) {
cat("Installing necessary httr library...\n")
install.packages("httr")
}if (!"jsonlite" %in% installed.packages()) {
cat("Installing necessary jsonlite library...\n")
install.packages("jsonlite")
}if (!exists("webDataLibrariesOpen")) {
library(httr)
library(jsonlite)
<- TRUE
webDataLibrariesOpen
}<- GET(url = dataURL)
webData if (status_code(webData) >= 300 || status_code(webData) < 200) {
<- data.frame(
returnValue message = "Data fetch failed.",
HTTPcode = status_code(webData)
)return(returnValue)
}<- fromJSON(
returnValue content(webData, "text", encoding = "UTF-8"),
flatten = TRUE
)return(returnValue)
}
<- function(ID = -1) {
getDataset <<- as.integer(getWebData("https://vectorbyte.crc.nd.edu/portal/api/vectraits-explorer/?format=json")$data$count)
totalDatasets if (as.integer(ID) <= totalDatasets && as.integer(ID) > 0) {
<- ID
datasetID else {
} while (TRUE) {
Sys.sleep(0.2)
<- readline(prompt = "Enter a dataset ID: ")
datasetID if (as.integer(datasetID) <= totalDatasets && as.integer(datasetID) > 0) {
break
else {
} cat(paste("The dataset ID", datasetID, "is invalid or is out of range.\n"))
cat(paste("Please choose a number between 1 and", totalDatasets, "\b.\n"))
}
}
}<- getWebData(
dataset paste(
c(
"https://vectorbyte.crc.nd.edu/portal/api/vectraits-dataset/",
datasetID,"/?format=json"
),collapse = ""
)
)if (as.character(dataset)[1] == "Data fetch failed.") {
cat("Uh Oh!\nAn HTTP Error Occured and dataset", datasetID, "could not be retrieved.\n")
cat("HTTP Error Code:", dataset$HTTPcode, "\b\n\n")
}return(dataset)
}
<- function(IDS, safety = TRUE, l = 50L) {
getDatasets Sys.sleep(0.2)
<- IDS
IDs if (length(IDs) > l) {
cat("You may not retrieve more than", l, "datasets at a time.\n")
cat("Would you like to retrieve only the first 50 datasets?\n")
<- tolower(readline())
answer if (grepl("y", answer) && !grepl("n", answer)) {
<- IDs[1:50]
IDs else {
} return()
}
}if (safety && length(IDs) > 50) {
cat("Are you sure you want to retrieve all", length(IDs), "datasets?\n")
cat(paste("This would take about", ceiling(length(IDs) / 50), "min.\n"))
<- tolower(readline())
answer else {
} cat(paste("This will take about", ceiling(60 * length(IDs) / 50), "seconds.\n"))
<- "y"
answer
}if (grepl("y", answer) && !grepl("n", answer)) {
<- length(IDs)
total <- 0
setNumber <<- c()
failedDatasets <- list()
datasets cat("Retrieving datasets....\n")
for (datasetID in IDs) {
<- setNumber + 1
setNumber flush.console()
<- getWebData(
datasets[[setNumber]] paste(
c(
"https://vectorbyte.crc.nd.edu/portal/api/vectraits-dataset/",
as.character(datasetID),
"/?format=json"
),collapse = ""
)
)# Remove previously displayed percentage:
cat(paste(
rep("\b", nchar(
as.character(
floor(10000 * (setNumber - 1) / total) / 100)
(
)+ 3),
) collapse = ""
))# Extend loading bar:
if (as.character(datasets[[setNumber]])[1] == "Data fetch failed.") {
cat("X> ")
<- c(failedDatasets, datasetID)
failedDatasets else {
} cat("=> ")
}# Display new percentage:
cat(as.character(floor(10000 * setNumber / total) / 100), "\b%")
}cat("\b\b\b\b\b\b 100%\nData retrieval complete!\n")
if (length(failedDatasets) > 0) {
cat("The following", length(failedDatasets), "datasets contained HTTP errors and could not be retrieved:\n")
print(failedDatasets)
}return(datasets)
}
}
<- function(KEYWORD = "", safety = TRUE) {
searchDatasets <- KEYWORD
keyword while (nchar(keyword) < 3) {
Sys.sleep(0.2)
<- readline(prompt = "Enter a keyword to search for in all datasets: ")
keyword if (nchar(keyword) < 3) {
cat("Please enter a more descriptive keyword.\n")
}
}cat("Searching Datasets....\n")
flush.console()
<- getWebData(
setSearch paste(
c(
"https://vectorbyte.crc.nd.edu/portal/api/vectraits-explorer/?format=json&keywords=",
gsub(" ", "%20", keyword)
),collapse = ""
)
)if (as.character(setSearch)[1] == "Data fetch failed.") {
cat("Uh Oh!\nAn HTTP error has occurred:", setSearch$HTTPcode, "\n")
cat("This could be because the search term you entered was too general (too many results).\n")
cat("Please try again:\n")
searchDatasets()
else {
} cat(length(setSearch$ids), "relevant datasets found.\n")
return(getDatasets(setSearch$ids, safety))
}
}
<- function(KEYWORDS = c(), safety = TRUE) {
searchDatasetsMulti if (length(KEYWORDS) == 0) {
Sys.sleep(0.2)
cat("Please enter a list of keywords to search for in the datasets:\n")
<- c()
keywords while (length(keywords) == 0) {
<- scan(what = "")
keywords
}else {
} <- KEYWORDS
keywords
}cat("Searching Datasets....\n")
flush.console()
<- getWebData(
setSearch paste(
c(
"https://vectorbyte.crc.nd.edu/portal/api/vectraits-explorer/?format=json&keywords=",
gsub(" ", "%20", paste(keywords, collapse = "%20"))
),collapse = ""
)
)if (as.character(setSearch)[1] == "Data fetch failed.") {
cat("Uh Oh!\nAn HTTP error has occurred:", setSearch$HTTPcode, "\n")
cat("This could be because the search term you entered had too many results.\n")
cat("This could also be because the search term you entered had no results.\n")
cat("Please try again:\n")
searchDatasetsMulti()
else {
} cat(length(setSearch$ids), "relevant datasets found.\n")
return(getDatasets(setSearch$ids, safety))
}
}
<- function(VARIABLE_NAME, VARIABLE_VALUE, OPERATOR = "contains", safety = TRUE) {
smartSearch <- tolower(OPERATOR)
operator if (operator != "contains") {
if (operator == "contain" || operator == "has") { operator <- "contains" }
if (operator == "!contain" || operator == "!contains" || operator == "!has" || operator == "!have" || operator == "does not contain") { operator <- "ncontains" }
if (operator == "=" || operator == "==" || operator == "equal" || operator == "equals") { operator <- "eq" }
if (operator == "!=" || operator == "not" || operator == "!equal" || operator == "!equals") { operator <- "neq" }
if (operator == "starts with" || operator == "start with" || operator == "starts" || operator == "start") { operator <- "sw" }
if (operator == "not start with" || operator == "!start" || operator == "!starts") { operator <- "nsw" }
}<- VARIABLE_NAME
variable_name if (tolower(variable_name) == "genus") { variable_name <- "Interactor1Genus" }
if (tolower(variable_name) == "species") { variable_name <- "Interactor1Species" }
if (tolower(variable_name) == "gender") { variable_name <- "Interactor1Sex" }
if (tolower(variable_name) == "who") { variable_name <- "SubmittedBy" }
if (tolower(variable_name) == "stage") { variable_name <- "Interactor1Stage" }
cat("Searching Datasets....\n")
flush.console()
<- getWebData(
setSearch paste(
c(
"https://vectorbyte.crc.nd.edu/portal/api/vectraits-explorer/?format=json&field=",
gsub(" ", "%20", variable_name),
"&operator=",
operator,"&term=",
gsub(" ", "%20", VARIABLE_VALUE)
),collapse = ""
)
)if (as.character(setSearch)[1] == "Data fetch failed.") {
if (setSearch$HTTPcode == 400) {
cat("Uh Oh!\nThe server does not wish to fulfill your request.\n")
cat("This could be because you included unsupported/reserved URL characters, such as:\n")
cat(", ! @ # $ % ^ & : ; \\ \" ' ? / < > emojis etc.\n")
cat("This could also be because too many results matched your search.\n")
cat("(Don't search for \"Animalia\" in \"Interactor1Kingdom\", for example.)\n")
cat("This could also be because you used the incorrect capitalization in the variable name entry.\n")
if (OPERATOR != "contains") {
cat("This could also very likely be because the operator you entered is not supported.\n")
cat("The following operators are supported by the server:\n")
cat("contains, ncontains, eq (equals), neq (not equal to), sw (starts with),\nnsw (doesn't start with), in, nin\n")
}else {
} cat("Uh Oh!\nAn HTTP error has occurred:", setSearch$HTTPcode, "\n")
if (setSearch$HTTPcode == 404) {
cat("The most likely reason for this is that no results matched your search.")
}
}else {
} cat(length(setSearch$ids), "relevant datasets found.\n")
return(getDatasets(setSearch$ids, safety))
}
}
<- function(DATASET) {
sciName return(paste(
$results$Interactor1Genus[1],
DATASET$results$Interactor1Species[1]
DATASET
))
}
<- function(DATASET) {
datasetRows return(length(DATASET$results$DatasetID))
}
<- function(DATASET) {
datasetColumns return(length(DATASET$results[1,]))
}
<- function(DATASET) {
datasetSummary cat(paste(
toupper(DATASET$results$OriginalTraitDef[1]),
"in",
toupper(DATASET$results$OriginalTraitUnit[1]),
"\b:\n"
))print(summary(DATASET$results$OriginalTraitValue))
if (!is.na(DATASET$results$Interactor1Common[1])) {
cat("Experiments done on", DATASET$results$Interactor1Common[1])
if (is.na(DATASET$results$Interactor2Common[1])) {
cat("s.\n")
else {
} cat(paste(
c(
"s and ",
$results$Interactor2Common[1],
DATASET"s.\n"
),collapse = ""
))
}
}cat(datasetRows(DATASET), "samples total.\n")
}
<- function(SELECTION = 0) {
pick if (SELECTION == 0) {
cat("MENU:\n [1] Retrieve dataset by ID\n [2] Retrieve datasets by IDs\n [3] Search for datasets by keyword\n [4] Search for datasets by list of keywords\n [5] Search for datasets by variable and value\n")
Sys.sleep(0.25)
<- as.integer(readline(prompt = "Enter a number from the menu above to select it. "))
answer else {
} <- SELECTION
answer
}Sys.sleep(0.25)
if (answer == 1) {
return(getDataset())
}if (answer == 2) {
cat("Enter a list of dataset IDs below.\n")
<- scan(what = integer())
datasetIDs return(getDatasets(datasetIDs))
}if (answer == 3) {
return(searchDatasets())
}if (answer == 4) {
return(searchDatasetsMulti())
}if (answer == 5) {
<- readline(prompt = "Variable Name: ")
vname Sys.sleep(0.2)
<- readline(prompt = "Variable Value: ")
vval return(smartSearch(vname, vval))
} }
Examples
<- getDataset(50) # Get dataset with ID 50
dataset50 head(dataset50)
$results
Id DatasetID IndividualID OriginalID OriginalTraitName
1 81848 50 PHX261 fecundity rate
2 81849 50 PHX261 fecundity rate
3 81850 50 PHX261 fecundity rate
4 81851 50 PHX261 fecundity rate
5 81852 50 PHX261 fecundity rate
OriginalTraitDef StandardisedTraitName StandardisedTraitDef
1 mean eggs individual-1 day-1 NA NA
2 mean eggs individual-1 day-1 NA NA
3 mean eggs individual-1 day-1 NA NA
4 mean eggs individual-1 day-1 NA NA
5 mean eggs individual-1 day-1 NA NA
OriginalTraitValue OriginalTraitUnit OriginalErrorPos OriginalErrorNeg
1 3.0 eggs individual-1 day-1 51.7 51.7
2 6.3 eggs individual-1 day-1 33.4 33.4
3 9.6 eggs individual-1 day-1 36.3 36.3
4 12.5 eggs individual-1 day-1 45.7 45.7
5 5.8 eggs individual-1 day-1 75.2 75.2
OriginalErrorUnit StandardisedTraitValue StandardisedTraitUnit
1 coefficient of variance NA NA
2 coefficient of variance NA NA
3 coefficient of variance NA NA
4 coefficient of variance NA NA
5 coefficient of variance NA NA
StandardisedErrorPos StandardisedErrorNeg StandardisedErrorUnit Replicates
1 NA NA NA NA
2 NA NA NA NA
3 NA NA NA NA
4 NA NA NA NA
5 NA NA NA NA
Habitat LabField ArenaValue ArenaUnit ArenaValueSI ArenaUnitSI
1 terrestrial laboratory NA NA NA NA
2 terrestrial laboratory NA NA NA NA
3 terrestrial laboratory NA NA NA NA
4 terrestrial laboratory NA NA NA NA
5 terrestrial laboratory NA NA NA NA
AmbientTemp AmbientTempMethod AmbientTempUnit AmbientLight AmbientLightUnit
1 NA NA NA NA NA
2 NA NA NA NA NA
3 NA NA NA NA NA
4 NA NA NA NA NA
5 NA NA NA NA NA
SecondStressor SecondStressorDef SecondStressorValue SecondStressorUnit
1 NA NA NA NA
2 NA NA NA NA
3 NA NA NA NA
4 NA NA NA NA
5 NA NA NA NA
TimeStart TimeEnd TotalObsTimeValue TotalObsTimeUnit TotalObsTimeValueSI
1 NA NA NA NA NA
2 NA NA NA NA NA
3 NA NA NA NA NA
4 NA NA NA NA NA
5 NA NA NA NA NA
TotalObsTimeUnitSI TotalObsTimeNotes ResRepValue ResRepUnit ResRepValueSI
1 NA NA NA NA NA
2 NA NA NA NA NA
3 NA NA NA NA NA
4 NA NA NA NA NA
5 NA NA NA NA NA
ResRepUnitSI LocationText LocationType OriginalLocationDate LocationDate
1 NA Dryden New York NA NA 1974-01-06
2 NA Dryden New York NA NA 1974-01-06
3 NA Dryden New York NA NA 1974-01-06
4 NA Dryden New York NA NA 1974-01-06
5 NA Dryden New York NA NA 1974-01-06
LocationDatePrecision CoordinateType Latitude Longitude Interactor1
1 3 decimal 42.48917 -76.35972 Sepedon fuscipennis
2 3 decimal 42.48917 -76.35972 Sepedon fuscipennis
3 3 decimal 42.48917 -76.35972 Sepedon fuscipennis
4 3 decimal 42.48917 -76.35972 Sepedon fuscipennis
5 3 decimal 42.48917 -76.35972 Sepedon fuscipennis
Interactor1Common Interactor1Wholepart Interactor1WholePartType
1 Marsh fly NA NA
2 Marsh fly NA NA
3 Marsh fly NA NA
4 Marsh fly NA NA
5 Marsh fly NA NA
Interactor1Number Interactor1Kingdom Interactor1Phylum Interactor1Class
1 17 Animalia Arthropoda Insecta
2 59 Animalia Arthropoda Insecta
3 54 Animalia Arthropoda Insecta
4 52 Animalia Arthropoda Insecta
5 24 Animalia Arthropoda Insecta
Interactor1Order Interactor1Family Interactor1Genus Interactor1Species
1 Diptera Sciomyzidae Sepedon fuscipennis
2 Diptera Sciomyzidae Sepedon fuscipennis
3 Diptera Sciomyzidae Sepedon fuscipennis
4 Diptera Sciomyzidae Sepedon fuscipennis
5 Diptera Sciomyzidae Sepedon fuscipennis
Interactor1Stage Interactor1Sex Interactor1Temp Interactor1TempUnit
1 adult female 15 Celsius
2 adult female 21 Celsius
3 adult female 26 Celsius
4 adult female 30 Celsius
5 adult female 33 Celsius
Interactor1TempMethod Interactor1GrowthTemp Interactor1GrowthTempUnit
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor1GrowthDur Interactor1GrowthdDurUnit Interactor1GrowthType
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor1Acc Interactor1AccTemp Interactor1AccTempNotes Interactor1AccTime
1 NA NA NA NA
2 NA NA NA NA
3 NA NA NA NA
4 NA NA NA NA
5 NA NA NA NA
Interactor1AccTimeNotes Interactor1AccTimeUnit Interactor1OrigTemp
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor1OrigTempNotes Interactor1OrigTime Interactor1OrigTimeNotes
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor1OrigTimeUnit Interactor1EquilibTimeValue
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
Interactor1EquilibTimeUnit Interactor1Size Interactor1SizeUnit
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor1SizeType Interactor1SizeSI Interactor1SizeUnitSI
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor1DenValue Interactor1DenUnit Interactor1DenTypeSI
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor1DenValueSI Interactor1DenUnitSI Interactor1MassValueSI
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor1MassUnitSI Interactor2 Interactor2Common Interactor2Kingdom
1 NA None None NA NA
2 NA None None NA NA
3 NA None None NA NA
4 NA None None NA NA
5 NA None None NA NA
Interactor2Phylum Interactor2Class Interactor2Order Interactor2Family
1 NA NA NA NA
2 NA NA NA NA
3 NA NA NA NA
4 NA NA NA NA
5 NA NA NA NA
Interactor2Genus Interactor2Species Interactor2Stage Interactor2Sex
1 NA NA NA NA
2 NA NA NA NA
3 NA NA NA NA
4 NA NA NA NA
5 NA NA NA NA
Interactor2Temp Interactor2TempUnit Interactor2TempMethod
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor2GrowthTemp Interactor2GrowthTempUnit Interactor2GrowthDur
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor2GrowthDurUnit Interactor2GrowthType Interactor2Acc
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor2AccTemp Interactor2AccTempNotes Interactor2AccTime
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor2AccTimeNotes Interactor2AccTimeUnit Interactor2OrigTemp
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor2OrigTempNotes Interactor2OrigTime Interactor2OrigTimeNotes
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor2OrigTimeUnit Interactor2EquilibTimeValue
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
Interactor2EquilibTimeUnit Interactor2Size Interactor2SizeUnit
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor2SizeType Interactor2SizeSI Interactor2SizeUnitSI
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor2DenValue Interactor2DenUnit Interactor2DenTypeSI
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor2DenValueSI Interactor2DenUnitSI Interactor2MassValueSI
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
Interactor2MassUnitSI PhysicalProcess PhysicalProcess_1 PhysicalProcess_2
1 NA NA NA NA
2 NA NA NA NA
3 NA NA NA NA
4 NA NA NA NA
5 NA NA NA NA
FigureTable
1 table 1
2 table 1
3 table 1
4 table 1
5 table 1
Citation
1 Barnes 1976. Effect of temperature on development survival oviposition and diapause in laboratory populations of Sepedon fuscipennis (Diptera: Sciomyzidae). Environ. Entomol. 5: 1089-1098
2 Barnes 1976. Effect of temperature on development survival oviposition and diapause in laboratory populations of Sepedon fuscipennis (Diptera: Sciomyzidae). Environ. Entomol. 5: 1089-1098
3 Barnes 1976. Effect of temperature on development survival oviposition and diapause in laboratory populations of Sepedon fuscipennis (Diptera: Sciomyzidae). Environ. Entomol. 5: 1089-1098
4 Barnes 1976. Effect of temperature on development survival oviposition and diapause in laboratory populations of Sepedon fuscipennis (Diptera: Sciomyzidae). Environ. Entomol. 5: 1089-1098
5 Barnes 1976. Effect of temperature on development survival oviposition and diapause in laboratory populations of Sepedon fuscipennis (Diptera: Sciomyzidae). Environ. Entomol. 5: 1089-1098
CuratedByCitation CuratedByDOI DOI SubmittedBy
1 NA NA 10.1093/ee/5.6.1089 Paul Huxley
2 NA NA 10.1093/ee/5.6.1089 Paul Huxley
3 NA NA 10.1093/ee/5.6.1089 Paul Huxley
4 NA NA 10.1093/ee/5.6.1089 Paul Huxley
5 NA NA 10.1093/ee/5.6.1089 Paul Huxley
ContributorEmail Notes DefaultChartXaxis DefaultChartCategory
1 phuxly@gmail.com NA Interactor1Temp LocationText
2 phuxly@gmail.com NA Interactor1Temp LocationText
3 phuxly@gmail.com NA Interactor1Temp LocationText
4 phuxly@gmail.com NA Interactor1Temp LocationText
5 phuxly@gmail.com NA Interactor1Temp LocationText
Get a list of datasets by their ID numbers:
<- getDatasets(c(1:10)) list_of_dataframes
This will take about 12 seconds.
Retrieving datasets....
=> 10 %=> 20 %=> 30 %=> 40 %=> 50 %=> 60 %=> 70 %=> 80 %=> 90 %=> 100 % 100%
Data retrieval complete!
Use do.call
and lapply
to create a single dataframe containing all of the datasets you pulled in the previous step:
<- do.call(rbind,lapply(list_of_dataframes, data.frame, stringsAsFactors=FALSE))
datasets1to10 head(datasets1to10)
results.Id results.DatasetID results.IndividualID results.OriginalID
1 81518 1 PHX801
2 81519 1 PHX801
3 81520 1 PHX801
4 81521 1 PHX801
5 81522 1 PHX801
6 81523 2 PHX802
results.OriginalTraitName results.OriginalTraitDef
1 development time mean duration of life stage
2 development time mean duration of life stage
3 development time mean duration of life stage
4 development time mean duration of life stage
5 development time mean duration of life stage
6 fecundity mean lifetime offspring
results.StandardisedTraitName results.StandardisedTraitDef
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.OriginalTraitValue results.OriginalTraitUnit results.OriginalErrorPos
1 21.3 days 0.31
2 12.2 days 0.23
3 8.3 days 0.16
4 6.7 days 0.16
5 6.5 days 0.26
6 51.5 offspring individual-1 3.93
results.OriginalErrorNeg results.OriginalErrorUnit
1 0.31 se
2 0.23 se
3 0.16 se
4 0.16 se
5 0.26 se
6 3.93 se
results.StandardisedTraitValue results.StandardisedTraitUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.StandardisedErrorPos results.StandardisedErrorNeg
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.StandardisedErrorUnit results.Replicates results.Habitat
1 NA NA terrestrial
2 NA NA terrestrial
3 NA NA terrestrial
4 NA NA terrestrial
5 NA NA terrestrial
6 NA NA terrestrial
results.LabField results.ArenaValue results.ArenaUnit results.ArenaValueSI
1 laboratory NA NA NA
2 laboratory NA NA NA
3 laboratory NA NA NA
4 laboratory NA NA NA
5 laboratory NA NA NA
6 laboratory NA NA NA
results.ArenaUnitSI results.AmbientTemp results.AmbientTempMethod
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
6 NA NA NA
results.AmbientTempUnit results.AmbientLight results.AmbientLightUnit
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
6 NA NA NA
results.SecondStressor results.SecondStressorDef results.SecondStressorValue
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
6 NA NA NA
results.SecondStressorUnit results.TimeStart results.TimeEnd
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
6 NA NA NA
results.TotalObsTimeValue results.TotalObsTimeUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.TotalObsTimeValueSI results.TotalObsTimeUnitSI
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.TotalObsTimeNotes results.ResRepValue results.ResRepUnit
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
6 NA NA NA
results.ResRepValueSI results.ResRepUnitSI results.LocationText
1 NA NA Nonsan-si Republic of Korea
2 NA NA Nonsan-si Republic of Korea
3 NA NA Nonsan-si Republic of Korea
4 NA NA Nonsan-si Republic of Korea
5 NA NA Nonsan-si Republic of Korea
6 NA NA Nonsan-si Republic of Korea
results.LocationType results.OriginalLocationDate results.LocationDate
1 field NA 2009-01-01
2 field NA 2009-01-01
3 field NA 2009-01-01
4 field NA 2009-01-01
5 field NA 2009-01-01
6 field NA 2009-01-01
results.LocationDatePrecision results.CoordinateType results.Latitude
1 1 decimal 36.5
2 1 decimal 36.5
3 1 decimal 36.5
4 1 decimal 36.5
5 1 decimal 36.5
6 1 decimal 36.5
results.Longitude results.Interactor1 results.Interactor1Common
1 126.75 Acyrthosiphon pisum Pea aphid
2 126.75 Acyrthosiphon pisum Pea aphid
3 126.75 Acyrthosiphon pisum Pea aphid
4 126.75 Acyrthosiphon pisum Pea aphid
5 126.75 Acyrthosiphon pisum Pea aphid
6 126.75 Acyrthosiphon pisum Pea aphid
results.Interactor1Wholepart results.Interactor1WholePartType
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1Number results.Interactor1Kingdom
1 39 Animalia
2 53 Animalia
3 45 Animalia
4 42 Animalia
5 8 Animalia
6 50 Animalia
results.Interactor1Phylum results.Interactor1Class results.Interactor1Order
1 Arthropoda Insecta Hemiptera
2 Arthropoda Insecta Hemiptera
3 Arthropoda Insecta Hemiptera
4 Arthropoda Insecta Hemiptera
5 Arthropoda Insecta Hemiptera
6 Arthropoda Insecta Hemiptera
results.Interactor1Family results.Interactor1Genus results.Interactor1Species
1 Aphididae Acyrthosiphon pisum
2 Aphididae Acyrthosiphon pisum
3 Aphididae Acyrthosiphon pisum
4 Aphididae Acyrthosiphon pisum
5 Aphididae Acyrthosiphon pisum
6 Aphididae Acyrthosiphon pisum
results.Interactor1Stage results.Interactor1Sex results.Interactor1Temp
1 juvenile <NA> 10
2 juvenile <NA> 15
3 juvenile <NA> 20
4 juvenile <NA> 25
5 juvenile <NA> 30
6 adult female 10
results.Interactor1TempUnit results.Interactor1TempMethod
1 Celsius NA
2 Celsius NA
3 Celsius NA
4 Celsius NA
5 Celsius NA
6 Celsius NA
results.Interactor1GrowthTemp results.Interactor1GrowthTempUnit
1 NA <NA>
2 NA <NA>
3 NA <NA>
4 NA <NA>
5 NA <NA>
6 NA <NA>
results.Interactor1GrowthDur results.Interactor1GrowthdDurUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1GrowthType results.Interactor1Acc
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1AccTemp results.Interactor1AccTempNotes
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1AccTime results.Interactor1AccTimeNotes
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1AccTimeUnit results.Interactor1OrigTemp
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1OrigTempNotes results.Interactor1OrigTime
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1OrigTimeNotes results.Interactor1OrigTimeUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1EquilibTimeValue results.Interactor1EquilibTimeUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1Size results.Interactor1SizeUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1SizeType results.Interactor1SizeSI
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1SizeUnitSI results.Interactor1DenValue
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1DenUnit results.Interactor1DenTypeSI
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1DenValueSI results.Interactor1DenUnitSI
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor1MassValueSI results.Interactor1MassUnitSI
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2 results.Interactor2Common results.Interactor2Kingdom
1 None None NA NA
2 None None NA NA
3 None None NA NA
4 None None NA NA
5 None None NA NA
6 None None NA NA
results.Interactor2Phylum results.Interactor2Class results.Interactor2Order
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
6 NA NA NA
results.Interactor2Family results.Interactor2Genus results.Interactor2Species
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
6 NA NA NA
results.Interactor2Stage results.Interactor2Sex results.Interactor2Temp
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
6 NA NA NA
results.Interactor2TempUnit results.Interactor2TempMethod
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2GrowthTemp results.Interactor2GrowthTempUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2GrowthDur results.Interactor2GrowthDurUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2GrowthType results.Interactor2Acc
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2AccTemp results.Interactor2AccTempNotes
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2AccTime results.Interactor2AccTimeNotes
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2AccTimeUnit results.Interactor2OrigTemp
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2OrigTempNotes results.Interactor2OrigTime
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2OrigTimeNotes results.Interactor2OrigTimeUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2EquilibTimeValue results.Interactor2EquilibTimeUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2Size results.Interactor2SizeUnit
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2SizeType results.Interactor2SizeSI
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2SizeUnitSI results.Interactor2DenValue
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2DenUnit results.Interactor2DenTypeSI
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2DenValueSI results.Interactor2DenUnitSI
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.Interactor2MassValueSI results.Interactor2MassUnitSI
1 NA NA
2 NA NA
3 NA NA
4 NA NA
5 NA NA
6 NA NA
results.PhysicalProcess results.PhysicalProcess_1 results.PhysicalProcess_2
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 NA NA NA
5 NA NA NA
6 NA NA NA
results.FigureTable
1 table 1
2 table 1
3 table 1
4 table 1
5 table 1
6 table 1
results.Citation
1 Ahn et al. 2020. Thermal effects on the population parameters and growth of Acyrthosiphon pisum (Harris) (Hemiptera: Aphididae). Insects 11:8
2 Ahn et al. 2020. Thermal effects on the population parameters and growth of Acyrthosiphon pisum (Harris) (Hemiptera: Aphididae). Insects 11:8
3 Ahn et al. 2020. Thermal effects on the population parameters and growth of Acyrthosiphon pisum (Harris) (Hemiptera: Aphididae). Insects 11:8
4 Ahn et al. 2020. Thermal effects on the population parameters and growth of Acyrthosiphon pisum (Harris) (Hemiptera: Aphididae). Insects 11:8
5 Ahn et al. 2020. Thermal effects on the population parameters and growth of Acyrthosiphon pisum (Harris) (Hemiptera: Aphididae). Insects 11:8
6 Ahn et al. 2020. Thermal effects on the population parameters and growth of Acyrthosiphon pisum (Harris) (Hemiptera: Aphididae). Insects 11:8
results.CuratedByCitation results.CuratedByDOI results.DOI
1 NA NA 10.3390/insects11080481
2 NA NA 10.3390/insects11080481
3 NA NA 10.3390/insects11080481
4 NA NA 10.3390/insects11080481
5 NA NA 10.3390/insects11080481
6 NA NA 10.3390/insects11080481
results.SubmittedBy results.ContributorEmail results.Notes
1 Paul Huxley phuxly@gmail.com reared on faba bean leaves
2 Paul Huxley phuxly@gmail.com reared on faba bean leaves
3 Paul Huxley phuxly@gmail.com reared on faba bean leaves
4 Paul Huxley phuxly@gmail.com reared on faba bean leaves
5 Paul Huxley phuxly@gmail.com reared on faba bean leaves
6 Paul Huxley phuxly@gmail.com reared on faba bean leaves
results.DefaultChartXaxis results.DefaultChartCategory
1 Interactor1Temp LocationText
2 Interactor1Temp LocationText
3 Interactor1Temp LocationText
4 Interactor1Temp LocationText
5 Interactor1Temp LocationText
6 Interactor1Temp LocationText
Remove unneeded prefixes from column names
<- datasets1to10 %>%
datasets1to10 `colnames<-`(str_to_lower(colnames(.))) %>%
`colnames<-`(str_remove(colnames(.), "(results)")) %>%
`colnames<-`(str_remove(colnames(.), "."))
Search for and list datasets on a specific genus
<- searchDatasets("Aedes") list_of_AedesDatasets
Searching Datasets....
80 relevant datasets found.
You may not retrieve more than 50 datasets at a time.
Would you like to retrieve only the first 50 datasets?
This will prompt you with something like the following:
“Searching Datasets…. 80 relevant datasets found. You may not retrieve more than 50 datasets at a time. Would you like to retrieve only the first 50 datasets?”
To which you can respond with “Y” and run the following code to …
Print a list of datasets on Aedes mosquitoes
for (i in 1:length(list_of_AedesDatasets)) {
print(list_of_AedesDatasets[[i]]$results$DatasetID[1])
}
You can then use the code above to pull all of the data that’s currently in VecTraits on Aedes
Other options
Retrieve Multiple Datasets by Their IDs
Format:
list_of_dataframes <- getDatasets(<Vector, List, or Range of IDs>)
Examples:
<- getDatasets(c(10, 20, 35)) # Get datasets 10, 20, and 35 list_of_dataframes
This will take about 4 seconds.
Retrieving datasets....
=> 33.33 %=> 66.66 %=> 100 % 100%
Data retrieval complete!
<- getDatasets(seq(200, 240, 10)) # Get datasets 200, 210, 220, 230, and 240 list_of_dataframes
This will take about 6 seconds.
Retrieving datasets....
=> 20 %=> 40 %=> 60 %=> 80 %=> 100 % 100%
Data retrieval complete!
<- getDatasets(list(50, 1, 580, 20)) # Get datasets 1, 20, 50, and 580 list_of_dataframes
This will take about 5 seconds.
Retrieving datasets....
=> 25 %=> 50 %=> 75 %=> 100 % 100%
Data retrieval complete!
<- getDatasets(320:324) # Get datasets 320, 321, 322, 323, and 324 list_of_dataframes
This will take about 6 seconds.
Retrieving datasets....
=> 20 %=> 40 %=> 60 %=> 80 %=> 100 % 100%
Data retrieval complete!
Retrieve List of Datasets By Column Values
Format:
list_of_dataframes <- smartSearch(<Column Name>, <Column Value>, <Optional Operator>)
Examples:
<- smartSearch("Interactor1Genus", "culex") # Datasets with genus Culex list_of_dataframes
Searching Datasets....
17 relevant datasets found.
This will take about 21 seconds.
Retrieving datasets....
=> 5.88 %=> 11.76 %=> 17.64 %=> 23.52 %=> 29.41 %=> 35.29 %=> 41.17 %=> 47.05 %=> 52.94 %=> 58.82 %=> 64.7 %=> 70.58 %=> 76.47 %=> 82.35 %=> 88.23 %=> 94.11 %=> 100 % 100%
Data retrieval complete!
<- smartSearch("SubmittedBy", "Lachance") # Datasets submitted by Lachance list_of_dataframes
Searching Datasets....
22 relevant datasets found.
This will take about 27 seconds.
Retrieving datasets....
=> 4.54 %=> 9.09 %=> 13.63 %=> 18.18 %=> 22.72 %=> 27.27 %=> 31.81 %=> 36.36 %=> 40.9 %=> 45.45 %=> 50 %=> 54.54 %=> 59.09 %=> 63.63 %=> 68.18 %=> 72.72 %=> 77.27 %=> 81.81 %=> 86.36 %=> 90.9 %=> 95.45 %=> 100 % 100%
Data retrieval complete!
<- smartSearch("Interactor2Species", "null", "neq") # Datasets with second interactor list_of_dataframes
Searching Datasets....
51 relevant datasets found.
You may not retrieve more than 50 datasets at a time.
Would you like to retrieve only the first 50 datasets?
<- smartSearch("OriginalTraitName", "survival", "eq") # Datasets strictly about survival list_of_dataframes
Searching Datasets....
75 relevant datasets found.
You may not retrieve more than 50 datasets at a time.
Would you like to retrieve only the first 50 datasets?
The pick()
Function
If all the information above was too much and there’s no way you’re going to remember it, all you need to know is the pick()
function. The pick()
function displays a small menu and allows you to choose an option in order for you to find and retrieve whatever dataset(s) you may be looking for.
Format:
x <- pick()
Access Dataframes In Lists
When multiple datasets are retrieved and stored in a list of dataframes, you can access individual datasets with the following format:
first_dataframe <- list_of_dataframes[[1]]
second_dataframe <- list_of_dataframes[[2]]
…and so on for every dataframe in the list.
Example:
To print a list of the names of those who contributed to the datasets related to tiger mosquitos:
<- searchDatasets("tiger mosquito") list_of_dataframes
Searching Datasets....
17 relevant datasets found.
This will take about 21 seconds.
Retrieving datasets....
=> 5.88 %=> 11.76 %=> 17.64 %=> 23.52 %=> 29.41 %=> 35.29 %=> 41.17 %=> 47.05 %=> 52.94 %=> 58.82 %=> 64.7 %=> 70.58 %=> 76.47 %=> 82.35 %=> 88.23 %=> 94.11 %=> 100 % 100%
Data retrieval complete!
for (i in 1:length(list_of_dataframes)) {
print(list_of_dataframes[[i]]$results$SubmittedBy[1])
}
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Lauren Chapman"
[1] "Paul Huxley"
[1] "Paul Huxley"
[1] "Lauren Chapman"
[1] "Lauren Chapman"
[1] "Lauren Chapman"
Access Data In Dataframes
To access variable x
in row y
of a dataset stored as a dataframe, use the $
symbol and square brackets []
:
variable_value <- dataframe$results$x[y]
For example, if you had a dataset stored as a dataframe and you wanted to know the Genus of Interactor 1 in the fifth row, you could get that with the following code:
dataframe$results$Interactor1Genus[5]
The same format also works for dataframes in lists. For example, you could run the following to get the original trait value in row 3 of the fourth dataset in the list:
list_of_dataframes[[4]]$results$OriginalTraitValue[3]
The same format also works on raw functions, although it is recommended that retrieved datasets are immediately stored in an R
object:
getDataset(5)$results$SubmittedBy[1] # Name of person who submitted the dataset with ID 5
Minor Additional Functions
datasetSummary(DATASET)
Summary: Prints summary of data within dataset Parameters: DATASET = A dataset as a dataframe, such as getDataset(1) Returns: Nothing
sciName(DATASET)
Summary: Finds the scientific name of the main interactor within the dataset Parameters: DATASET = A dataset as a dataframe, such as getDataset(1) Returns: Scientific Name of main interactor within dataset, as string
datasetRows(DATASET)
Summary: Finds the number of rows/samples in a dataset Parameters: DATASET = A dataset as a dataframe, such as getDataset(1) Returns: Number of rows, as integer
datasetColumns(DATASET)
Summary: Finds the number of columns/variables in a dataset Parameters: DATASET = A dataset as a dataframe, such as getDataset(1) Returns: Number of columns, as integer