In R, with get() call a function from an unloaded package without using library -


i want call function unloaded package having function name stored in list.

normally use

library(shiny) pagelist <- list("type" = "p") # object function name (will loaded .txt file) get(pagelist$type[1])("display text") 

but since when writing package you're not allowed load library i'd have use like

get(shiny::pagelist$type[1])("display text") 

which doesn't work. there way call function function name stored in list, without having load library? note should possible call many different functions (all same package), using e.g.

if (pagelist$type[1] == "p"){   shiny::p("display text")  } 

would require quite long list of if else statemens.

use getexportedvalue:

getexportedvalue("shiny",pagelist$type[1])("display text") #<p>display text</p> 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -