shiny.tag -> character -> shiny.tag

Hi!

I was wondering if it were possible to take an object of class shiny.tag, convert it to a string and then convert it back to a shiny.tag.

In other words if there's some_function that can do the following:

vbox <- flexdashboard::valueBox("100", "Score")
vbox_txt <- as.character(vbox)
vbox_new <- some_function(vbox_txt)
identical(vbox, vbox_new) == T

Thanks!

I expect you will struggle to find an easy solution for that.
Do you have a use case, or issue in your work, that may be solved differently perhaps ? we could discuss it.

The goal is to have various shiny elements sent through an API and then rendered in a Flexdashboard .Rmd.

Any solution would work, but would preferably like for it to be flexible (which sounds like there isn't an easy solution).

Maybe my reaction was too kneejerk.
In general we can take an r_object, and get a string representation, then evaluate it back into an r object with the use of dput() to go to string, and eval/parse to go back. The exceptions would be objects with pointers etc.
consider

vbox <- flexdashboard::valueBox("100", "Score")
vbox_txt <- capture.output(dput(vbox))
vbox_new <- eval(parse(text=vbox_txt))
identical(vbox, vbox_new)

I think this is what I was looking for! Thank you so much.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.