Title: | Commonly Used Functions for R Shiny Applications |
---|---|
Description: | A set of common functions to be used for displaying messages, checking variables, finding absolute paths, starting applications, etc. More functions will be added later. |
Authors: | Hanming Tu [aut, cre] |
Maintainer: | Hanming Tu <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.6 |
Built: | 2025-03-08 02:45:02 UTC |
Source: | https://github.com/tucai/comfuncs |
Convert class or list to a data frame
cvt_class2df(x, exc = "^__", condition = FALSE)
cvt_class2df(x, exc = "^__", condition = FALSE)
x |
a class or list |
exc |
exclude pattern |
condition |
condition for excluding |
Hanming Tu
r1 <- Sys.getenv() r2 <- cvt_class2df(r1)
r1 <- Sys.getenv() r2 <- cvt_class2df(r1)
This method displays or writes the message based on debug level. The filehandler is provided through environment variable 'log_fn', and the outputs are written to the file. This method will display message or a hash array based on debug level ('d_level'). If 'd_level' is set to '0', no message or array will be displayed. If 'd_level' is set to '2', it will only display the message level (lvl) is less than or equal to '2'. If you call this method without providing a message level, the message level (lvl) is default to '0'. Of course, if no message is provided to the method, it will be quietly returned. If 'd_level' is set to '1', all the messages with default message level, i.e., 0, and '1' will be displayed. The higher level messages will not be displayed.
echo_msg(prg, step, msg, lvl = 0, fn = NULL)
echo_msg(prg, step, msg, lvl = 0, fn = NULL)
prg |
program name calling from |
step |
step in the program |
msg |
the message to be displayed. No newline is needed in the end of the message. It will add the newline code at the end of the message. |
lvl |
the message level is assigned to the message. If it is higher than the debug level, then the message will not be displayed. |
fn |
log file name |
message
Hanming Tu
echo_msg('comFunc', 1, 'This is a test');
echo_msg('comFunc', 1, 'This is a test');
Get absolute directory
get_abs_path(dir, relpath)
get_abs_path(dir, relpath)
dir |
directory |
relpath |
relative path |
Hanming Tu
get_abs_path("/Users/htu/myRepo", "scripts") # get "/Users/htu/myRepo/scripts"
get_abs_path("/Users/htu/myRepo", "scripts") # get "/Users/htu/myRepo/scripts"
check if string or list is empty (na, null or blank spaces).
is_empty(x)
is_empty(x)
x |
a list or string |
true or false
Hanming Tu
is_empty(NULL); is_empty(''); is_empty(NA);
is_empty(NULL); is_empty(''); is_empty(NA);
start R Shiny apps included in this package.
start_app( app_name = "showenv", n = 1, pkg = "comFuncs", pt = NULL, lb = getOption("shiny.launch.browser", interactive()), ht = getOption("shiny.host", "127.0.0.1"), dm = "normal", msg_lvl = NULL, loc = "local" )
start_app( app_name = "showenv", n = 1, pkg = "comFuncs", pt = NULL, lb = getOption("shiny.launch.browser", interactive()), ht = getOption("shiny.host", "127.0.0.1"), dm = "normal", msg_lvl = NULL, loc = "local" )
app_name |
app or script name |
n |
app number |
pkg |
package name |
pt |
Port number |
lb |
define the browser- shiny.launch.browser |
ht |
define the host or ip address |
dm |
display modes are auto, normal or showcase |
msg_lvl |
message level |
loc |
location of the scirpt: local|github; default to 'local' |
Hanming Tu
# this function start an interactive page so we could not add an runnable # example NULL;
# this function start an interactive page so we could not add an runnable # example NULL;