Skip to content

Commit

Permalink
Merge pull request #58 from EDiLD/fix_quick
Browse files Browse the repository at this point in the history
Fix issue #48
  • Loading branch information
Eduard Szöcs committed Nov 29, 2012
2 parents 5072f7f + 02b0e4c commit cd43105
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions R/get_tsn.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,22 @@ get_tsn <- function (searchterm, searchtype = "sciname", verbose = TRUE)
# check for direct match
if (nrow(tsn_df) > 1){
direct <- match(tolower(x), tolower(tsn_df$combinedname))
tsn <- tsn_df$tsn[direct]
if(!is.na(direct))
tsn <- tsn_df$tsn[direct]
}
# user prompt
if (nrow(tsn_df) > 1 & !exists('direct')){
if (nrow(tsn_df) > 1 & is.na(direct)){
cat("\n\n")
print(tsn_df)
cat("\nMore than one TSN found for species '", x, "'!\n
Enter rowname of species to take:\n") # prompt
take <- scan(n = 1, quiet = TRUE)
Enter rownumber of species (other inputs will return 'NA'):\n") # prompt
take <- scan(n = 1, quiet = TRUE, what = 'raw')
if(take %in% seq_len(nrow(tsn_df))){
take <- as.numeric(take)
cat("Input accepted, took species '", as.character(tsn_df$combinedname[take]), "'.\n")
} else {
stop("Non valid input!\n")
tsn <- NA
cat("Returned 'NA'")
}
tsn <- tsn_df$tsn[take]
}
Expand Down

0 comments on commit cd43105

Please sign in to comment.