fixnames: Change names to be the same for each taxon.

Description Usage Arguments Value Examples

View source: R/fixnames.r

Description

That is, this function attempts to take all the names that are synonyms, for whatever reason (e.g., some names have authorities on them), and collapses them to the same string - making data easier to deal with for making maps, etc.

Usage

1
fixnames(obj, how = "shortest", namevec = NULL)

Arguments

obj

An object of class occdat

how

One of a few different methods:

  • shortest Takes the shortest name string that is likely to be the prettiest to display name, and replaces alll names with that one, better for maps, etc.

  • query This method takes the names you orginally queried on (in the occdat object), and replaces names in the occurrence data with them.

  • supplied If this method, supply a vector of names to replace the names with

namevec

A vector of names to replace names in the occurrence data.frames with. Only used if how="supplied"

Value

An object of class occdat.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
spp <- c('Danaus plexippus','Accipiter striatus','Pinus contorta')
dat <- occ(spp, from='gbif', gbifopts=list(hasCoordinate=TRUE), limit=50)
fixnames(dat, how="shortest")$gbif
fixnames(dat, how="query")$gbif
fixnames(dat, how="supplied", namevec = c('abc', 'def', 'ghi'))$gbif

dat <- occ(spp, from='ecoengine', limit=50)
## doesn't changes things
fixnames(dat, how="shortest")$ecoengine$data$Danaus_plexippus
## this is better
fixnames(dat, how="query")$ecoengine$data$Danaus_plexippus
## or this
fixnames(dat, how="supplied", 
 namevec = c("Danaus","Accipiter","Pinus"))$ecoengine$data$Danaus_plexippus

## End(Not run)

Example output

Warning messages:
1: No records found in GBIF for Danaus plexippus 
2: No records found in GBIF for Accipiter striatus 
3: No records found in GBIF for Pinus contorta 
Species [Danaus plexippus (0), Accipiter striatus (0), Pinus contorta (0)] 
First 10 rows of [Danaus_plexippus]

# A tibble: 0 x 0
There were 50 or more warnings (use warnings() to see the first 50)
Species [Danaus plexippus (0), Accipiter striatus (0), Pinus contorta (0)] 
First 10 rows of [Danaus_plexippus]

# A tibble: 0 x 1
# ... with 1 variables: name <chr>
Warning messages:
1: Unknown or uninitialised column: 'longitude'. 
2: Unknown or uninitialised column: 'latitude'. 
3: Unknown or uninitialised column: 'prov'. 
Species [Danaus plexippus (0), Accipiter striatus (0), Pinus contorta (0)] 
First 10 rows of [Danaus_plexippus]

# A tibble: 0 x 1
# ... with 1 variables: name <chr>
Warning messages:
1: Unknown or uninitialised column: 'longitude'. 
2: Unknown or uninitialised column: 'latitude'. 
3: Unknown or uninitialised column: 'prov'. 
Warning messages:
1: No records found in Ecoengine for Danaus plexippus 
2: No records found in Ecoengine for Accipiter striatus 
3: No records found in Ecoengine for Pinus contorta 
# A tibble: 0 x 0
There were 50 or more warnings (use warnings() to see the first 50)
# A tibble: 0 x 1
# ... with 1 variables: name <chr>
# A tibble: 0 x 1
# ... with 1 variables: name <chr>

spocc documentation built on May 30, 2017, 1:06 a.m.