Description Usage Arguments Details Examples
An "rbind
for data.frames", sort of.
1 |
dtf |
data.frame; original data.frame |
nrw |
data.frame; the new row(s) to be added |
top |
logical; should the new rows be added to the top or the bottom (default)? |
Can only bind two objects at a time, but will bind data.frames with non-matching column names and -classes. In such cases the original data.frame will serve as template.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | dtf <- data.frame(A=letters[1:5],
B=1:5,
C=as.factor(5:1),
D=as.Date(0:4, origin="2000-01-01"),
stringsAsFactors=FALSE)
nrw <- data.frame(A=letters[1:5],
B=4:8,
C=5:1,
D=as.Date(5:1, origin="1990-01-01"),
stringsAsFactors=FALSE)
str(dtf)
dtf.a <- addrows(dtf, nrw, top=FALSE)
str(dtf.a)
# adding a single row with little concern for data types and column names
b <- type.convert(beaver1[80:90,])
b$activ <- as.logical(b$activ)
addrows(b, data.frame(350, 1200, 37.02, 1))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.