df2tibble: df2tibble

View source: R/df2tibble.R

df2tibbleR Documentation

df2tibble

Description

Transform RANADU data.frame to tibble and v.v.

Usage

df2tibble(.d, reverse = FALSE)

Arguments

.d

A data-frame following RANADU conventions, or alternately a tibble produced by conversion from such a data.frame.

reverse

(default: FALSE) Convert from a tibble to data.frame, following RANADU conventions for size-distribution variables.

Details

Given a RANADU data.frame (e.g., produced by getNetCDF()), construct and return a tibble. The special handling required relates to size-distribution data, stored in a two-dimensional vector as a component of the data.frame. This is not acceptable in a tibble, so this size distribution is converted to a list before producing the tibble. The reverse transformation makes that list back into a RANADU data.frame. In both cases attributes of the size-distribution variables are preserved; this is important because an attribute specifies the sizes corresponding to bins in the size distribution, and this is used in RANADU functions that plot the size distribution. The converted variables include any for which the data.frame column is a two-dimensional vector; this will be the case for variables like CCDP, CUHSAS, etc. The reason for using this function is to enable the many special features applicable to tibbles, for variables other than the size-distribution variables. (At present, RANADU code plotting the size- distribution variables all is based on the data.frame format.)

Value

A tibble corresponding to the input data.frame but in which any two-dimensional size-distribution vectors are converted to lists. The first index in the list corresponds to the Time variable, and the next to the size distribution array. If "reverse" then a tibble so produced is converted back to a RANADU-convention data.frame.

Author(s)

William Cooper

Examples

RAFtibble <- df2tibble(RAFdata)

NCAR/Ranadu documentation built on Jan. 27, 2023, 1:09 a.m.