Movatterモバイル変換


[0]ホーム

URL:


Counters

whereami stores in counters when awhereamicall was invoked in a script during a session. This information can beused in control reactivity in shiny app development and testing.

Below shows the basics of accessing and controlling counters.

library(whereami)
txt_1<-"whereami::cat_where(whereami::whereami(tag = 'tag1'))"txt_2<-"whereami::cat_where(whereami::whereami(tag = 'tag2'))"tf_1<-tempfile(fileext ='.R')tf_2<-tempfile(fileext ='.R')cat(txt_1,file = tf_1)cat(txt_2,file = tf_2)
source(tf_1)source(tf_2)

Query Counter State

# All counterscounter_state()# A single countercounter_state(tag ='tag1')

Accessing Counters

# Counter namescounter_names()# Counter tagscounter_tags()

Retrieve Counters

counters<-counter_get()counters

Manipulating Counters

Usingcounter_reset andcounter_state in aloop

for( iin1:10 ){source(tf_1)source(tf_2)if(counter_state(tag ='tag1')>5 )counter_reset(tag ='tag2')}

Plot Method

plot(counter_get())

json logs

A json log of the counter is written tofile.path(tempdir(),'whereami.json') by default. The pathcan be set usingset_whereami_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()

[8]ページ先頭

©2009-2025 Movatter.jp