Description Usage Arguments Details Value Author(s) Examples
Add summary information from one dataframe to the dataframe that has been summarized, given only starting posititions of summarized groups.
E.g. used when one dataframe consists of timestamped samples and another
contains summary information about blocks of time.
Imagine a sampled heart rate with columns 'time' and 'signal'
in one dataframe and information about events that happened in
blocks of the sampling, with start times of the blocks, in the other dataframe.
See Examples
.
1 2 |
to |
Dataframe to transfer information to. |
from |
Dataframe to get information from. |
by |
Names of columns to match starting positions by. Given as vector E.g. |
insert_missing |
If some starting positions are not found
in the |
order_to |
Order the |
order_from |
Order the |
Starting positions are the values in the
by
column of the from
dataframe.
The to
dataframe with the added columns from the from
dataframe.
Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Attach packages
library(transfrr)
library(dplyr)
# Get data (Note: loaded with transfrr)
sunspots <- sunspots_
presidents <- USA.presidents
# Transfer the presidents' information
# to the time of their presidency
transferred <- sunspots %>%
transfer(presidents, by = c("start_date", "took_office"))
# Note that the first rows will contain NAs, as they lie
# before the first US president. Check the tail for proof
# that it works.
tail(transferred)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.