plotting_restructure: plotting_restructure

Description Usage Arguments Value Examples

Description

Helper function to add graphing / plotting variables to the recounted data frame

Usage

1

Arguments

A recounted data frame

Value

Returns a data frame with 4 variables:

sub_series_sum

The cumulative sum of the target variable across the behavior stream

sub_series_total

The total number of events in the behavior stream

sub_series_cum_run_prob

Running probability using total events in denominator

sub_series_run_prob

Running probability divided by the number of events to a point in the series

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
test_df_rc <- recounter(two_person_picture,BEH,"o","A")$recounted_data_frame

# To plot the running probability for each sub-series.
# This shows the shift in the distribution across the sequence.

#ggplot2::ggplot(test_df_rc,ggplot2::aes(x = recount_stream_index, y = sub_series_run_prob, color = #
#(recount_sequence), group = sub_series)) + ggplot2::geom_point() +
#ggplot2::facet_grid(~sub_series) +
#  ggplot2::ggtitle("Running Sequence Probabilities By Sub-Series")+
#  ggplot2::xlab("Observation Sequence") +
#  ggplot2::ylab("Running Probability")


# To show the average sequence probabilities for each sub-series

## Summarize the means per sub-series

#sum_one<- test_df_rc %>% group_by(sub_series, recount_sequence) %>%
#  summarize(sub_series_mean = mean(sub_series_run_prob)) %>% ungroup()

#ggplot(filter(sum_one, recount_sequence != "R"),aes(x = sub_series, y = #sub_series_mean, color = (recount_sequence))) + geom_point() + geom_line() +
#  ggtitle("Average Sub-Series Probabilities By Sequence") +
#  xlab("Sub-Series") +
#  ylab("Average Sequence Probabilities")


## To plot the overall series with the overall Sequence Probabilities
#juxtaposed on the series

# Find the overall average by sequence
#overall_average <- sum_one %>% group_by(recount_sequence) %>% summarize
#(mean_sub_mean = mean(sub_series_mean)) %>% ungroup() %>% filter
#(recount_sequence != "R")

# Merge summary with the original dataset so we can add the means to the plot

#average_df<-left_join(test_df_rc, overall_average, by = "recount_sequence")


#ggplot(average_df,aes(x = recount_stream_index, y = sub_series_run_prob, #color = (recount_sequence))) + geom_point() + geom_line(aes(y = #mean_sub_mean)) +
#  ggtitle("Overall Sequence Average") +
#  xlab("Observation Sequence") +
#  ylab("Running Probabilities of Target")

delaneyj1786/REINFORCINATOR documentation built on Jan. 14, 2022, 3:47 a.m.