Learn R Programming

mvbutils (version 2.5.101)

mvbutils.utils: Miscellaneous utilities

Description

Miscellaneous utilities.

Usage

as.cat( x)
## S3 method for class 'POSIXct':
cbind( ...)  # cbind.POSIXct
clip( x, n=1)
cq( ...)
deparse.names.parsably( x)
empty.data.frame( ...)
env.name.string( env)
exists.mvb( x, pos = -1, envir = pos.to.env(pos), frame, mode = "any", inherits = FALSE)
expanded.call( nlocal=sys.parent())
everyth( x, by=1, from=1)
find.funs(pos=1, ..., exclude.mcache = TRUE, mode="function")
find.lurking.envs(obj, delve=FALSE, trace=FALSE)
generic.dll.loader( libname, pkgname)
index( lvector)
is.dir( dir)
legal.filename( name)
## S3 method for class 'POSIXct':
length(x) <- value # length<-.POSIXct
lsall( ...)
lib.pos() # used only to hack 'library'
masked( pos)
masking( pos=1)
mkdir( dirlist)
most.recent( lvec)
my.all.equal( x, y)
named( x)
nscat( fmt, ..., sep='\n', file='')
option.or.default( opt.name, default=NULL)
pos( substrs, mainstrs, any.case = FALSE, names.for.output)
## S3 method for class 'cat':
print( x, ...) # print.cat
## S3 method for class 'nullprint':
print( x, ...) # print.nullprint
put.in.session( ...)
## S3 method for class 'POSIXct':
rbind( ...) # rbind.POSIXct
returnList( ...)
safe.rbind( df1, df2)
scatn( fmt, ..., sep='\n', file='')
to.regexpr( x)
yes.no( prompt, default)

Arguments

x, y, n, ..., value, by, env, from, exclude.mcache, nlocal, lvector, dir, name, pos, envir, frame, mode, inherits, dirlist, lvec, opt.name, default, substrs, mainstrs, any.case, names.for.output, df1, df2, prompt, obj, delve, trace, fmt, sep, file, libna
see "Arguments by function"

Value

  • as.catcharacter vector of class cat
  • cbind.POSIXctmatrix of class POSIXct, with same tzone as first element of ...
  • clipvector of the same mode as x
  • cqcharacter vector
  • empty.data.framedata.frame
  • env.name.stringa string
  • expanded.calla call object
  • everythsame type as x
  • find.funsa character vector of function names
  • find.lurking.envsa data.frame with columns "what" and "size"
  • generic.dll.loadera useless list
  • is.dirlogical vector
  • is.nonzeroTRUE or FALSE
  • legal.filenamecharacter( 1)
  • length<-.POSIXctvector of class POSIXct
  • maskedcharacter vector
  • maskingcharacter vector
  • mkdirlogical vector of success/failure
  • nscatNULL
  • most.recentinteger vector the same length as lvec, with values in the range (0,length(lvec)).
  • namedvector of the same mode as x
  • option.or.defaultoption's value
  • posnumeric matrix, one column per match found plus one; at least one column guaranteed
  • rbind.POSIXctmatrix of class POSIXct, with same tzone as first element of ...
  • returnListlist or single object
  • safe.rbinddata.frame
  • scatnNULL
  • to.regexprcharacter
  • yes.noTRUE or FALSE

code

cat

bold

below

item

  • deparse.names.parsably
  • empty.data.frame
  • env.name.string
  • exists.mvb
  • expanded.call
  • everyth
  • find.funs
  • find.funs
  • find.funs
  • find.lurking.envs
  • find.lurking.envs
  • generic.dll.loader
  • index
  • is.dir
  • legal.filename
  • find.funs
  • length<-.POSIXct
  • length<-.POSIXct
  • lsall
  • masking, masked
  • mkdir
  • most.recent
  • my.all.equal
  • named
  • nscat
  • option.or.default
  • option.or.default
  • pos
  • pos
  • pos
  • pos
  • print.cat, print.nullprint x
  • print.cat, print.nullprint ...
  • put.in.session
  • rbind.POSIXct
  • returnList
  • safe.rbind
  • scatn, nscat
  • to.regexpr
  • yes.no
  • yes.no

Details

as.cat makes a character vector print as if it was catted rather than printed. cbind.POSIXct and rbind.POSIXct cope nicely with POSIXct matrices and arrays; default R{} behaviour is to strip the attributes and turn everything back into raw seconds...

Examples

Run this code
x <- matrix( Sys.time()+Seconds( 1:6), 2, 3)
rbind( x, x)
cbind( x, x)
length( x) <- 5
clip( 1:5, 2) # 1:3
cq( alpha, beta) # c( "alpha", "beta")
empty.data.frame( a=1, b="yes")
# data.frame with 0 rows of columns "a" (numeric) and "b" (character)
empty.data.frame( a=1, b=factor( c( "yes", "no")))$b
# factor with levels c( "no", "yes")
everyth( 1:10, 3, 5) # c( 5, 8)
f <- function( a=9, b) expanded.call(); f( 3, 4) # list( a=3, b=4)
find.funs( "package:base", patt="an") # "transform" etc.
find.lurking.envs( cd)
#                                     what  size
#1                     attr(obj, "source")  5368
#2                                     obj 49556
#3 environment(obj) <: namespace:mvbutils>   Inf
eapply( .GlobalEnv, find.lurking.envs)
mypack:::.onLoad <- function( libname, pkgname) generic.dll.loader( libname, pkgname)
#... or just copy the code into your .onLoad
is.dir( getwd()) # TRUE
legal.filename( "a:b\\c/d&f") # "a.b.c.d&f"
most.recent( c( FALSE,TRUE,FALSE,TRUE)) # c( 0, 2, 2, 4)
sapply( named( cq( alpha, beta)), nchar)  # c( alpha=5, beta=4)
option.or.default( "my.option", 5) # probably 5
pos( cq( quick, lazy), "the quick brown fox jumped over the lazy dog")
# matrix( c( 5, 37), nrow=2)
pos( "quick", c( "first quick", "second quick quick", "third"))
# matrix( c( 7,8,0, 0,14,0), nrow=3)
pos( "quick", "slow") # matrix( 0)
f <- function() { a <- 9; return( returnList( a, a*a, a2=a+a)) }
f() # list( a=9, 81, a2=18)
levels( rbind( data.frame( x=1), data.frame( x="cat"))$x)
# NULL, because "x" acquires mode "character"; a bug, I think
levels( safe.rbind( data.frame( x=1), data.frame( x="cat"))$x)
# c( "1", "cat")
scatn( 'Things %i', 1:3)
to.regexpr( "a{{") # "a\\\\\{\\\\\{"
mkdir( "subdirectory.of.getwd")
yes.no( "OK (Y/N)? ")
masking( 1)
masked( 5)

Run the code above in your browser using DataLab