{"action":"created","issue":{"url":"https://api.github.com/repos/ropensci/rfishbase/issues/38","labels_url":"https://api.github.com/repos/ropensci/rfishbase/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/ropensci/rfishbase/issues/38/comments","events_url":"https://api.github.com/repos/ropensci/rfishbase/issues/38/events","html_url":"https://github.com/ropensci/rfishbase/issues/38","id":65579997,"number":38,"title":"validate_names returns array of suggestions errantly","user":{"login":"sartonic","id":11744467,"avatar_url":"https://avatars.githubusercontent.com/u/11744467?v=3","gravatar_id":"","url":"https://api.github.com/users/sartonic","html_url":"https://github.com/sartonic","followers_url":"https://api.github.com/users/sartonic/followers","following_url":"https://api.github.com/users/sartonic/following{/other_user}","gists_url":"https://api.github.com/users/sartonic/gists{/gist_id}","starred_url":"https://api.github.com/users/sartonic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sartonic/subscriptions","organizations_url":"https://api.github.com/users/sartonic/orgs","repos_url":"https://api.github.com/users/sartonic/repos","events_url":"https://api.github.com/users/sartonic/events{/privacy}","received_events_url":"https://api.github.com/users/sartonic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-01T01:16:41Z","updated_at":"2015-04-01T20:14:06Z","closed_at":null,"body":"I am using validate_names on a list of over 1000 scientific names, which are mostly correct, but may have small spelling errors occasionally. I've included a subset of the species below.\r\n\r\n```\r\n> species = c(\"Ablennes hians\", \"Acanthopagrus schlegeli\", \"Acanthopagrus berda\", \"Auxis thazard\", \"Auxis rochei\")\r\n```\r\n\r\nOf these species, I can (after-the-fact) verify that A. schegeli, A. thazard, and A. rochei are misspelled. However, when I run validate_names, several interesting things happen...\r\n\r\n```\r\n> validate_names(species)\r\n\r\n[[1]]\r\n[1] \"Ablennes hians\"\r\n\r\n[[2]]\r\n[1] \"Acanthopagrus schlegelii schlegelii\"\r\n\r\n[[3]]\r\n[1] \"Acanthopagrus berda\"     \"Acanthopagrus vagus\"     \"Acanthopagrus pacificus\"\r\n\r\n[[4]]\r\n[1] \"Auxis rochei rochei\"   \"Auxis thazard thazard\"\r\n\r\n[[5]]\r\n[1] \"Auxis rochei rochei\"\r\n\r\n```\r\n\r\nThe function returns an array of arrays. Within that...\r\n1) A. hians had no spelling issues, and was returned correctly;\r\n2) A. schlegelii had a spelling issue and returned fixed;\r\n3) A. berda had no spelling issues, but an array of alternatives were also returned;\r\n4) A. thazard was misspelled, and was returned fixed, but placed second in an array of alternatives;\r\n5) A. rochei was misspelled, and was returned fixed.\r\n\r\nIt seems like there are two issues here. The first is that even when there is an exact string match, an array of suggestions is returned (#3), when I would have thought that just the original string would be returned. Is this intentional? Second, when a species names does need to be corrected, the closest match isn't always returned first in the array of suggestions (#4). \r\n\r\nFor me, ideally only the best match would be returned, and at the very least the best match would be returned first in an array of alternatives. This is because, now, if I use this array of arrays as an input to another function, like species_info, only the first entry of each array is used as the species name parameter. This leads to duplication issues, and left out A. thazard entirely, as you can see below.\r\n\r\n```\r\n> speciesList = validate_names(species)\r\n> species_info(speciesList, fields = c(\"SpecCode\", \"Genus\", \"Species\", \"FBname\"))\r\n\r\nSource: local data frame [5 x 4]\r\n\r\n  SpecCode         Genus               Species             FBname\r\n1      972      Ablennes                 hians    Flat needlefish\r\n2     6531 Acanthopagrus schlegelii schlegelii Blackhead seabream\r\n3     5526 Acanthopagrus                 berda  Goldsilk seabream\r\n4       93         Auxis         rochei rochei        Bullet tuna\r\n5       93         Auxis         rochei rochei        Bullet tuna\r\n```"},"comment":{"url":"https://api.github.com/repos/ropensci/rfishbase/issues/comments/88618580","html_url":"https://github.com/ropensci/rfishbase/issues/38#issuecomment-88618580","issue_url":"https://api.github.com/repos/ropensci/rfishbase/issues/38","id":88618580,"user":{"login":"cboettig","id":222586,"avatar_url":"https://avatars.githubusercontent.com/u/222586?v=3","gravatar_id":"","url":"https://api.github.com/users/cboettig","html_url":"https://github.com/cboettig","followers_url":"https://api.github.com/users/cboettig/followers","following_url":"https://api.github.com/users/cboettig/following{/other_user}","gists_url":"https://api.github.com/users/cboettig/gists{/gist_id}","starred_url":"https://api.github.com/users/cboettig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cboettig/subscriptions","organizations_url":"https://api.github.com/users/cboettig/orgs","repos_url":"https://api.github.com/users/cboettig/repos","events_url":"https://api.github.com/users/cboettig/events{/privacy}","received_events_url":"https://api.github.com/users/cboettig/received_events","type":"User","site_admin":false},"created_at":"2015-04-01T20:14:06Z","updated_at":"2015-04-01T20:14:06Z","body":"Re: ecology() vs species_info(), every species FishBase knows about has an\nentry in the species_info() table (it's somewhat analogous to the\nsummary/home-page you see for the species on the website); but not every\nspecies has an entry in the ecology() table -- for some species fishbase\njust doesn't have trophic ecology information.  On the website you'll see a\nlist of tables on every summary page that is called \"additional\ninformation\", and all missing tables are just grayed out.\n\necology() is pretty good; other tables are even more sparse.\n\n\nRe: the connection being broken -- that's not actually anything to do with\nthe recent rfishbase commit.  As I mentioned, this version is still in\ndevelopment and that was due to me restarting the web server that provides\nthe fishbase API (hence \"connection refused\" error -- I know it's pretty\nopaque, automated errors always are).  You can use the functions\nheartbeat() or ping() to see if the server is alive.  The server will be\nmore stable once we have a stable release for CRAN, but for now we're still\nfiddling with it to add more features and endpoints, etc.\n\n\n\n\nOn Wed, Apr 1, 2015 at 1:06 PM sartonic <notifications@github.com> wrote:\n\n> Yes, I think it is good to clarify whenever the output m is less than the\n> input n. I actually have a tiny follow-up question based on that same\n> question.\n>\n> Let's say I run validate_names on a list of 864 scientific names and the\n> output of validate_names is 667. Running the validated names through\n> species_info() returns 667 entries, but running the validated names through\n> ecology() for fields=c(\"SpecCode\", \"FoodTroph\", \"FoodSeTroph\",\n> \"DietTroph\", \"DietSeTroph\") returns only 628 entries. What accounts for\n> that difference? I would have thought perhaps ecology() was excluding\n> species for which all of the fields (except SpecCode) were NA, but there\n> are a few examples in the output where there are NAs for each field.\n>\n> Also I just downloaded and reinstalled rfishbase to get the latest push\n> and now the function seems to be broken:\n>\n> > validatedSpecies = validate_names(mySpecies)\n> Error in function (type, msg, asError = TRUE)  :\n>   Failed connect to fishbase.ropensci.org:80; Connection refused\n> In addition: There were 50 or more warnings (use warnings() to see the first 50)\n>\n> > testValidate = validate_names(\"Ablennes  hians\")\n> Warning messages:\n> 1: In check_and_parse(resp) : server error: (502) Bad Gateway\n> 2: In error_checks(parsed, resp = resp) :\n>   Failed to parse or empty query results for http://fishbase.ropensci.org/synonyms?SynSpecies=%20hians&SynGenus=Ablennes&limit=50&fields=SynGenus%2CSynSpecies%2CValid%2CMisspelling%2CColStatus%2CSynonymy%2CCombination%2CSpecCode%2CSynCode%2CCoL_ID%2CTSN%2CWoRMS_ID\n> 3: No match found for species 'Ablennes  hians'\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/ropensci/rfishbase/issues/38#issuecomment-88616189>.\n>\n"}}