export.snowprofileCsv: Export or write a snowprofile object to a CSV table

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/export.snowprofileCsv.R

Description

Export or write a snowprofile object to a CSV table

Usage

1
2
3
4
5
6
7
export.snowprofileCsv(
  profile,
  filename = stop("filename must be provided"),
  sep = ",",
  export.all = "Layers",
  variables = NA
)

Arguments

profile

snowprofile object

filename

character string, e.g. 'path/to/file.csv'

sep

csv column separator as character string

export.all

one of TRUE, FALSE, 'Layers': export all variables of the snowprofile object to the csv table?

If 'Layers', then all layer variables of the snowprofile will be exported.

variables

A tag-value list of the format, e.g. height = 'height_top', to specify column names of specific variables, to customize column order, and/or to include specific profile meta data if export.all == 'Layers' (e.g. easily include the meta data station_id). Note that the tags of the tag-value list need to correspond to elements of the snowprofile object.

Details

Note that existing files with the specified filename will be overwritten without warning!

Value

Writes csv file to disk, no return value in R

Author(s)

fherla

See Also

snowprofileCsv

Examples

 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
## export an entire snowprofile object:

export.snowprofileCsv(SPpairs$A_manual, filename = file.path(tempdir(), 'file.csv'),
                      export.all = TRUE)


## export only the layer properties of a snowprofile object,
#  and change the column order with few column names:
#  All layer variables will be exported, but the three ones provided in 'variables'
#  will be the first three columns of the csv table, and their column names will be changed
#  accordingly.

export.snowprofileCsv(SPpairs$A_manual, filename = file.path(tempdir(), 'file.csv'),
                      export.all = 'Layers',
                      variables = list(height = 'height_top', hardness = 'hardness',
                                       gtype = 'gt1'))


## export all layer properties of a snowprofile object plus the station ID:

export.snowprofileCsv(SPpairs$A_manual, filename = file.path(tempdir(), 'file.csv'),
                      export.all = 'Layers', variables = list(station_id = 'station_id'))

## check the content of the exported csv file:
csv_content <- read.csv(file.path(tempdir(), 'file.csv'))
head(csv_content)

## or re-import the csv file as snowprofile object:
csv_snowprofile <- snowprofileCsv(file.path(tempdir(), 'file.csv'))
print(csv_snowprofile)

sarp.snowprofile documentation built on July 25, 2020, 5:06 p.m.