nfd_to_class: Convert 'nfd' objects to other classes

as.data.frame.nfdR Documentation

Convert nfd objects to other classes

Description

as.data.frame converts nfd, crss_nf, and crssi objects to data.frames.

Usage

## S3 method for class 'nfd'
as.data.frame(x, row.names = NULL, optional = FALSE, ..., wide = TRUE)

## S3 method for class 'crssi'
as.data.frame(x, row.names = NULL, optional = FALSE, ..., wide = TRUE)

Arguments

x

Object inheriting from nfd.

row.names

NULL or a character vector giving the row names for the data frame. Missing values are not allowed.

optional

logical. If TRUE, setting row names and converting column names (to syntactic names: see make.names) is optional. Note that all of R's base package as.data.frame() methods use optional only for column names treatment, basically with the meaning of data.frame(*, check.names = !optional). See also the make.names argument of the matrix method.

...

Other parameters passed to base::as.data.frame()

wide

When TRUE, the sites are included as columns. When FALSE the sites are converted to a site column, making the data.frame longer.

Value

data.frame with columns for date, trace, time_step, and flow_type. When wide == TRUE, there is another column for each site. When wide == FALSE, site, and value columns. If x is a crssi object, than the returned data.frame will also include Sacramento Year Type Index data as another column (wide == TRUE) or as another entry into site (wide == FALSE).

Examples

nf <- crss_nf(
  CoRiverNF::monthlyInt["2000/2002"],
  flow_space = "intervening",
  time_step = "monthly"
 )
 
 # keep sites as columns
 as.data.frame(nf)
 
 # moves sites to "site" variable
 as.data.frame(nf, wide = FALSE)

# crssi objects have sacramento year type data in them, which is also 
# included in the data frame

sac <- sac_year_type_get(internal = TRUE)["2000/2002"]
in_data <- crssi(nf, sac, scen_number = 1.20002002)

as.data.frame(in_data)


BoulderCodeHub/CRSSIO documentation built on July 2, 2023, 5:15 p.m.