pasteByRowOrdered | R Documentation |
Paste data.frame rows into an ordered factor
pasteByRowOrdered(
x,
sep = "_",
na.rm = TRUE,
condenseBlanks = TRUE,
includeNames = FALSE,
keepOrder = FALSE,
byCols = seq_len(ncol(x)),
na.last = TRUE,
...
)
x |
|
sep |
|
na.rm |
|
condenseBlanks |
|
includeNames |
|
keepOrder |
|
byCols |
|
na.last |
|
... |
additional arguments are passed to |
This function is an extension to jamba::pasteByRow()
which
pastes rows from a data.frame
into a character vector. This
function defines factor levels by running jamba::mixedSortDF(unique(x))
and calling jamba::pasteByRow()
on the result. Therefore the
original order of the input x
is maintained while the factor
levels are based upon the appropriate column-based sort.
Note that the ...
additional arguments are
passed to jamba::mixedSortDF()
to customize the column-based
sort order, used to define factor levels. A good way to test the
order of factors is to run jamba::mixedSortDF(unique(x))
with
appropriate arguments, and confirm the rows are ordered as expected.
Note also that jamba::mixedSortDF()
uses jamba::mixedSort()
which itself performs alphanumeric sort in order to keep
values in proper numeric order where possible.
Other jam string functions:
asSize()
,
breaksByVector()
,
cPasteSU()
,
cPasteS()
,
cPasteUnique()
,
cPasteU()
,
cPaste()
,
fillBlanks()
,
formatInt()
,
gsubOrdered()
,
gsubs()
,
makeNames()
,
mixedOrder()
,
mixedSortDF()
,
mixedSorts()
,
mixedSort()
,
mmixedOrder()
,
nameVectorN()
,
nameVector()
,
padInteger()
,
padString()
,
pasteByRow()
,
sizeAsNum()
,
tcount()
,
ucfirst()
,
uniques()
f <- LETTERS;
df <- data.frame(A=f[rep(1:3, each=2)],
B=c(NA, f[3]),
C=c(NA, NA, f[2]))
df
# note that output is consistent with mixedSortDF()
jamba::mixedSortDF(df)
jamba::pasteByRowOrdered(df)
jamba::mixedSortDF(df, na.last=FALSE)
jamba::pasteByRowOrdered(df, na.last=FALSE)
jamba::mixedSortDF(df, byCols=c(3, 2, 1))
jamba::pasteByRowOrdered(df, byCols=c(3, 2, 1))
df1 <- data.frame(group=rep(c("Control", "ABC1"), each=6),
time=rep(c("Hour2", "Hour10"), each=3),
rep=paste0("Rep", 1:3))
# default will sort each column alphanumerically
pasteByRowOrdered(df1)
# keepOrder=TRUE will honor existing order of character columns
pasteByRowOrdered(df1, keepOrder=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.