The goal of trailcountR is to make it easier to process visitor count data collected in the field. Land managers use a variety of methods to gather visitor traffic counts at the trail or forest level. These methods may include deploying infrared counters at trail heads (TRAFx), magnetic vehicle counters, in-person parking lot counts, cameras and others. These raw formats with instantaneous or hourly counts must be transformed into daily counts and combined to be used in downstream analyses.
You can install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("OutdoorRD/trailcountR")
Once you have parsed IR data for a specific device, the days included
will only be dates that the device logged a count. If the site had no
visitors for a day or the device was broken, then no counts are logged
for that day and thus that date will not be included in the data. To
create a complete timeseries for IR data, use the
make_complete_timeseries()
function. Any dates where the counter was
not triggered will have an NA count.
library(trailcountR)
library(magrittr)
# create a complete timeseries for IR data
df <- tibble::tibble(
PlacementID = c(102, 102, 102, 102),
date = c("19-06-04", "19-06-07", "19-06-08", "19-06-10"),
time = c("14:00", "14:00", "13:01", "12:02"),
count = c(15, 13, 12, 50))
df %>%
kableExtra::kbl() %>%
kableExtra::kable_material_dark(lightable_options = "striped")
PlacementID
date
time
count
102
19-06-04
14:00
15
102
19-06-07
14:00
13
102
19-06-08
13:01
12
102
19-06-10
12:02
50
# make the complete timeseries
df2 <- make_complete_timeseries(df)
df2 %>%
kableExtra::kbl() %>%
kableExtra::kable_material_dark(lightable_options = "striped")
date
PlacementID
time
count
2019-06-04
102
14:00
15
2019-06-05
102
NA
NA
2019-06-06
102
NA
NA
2019-06-07
102
14:00
13
2019-06-08
102
13:01
12
2019-06-09
102
NA
NA
2019-06-10
102
12:02
50
Once a complete timeseries has been generated for an IR counter, there
might be certain days which have missing counts. This could occur when
no visitors triggered the counter for that day or when the counter has
stopped working. For downstream analyses, these missing counts should be
replaced with a count of zero. The insert_zero_counts()
function makes
this happen.
library(trailcountR)
library(magrittr)
## Make toy IR counter data
df <- tibble::tibble(
PlacementID = c(102, 102, 102, 102),
date = c("19-06-04", "19-06-07", "19-06-08", "19-06-10"),
time = c("14:00", "14:00", "13:01", "12:02"),
count = c(15, 13, 12, 50))
# complete the timeseries
df2 <- make_complete_timeseries(df)
df2 %>%
kableExtra::kbl() %>%
kableExtra::kable_material_dark(lightable_options = "striped")
date
PlacementID
time
count
2019-06-04
102
14:00
15
2019-06-05
102
NA
NA
2019-06-06
102
NA
NA
2019-06-07
102
14:00
13
2019-06-08
102
13:01
12
2019-06-09
102
NA
NA
2019-06-10
102
12:02
50
# replace the missing counts with zeros
df3 <- insert_zero_counts(df2)
df3 %>%
kableExtra::kbl() %>%
kableExtra::kable_material_dark(lightable_options = "striped")
date
PlacementID
time
count
2019-06-04
102
14:00
15
2019-06-05
102
NA
0
2019-06-06
102
NA
0
2019-06-07
102
14:00
13
2019-06-08
102
13:01
12
2019-06-09
102
NA
0
2019-06-10
102
12:02
50
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.