MergeXobs: Merge two Xobs data frames

View source: R/function_MergeXobs.R

MergeXobsR Documentation

Merge two Xobs data frames

Description

Function to merge two Xobs data frames, with handling of overlapping time periods and time periods gaps as well as merging of common columns.

Usage

MergeXobs(x, y, comment = "")

Arguments

x, y

Data frames of class HypeXobs, including additional attributes comment, variable, subid, and timestep, typically imported using ReadXobs. For details on attribute format, see the class description. Class attribute not formally necessary.

comment

Character string, will be added to the result as attribute comment. If empty, comment attributes from x and y will be merged to new comment string.

Details

MergeXobs handles time steps of different lengths (e.g. daily, hourly), but requires identical time step lengths from both inputs data frames. The functions expects data frames of class HypeXobs or data frames with comparable structure and will throw a warning if the class attribute is missing.

In case of common columns (identical observation variable and SUBID combinations in x and y), values from columns in x will take precedence, and values from y will only be added if x values are missing

Value

MergeXobs returns a data frame with attributes for Xobs data.

Examples

# Import dummy data, add new observations to second Xobs table
te1 <- ReadXobs(filename = system.file("demo_model", "Xobs.txt", package = "HYPEtools"))
te2 <- ReadXobs(filename = system.file("demo_model", "Xobs.txt", package = "HYPEtools"))
te2$WSTR_40541[1:10] <- runif(n = 10, 50, 100)
MergeXobs(x = te1, y = te2)


rcapell/RHYPE documentation built on Feb. 28, 2024, 3:11 p.m.