add_attr2tb: Copy attributes from members of a generic_mspct

Description Usage Arguments Details Value Note See Also Examples

View source: R/spct.metadata.r

Description

Copy metadata attributes from members of a generic_mspct object into a tibble or data.frame.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
add_attr2tb(
  tb = NULL,
  mspct,
  col.names = NULL,
  idx = "spct.idx",
  unnest = FALSE
)

when_measured2tb(
  mspct,
  tb = NULL,
  col.names = "when.measured",
  idx = "spct.idx"
)

geocode2tb(mspct, tb = NULL, col.names = "geocode", idx = "spct.idx")

lonlat2tb(mspct, tb = NULL, col.names = c("lon", "lat"), idx = "spct.idx")

lon2tb(mspct, tb = NULL, col.names = "lon", idx = "spct.idx")

lat2tb(mspct, tb = NULL, col.names = "lat", idx = "spct.idx")

address2tb(mspct, tb = NULL, col.names = "address", idx = "spct.idx")

what_measured2tb(
  mspct,
  tb = NULL,
  col.names = "what.measured",
  idx = "spct.idx"
)

how_measured2tb(mspct, tb = NULL, col.names = "how.measured", idx = "spct.idx")

normalized2tb(mspct, tb = NULL, col.names = "normalized", idx = "spct.idx")

scaled2tb(mspct, tb = NULL, col.names = "scaled", idx = "spct.idx")

instr_desc2tb(mspct, tb = NULL, col.names = "instr.desc", idx = "spct.idx")

instr_settings2tb(
  mspct,
  tb = NULL,
  col.names = "instr.settings",
  idx = "spct.idx"
)

BSWF_used2tb(mspct, tb = NULL, col.names = "BSWF.used", idx = "spct.idx")

filter_properties2tb(
  mspct,
  tb = NULL,
  col.names = "filter.properties",
  idx = "spct.idx"
)

Tfr_type2tb(mspct, tb = NULL, col.names = "Tfr.type", idx = "spct.idx")

Rfr_type2tb(mspct, tb = NULL, col.names = "Rfr.type", idx = "spct.idx")

time_unit2tb(mspct, tb = NULL, col.names = "time.unit", idx = "spct.idx")

comment2tb(mspct, tb = NULL, col.names = "comment", idx = "spct.idx")

Arguments

tb

tibble or data.frame to which to add the data (optional).

mspct

generic_mspct Any collection of spectra.

col.names

named character vector Name(s) of metadata attributes to copy, while if named, the names provide the name for the column.

idx

character Name of the column with the names of the members of the collection of spectra.

unnest

logical Flag controlling if metadata attributes that are lists of values should be returned in a list column or in separate columns.

Details

The attributes are copied to a column in a tibble or data frame. If the tb formal parameter receives NULL as argument, a new tibble will be created. If an existing data.frame or tibble is passed as argument, new columns are added to it. However, the number of rows in the argument passed to tb must match the number of spectra in the argument passed to mspct. Only in the case of method add_attr2tb() if the argument to col.names is a named vector, the names of members are used as names for the columns created. This permits setting any valid name for the new columns. If the vector passed to col.names has no names the names of the attributes are used for the new columns. If the fields of the attributes are unnested their names are used as names for the columns.

Valid accepted as argument to col.names are NULL, "lon", "lat", "address", "geocode", "where.measured", "when.measured", "what.measured", "how.measured", "comment", "normalised", "normalized", "scaled", "bswf.used", "instr.desc", "instr.settings", "filter.properties", "Tfr.type", "Rfr.type", "time.unit".

Value

A tibble With the metadata attributes in separate new variables.

Note

The order of the first two arguments is reversed in add_attr2tb() compared to the other functions. This is to allow its use in 'pipes', while the functions for single attributes are expected to be used mostly to create new tibbles.

See Also

Other measurement metadata functions: getFilterProperties(), getHowMeasured(), getInstrDesc(), getInstrSettings(), getWhatMeasured(), getWhenMeasured(), getWhereMeasured(), get_attributes(), isValidInstrDesc(), isValidInstrSettings(), select_spct_attributes(), setFilterProperties(), setHowMeasured(), setInstrDesc(), setInstrSettings(), setWhatMeasured(), setWhenMeasured(), setWhereMeasured(), spct_attr2tb(), spct_metadata(), trimInstrDesc(), trimInstrSettings()

Examples

1
2
3
4
5
6
7
8
9
library(dplyr)

my.mspct <- source_mspct(list(sun1 = sun.spct, sun2 = sun.spct * 2))
q_irrad(my.mspct) %>%
  add_attr2tb(my.mspct, c(lat = "latitude",
                          lon = "longitude",
                          when.measured = "time"))

when_measured2tb(my.mspct)

photobiology documentation built on April 4, 2021, 5:05 p.m.