/
counter.Rd
93 lines (66 loc) · 1.76 KB
/
counter.Rd
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/counter.R
\name{counter_state}
\alias{counter_state}
\alias{counter_reset}
\alias{counter_names}
\alias{counter_tags}
\alias{counter_get}
\title{whereami counter}
\usage{
counter_state(item = NULL, tag = NULL)
counter_reset(item = NULL, tag = NULL)
counter_names()
counter_tags()
counter_get()
}
\arguments{
\item{item}{character, name of the counter to access, Default: NULL}
\item{tag}{character, tag of the counter to acces, if it was set at initial whereami call.
This can be used instead of the item name, Default: NULL}
}
\description{
Interact with internal whereami counter
}
\details{
\code{counter_names()} returns names of the active stored counters.
\code{counter_state()} returns current hit count for item, if NULL then all counters
are returned.
\code{counter_reset()} will remove counter of item, if item is NULL then all counters
are reset.
\code{counter_get()} returns a table with all the counters. These can then
be plotted with the with the plot method.
A json log of the counter is written to file.path(tempdir(),'whereami.json') by default
The path can be set using \link[whereami:set_whereami_log]{set_whereami_log}
}
\examples{
if(interactive()){
txt <- "
whereami::cat_where(whereami::whereami(tag = 'tag1'))
"
tf <- tempfile(fileext = '.R')
cat(txt,file = tf)
source(tf)
counter_state()
counter_state(tag = 'tag1')
counter_names()
counter_tags()
counters <- counter_get()
counters
plot(counter_get())
# read the json log
jsonlite::read_json(
file.path(tempdir(),'whereami.json'),
simplifyVector = TRUE)
# clear all counters
counter_reset()
#verify that there are no active counters
counter_state()
# cleanup
unlink(tf)
}
}
\author{
Jonathan Sidi
}
\concept{counter}