Skip to contents

Get Column Names from a Time Series Lists

Usage

tsl_colnames_get(tsl = NULL, names = c("all", "shared", "exclusive"))

Arguments

tsl

(required, list) Time series list. Default: NULL

names

(optional, character string) Three different sets of column names can be requested:

  • "all" (default): list with the column names in each zoo object in tsl. Unnamed columns are tagged with the string "unnamed".

  • "shared": character vector with the shared column names in at least two zoo objects in tsl.

  • "exclusive": list with names of exclusive columns (if any) in each zoo object in tsl.

Value

list

Examples

#generate example data
tsl <- tsl_simulate()

#list all column names
tsl_colnames_get(
  tsl = tsl,
  names = "all"
)
#> $A
#> [1] "a" "b" "c" "d" "e"
#> 
#> $B
#> [1] "a" "b" "c" "d" "e"
#> 

#change one column name
names(tsl[[1]])[1] <- "new_column"

#all names again
tsl_colnames_get(
  tsl = tsl,
  names = "all"
)
#> $A
#> [1] "new_column" "b"          "c"          "d"          "e"         
#> 
#> $B
#> [1] "a" "b" "c" "d" "e"
#> 

#shared column names
tsl_colnames_get(
  tsl = tsl,
  names = "shared"
)
#> $A
#> [1] "b" "c" "d" "e"
#> 
#> $B
#> [1] "b" "c" "d" "e"
#> 

#exclusive column names
tsl_colnames_get(
  tsl = tsl,
  names = "exclusive"
)
#> $A
#> [1] "new_column"
#> 
#> $B
#> [1] "a"
#>