Method to set by reference the "where.measured"
attribute of an R
object.
Usage
setWhereMeasured(x, where.measured, lat, lon, address, ...)
where_measured(x) <- value
# Default S3 method
setWhereMeasured(x, where.measured, lat, lon, address, ...)
# S3 method for class 'generic_spct'
setWhereMeasured(
x,
where.measured = NA,
lat = NA,
lon = NA,
address = NA,
idFactor = getIdFactor(x),
simplify = TRUE,
...
)
# S3 method for class 'summary_generic_spct'
setWhereMeasured(
x,
where.measured = NA,
lat = NA,
lon = NA,
address = NA,
idFactor = getIdFactor(x),
simplify = TRUE,
...
)
# S3 method for class 'data.frame'
setWhereMeasured(
x,
where.measured = NA,
lat = NA,
lon = NA,
address = NA,
idFactor = getIdFactor(x),
simplify = TRUE,
...
)
# S3 method for class 'generic_mspct'
setWhereMeasured(x, where.measured = NA, lat = NA, lon = NA, address = NA, ...)
Arguments
- x
an R object
- where.measured, value
A one row
data.frame
with the same format as returned by functiongeocode
from package 'ggmap' for a location search.- lat
numeric Latitude in decimal degrees North.
- lon
numeric Longitude in decimal degrees West.
- address
character Human readable address.
- ...
Allows use of additional arguments in methods for other classes.
- idFactor
character Name of the column with IDs of the spectra stored in long form or ID column name in bound geocodes to use for IDs of collection of spectra members.
- simplify
logical If all members share the same geocode value set as attribute value a one row geocode instead of a named list of data frames.
Details
Code setWhereMeasured()
methods alter x
itself by
reference and in addition return x
invisibly. If x
is not an
object of a supported class, x
is not modified. If the argument to
where.measured
is not a data.frame
or tibble
object or
NULL
an error is triggered as a validation test is applied. A
geocode describes a geographic location based on longitude (lon
) and
latitude (lat
) as numeric
values and can optionally contain
an address (address
) as a single character
string. Passing
NULL
as argument for parameter where.measured
unsets the
attribute. Parameters lon
, lat
and address
provide an
alternative to passing a ready constructed geocode data frame as input.
By default, when setting the geocode attribute for multiple spectra stored in long form, geocodes are stored as named lists of data frames unless they are identical and can be simplified. It is possible to disable simplification and force the use of a named list.
If the argument passed to parameter geocode
is a data frame with one
row per spectrum and the idFactor
name matches, it will be split
into a named list and, if possibly, simplified. It is also possible but
deprecated to set the attribute to an indexed geocode with multiple rows.
Methods (by class)
setWhereMeasured(default)
: defaultsetWhereMeasured(generic_spct)
: generic_spctsetWhereMeasured(summary_generic_spct)
: summary_generic_spctsetWhereMeasured(data.frame)
: data.framesetWhereMeasured(generic_mspct)
: generic_mspct
Note
Method for collections of spectra recycles the location information
only if it is a one row data.frame
.
See also
Other measurement metadata functions:
add_attr2tb()
,
getFilterProperties()
,
getHowMeasured()
,
getInstrDesc()
,
getInstrSettings()
,
getSoluteProperties()
,
getWhatMeasured()
,
getWhenMeasured()
,
getWhereMeasured()
,
get_attributes()
,
isValidInstrDesc()
,
isValidInstrSettings()
,
select_spct_attributes()
,
setFilterProperties()
,
setHowMeasured()
,
setInstrDesc()
,
setInstrSettings()
,
setSoluteProperties()
,
setWhatMeasured()
,
setWhenMeasured()
,
spct_attr2tb()
,
spct_metadata()
,
subset_attributes()
,
trimInstrDesc()
,
trimInstrSettings()
Examples
my.spct <- sun.spct
where_measured(my.spct)
#> # A tibble: 1 × 3
#> lat lon address
#> <dbl> <dbl> <chr>
#> 1 60.2 25.0 Kumpula, Helsinki, FI
where_measured(my.spct) <- data.frame(lon = 0, lat = -60)
where_measured(my.spct)
#> # A tibble: 1 × 3
#> lon lat address
#> <dbl> <dbl> <chr>
#> 1 0 -60 NA
where_measured(my.spct) <- NULL
where_measured(my.spct)
#> # A tibble: 1 × 3
#> lon lat address
#> <dbl> <dbl> <chr>
#> 1 NA NA NA