add_rows: Add rows to data.frame/matrix/table

Description Usage Arguments Value Examples

Description

add_rows is similar to rbind but it handles non-matching column names. %add_rows% is an infix version of add_rows. There is also special method for the results of cro/cro_fun/tables/fre. .add_rows is version for adding rows to default dataset. See default_dataset.

Usage

1
2
3
4
5
6
7
8
9
add_rows(..., nomatch_columns = c("add", "drop", "stop"))

## S3 method for class 'data.frame'
add_rows(..., nomatch_columns = c("add", "drop",
  "stop"))

x %add_rows% y

.add_rows(..., nomatch_columns = c("add", "drop", "stop"))

Arguments

...

data.frame/matrix/table for binding

nomatch_columns

action if there are non-matching columns between data.frames. Possible values are "add", "drop", "stop". "add" will combine all columns, "drop" will leave only common columns, "stop" will raise an error.

x

data.frame/matrix/table for binding

y

data.frame/matrix/table for binding

Value

See rbind, cro, cro_fun, fre, tables

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
a = data.frame(x = 1:5, y = 6:10)
b = data.frame(y = 6:10, z = 11:15)

add_rows(a, b) # x, y, z
a %add_rows% b # the same result

add_rows(a, b, nomatch_columns = "drop")  # y

# simple tables
data(mtcars)
# apply labels
mtcars = apply_labels(mtcars,
                mpg = "Miles/(US) gallon",
                cyl = "Number of cylinders",
                disp = "Displacement (cu.in.)",
                hp = "Gross horsepower",
                drat = "Rear axle ratio",
                wt = "Weight (lb/1000)",
                qsec = "1/4 mile time",
                vs = "V/S",
                vs = c("V-engine" = 0, "Straight engine" = 1),
                am = "Transmission (0 = automatic, 1 = manual)",
                am = c(automatic = 0, manual = 1),
                gear = "Number of forward gears",
                carb = "Number of carburetors"
)

tbl_mean = calculate(mtcars, cro_mean(cyl, am))
tbl_percent = calculate(mtcars, cro_cpct(cyl, am))

tbl_mean %add_rows% tbl_percent

gdemin/expss documentation built on May 16, 2019, 11:14 p.m.