extract: EdR Extraction Function

Description Usage Arguments Details Value Examples

Description

EdR.extract() extracts entries from multiple columns of a dataframe, storing each in a new dataframe as a (value, value_type) pair, where value_type is the original column name for that entry.

Usage

1
	EdR.extract(dataf, timecols, valcols)

Arguments

dataf

A dataframe

timecols

A vector of strings specifying time columns (i.e., independent variables) to extract from the dataframe

valcols

A vector of strings specifying data columns to extract from the dataframe

Details

Suppose you have a dataframe df with columns time_variable, data_variable_a, data_variable_b, i.e., a dataframe storing a timeseries of data_variable_a and data_variable_b as a function of time_variable. It is possible to plot this information using xyplot(data_variable_a + data_variable_b ~ time_variable, data=df. In this case, data_variable_a and data_variable_b will show up as separate traces on the same graph.

Calling df_2 <- EdR.extract(df, c("time_variable"), c("data_variable_a", "data_variable_b")) will produce a dataframe with columns time_variable, value, and value_type. It is now possible to plot data_variable_a and data_variable_b as separate panels using xyplot(value ~ time_variable | factor(value_type), data=df_2).

This functionality is often used in conjunction with EdR.merge. Typically EdR.extract is used to extract important variables from a BioCro simulation result, and then EdR.merge is used to combine the results of several simulations with different parameters. Then a plot can easily be generated showing each variable in a separate panel with separate traces for each simulation.

Value

A dataframe with a value column, a value_type column, and other columns for the elements of timecols

Examples

1
	#datanew <- EdR.extract(data1, c("doy_dbl", "TTc"), c("Leaf", "Stem", "Root", "Grain"))

eloch216/EdR documentation built on Jan. 5, 2020, 7:26 p.m.