28
28
# ' }
29
29
# ' @examples \dontrun{
30
30
# ' worms_records(scientific='Salmo')
31
+ # ' worms_records(scientific=c('Salmo','Aphanius'))
31
32
# ' worms_records(scientific='Liopsetta glacialis')
32
33
# ' worms_records(common='salmon')
34
+ # ' worms_records(common=c('salmon','char'))
33
35
# ' worms_records(startdate='2014-06-01T00:00:00', enddate='2014-06-02T00:00:00')
34
- # ' worms_records(id =1080)
35
- # ' worms_records(extid =6830, type='ncbi')
36
+ # ' worms_records(ids =1080)
37
+ # ' worms_records(extids =6830, type='ncbi')
36
38
# ' }
37
- worms_records <- function (scientific = NULL , common = NULL , id = NULL , extid = NULL , like = NULL , type = NULL ,
39
+ worms_records <- function (scientific = NULL , common = NULL , ids = NULL , extids = NULL , like = NULL , type = NULL ,
38
40
marine_only = 1 , offset = NULL , startdate = NULL , enddate = NULL , opts = NULL , iface = NULL , ... )
39
41
{
40
42
server <- ' http://www.marinespecies.org/aphia.php?p=soap'
@@ -43,21 +45,22 @@ worms_records <- function(scientific=NULL, common=NULL, id=NULL, extid=NULL, lik
43
45
' getAphiaRecordsByVernacular'
44
46
} else if (! is.null(startdate )|! is.null(enddate )) {
45
47
' getAphiaRecordsByDate'
46
- } else if (! is.null(extid )) {
48
+ } else if (! is.null(extids )) {
47
49
' getAphiaRecordByExtID'
48
- } else if (! is.null(id )){
50
+ } else if (! is.null(ids )){
49
51
' getAphiaRecordByID'
50
52
} else {
51
53
if (length(scientific ) > 1 ) ' getAphiaRecordsByNames' else ' getAphiaRecords'
52
54
}
53
55
fxn <- worms_get_fxn(endpt )
54
56
res <- switch (endpt ,
55
- getAphiaRecords = fxn( scientificname = scientific , like = like , fuzzy = ' false' , marine_only = marine_only , offset = ' false' , server = server , .opts = opts , ... ),
56
- getAphiaRecordsByNames = fxn( scientificname = scientific , like = like , fuzzy = ' false' , marine_only = marine_only , server = server , .opts = opts , ... ),
57
- getAphiaRecordsByVernacular = fxn( vernacular = common , like = like , offset = offset , server = server , .opts = opts , ... ),
58
- getAphiaRecordsByDate = fxn (startdate = startdate , enddate = enddate , marine_only = marine_only , offset = offset , server = server , .opts = opts , ... ),
59
- getAphiaRecordByID = fxn( AphiaID = id , server = server , .opts = opts , ... ),
60
- getAphiaRecordByExtID = fxn( id = extid , type = type , server = server , .opts = opts , ... )
57
+ getAphiaRecords = lapply( scientific , fxn , like = like , fuzzy = ' false' , marine_only = marine_only , offset = ' false' , server = server , .opts = opts , ... ),
58
+ getAphiaRecordsByNames = lapply( scientific , fxn , like = like , fuzzy = ' false' , marine_only = marine_only , server = server , .opts = opts , ... ),
59
+ getAphiaRecordsByVernacular = lapply( common , fxn , like = like , offset = offset , server = server , .opts = opts , ... ),
60
+ getAphiaRecordsByDate = lapply (startdate , fxn , enddate = enddate , marine_only = marine_only , offset = offset , server = server , .opts = opts , ... ),
61
+ getAphiaRecordByID = lapply( ids , fxn , server = server , .opts = opts , ... ),
62
+ getAphiaRecordByExtID = lapply( extids , fxn , type = type , server = server , .opts = opts , ... )
61
63
)
62
- do.call(rbind , lapply(res , function (y ) data.frame (unclass(y ), stringsAsFactors = FALSE )))
64
+ names(res ) <- switch (endpt , getAphiaRecords = scientific , getAphiaRecordsByNames = scientific , getAphiaRecordsByVernacular = common , getAphiaRecordsByDate = startdate , getAphiaRecordByID = ids , getAphiaRecordByExtID = extids )
65
+ parse_data_byname(res )
63
66
}
0 commit comments