safeRequire(packageName, mirrorIndex=NULL)
trim(str)
noZero(str)
formatPvalue(values, digits = 3, spaces=TRUE, includeP = TRUE)
formatR(r, digits)
repStr(n = 1, str = " ")
repeatStr(n = 1, str = " ")
ifelseObj(condition, ifTrue, ifFalse)
invertItem(item, range=NULL, ignorePreviousInversion = FALSE)
is.odd(vector)
is.even(vector)
convertToNumeric(vector, byFactorLabel = FALSE)
massConvertToNumeric(dat, byFactorLabel = FALSE, ignoreCharacter = TRUE, stringsAsFactors = FALSE)
vecTxt(vector, delimiter = ", ", useQuote = "", firstDelimiter = NULL, lastDelimiter = " & ", firstElements = 0, lastElements = 1, lastHasPrecedence = TRUE)
vecTxtQ(vector, useQuote = "'", ...)
find %IN% table
cat0(..., sep="")
addToLog(fullLog, ..., showLog = FALSE);
For formatR, the number of digits to use when formatting the Pearson correlation.
firstElements
, and last lastElements
elements.
useQuote="'"
), doublequote all elements
(useQuote='"'
), or anything else (e.g. useQuote='|'
).
The only difference between vecTxt
and vecTxtQ
is
that the latter by default quotes the elements.
TRUE
) or the number of elements to separate with the last
delimiter (FALSE
)?
cat
, of course, "" by default.
cat
the log.
The trim function removes whitespaces from the start and end of a text string.
The noZero function removes the first zero from a string that was originally a number.
The formatPvalue function formats a P value, roughly according to APA style guidelines. This means that the noZero is used to remove the zero preceding the decimal point, and p values that would round to zero given the requested number of digits are shown as e.g. p<.001.< p="">
The formatR function format a Pearson correlation for pretty printing (using noZero).
The repeatStr (or repStr) function repeats a string a given number of times.
The ifelseObj function just evaluates a condition, returning one object if it's true, and another if it's false.
The invertItem function 'unmirrors' an inverted item (i.e. for a 1-3 item, 1 becomes 3, 2 stays 2, and 3 becomes 1).
is.odd and is.even check whether a number is, or numbers in a vector are, odd or even.
The infix function %IN% is a case-insensitive version of %in%
.
The cat0 function is to cat what paste0 is to paste; it simply makes concatenating many strings without a separator easier.
The addToLog function adds a character vector to a log.
### load a package
safeRequire('ggplot2');
### trim a string
trim(' this is a string with whitespace in front and at the end ');
### Returns "this is a string with whitespace in front and at the end"
repeatStr("-", 8);
### Returns "--------" (incredibly useful, no? :-))
tempVector <- c(1,2,3,3,2,4,3,2,1,1,3,4,5,4,3,2,2,1,1,2);
invertedTempVector <- invertItem(tempVector);
### We can also invert it back, but then we have to override the security
### that prevents accidently inverting items back.
invertItem(tempVector, ignorePreviousInversion=TRUE);
Run the code above in your browser using DataLab