df_append: Append New Data to Dataframe

View source: R/utils.R

df_appendR Documentation

Append New Data to Dataframe

Description

Update a 'data.frame' object with new data. Can be used to append new updated time series data to an existing dataframe, where each observation is indexed by a unique timestamp/identifier in a key column.

Usage

df_append(old, new, key = "time", keep.attr = "timestamp")

Arguments

old

data.frame object containing existing data.

new

data.frame object containing new data.

key

[default 'time'] column name used as key, provided as a character string.

keep.attr

[default 'timestamp'] name of an attribute in 'new' to retain, if present, provided as a character string.

Details

Can be used to update price dataframes retrieved by oanda. The function is designed to update existing data with new values as they become available. As opposed to df_merge, the data in 'new' will overwrite the data in 'old' rather than create duplicates.

Value

A data.frame of the existing data appended with the new data. If the data in 'new' contains data with the same value for the key column as 'old', the data in 'new' will overwrite the data in 'old'.

If the attribute specified by 'keep.attr' is present in 'new', this is retained. All other non-required attributes are dropped.

Examples

data1 <- sample_ohlc_data[1:8, ]
data1
data2 <- sample_ohlc_data[7:10, ]
data2
df_append(data1, data2)


ichimoku documentation built on Nov. 2, 2023, 5:36 p.m.