Merge2: Merge/Combine

Rbind2R Documentation

Merge/Combine

Description

Rbind2: dplyr::bind_rows() mit labels + name der Daten

Combine more then two Data Frames Objects by Columns

Usage

Rbind2(
  ...,
  .id = "which",
  .names = NULL,
  .use.label = TRUE,
  include.rownames = FALSE
)

Merge2(
  ...,
  by = 0,
  by.x = by,
  by.y = by,
  all = FALSE,
  all.x = all,
  all.y = all,
  sort = FALSE,
  suffixes = NULL,
  include.label = TRUE
)

combine_data_frame(..., by = 1, prefix = NULL)

Arguments

...

data.frames

.id

Data frame identifier. dplyr::bind_rows(..., .id = NULL)

.names

alternative zur vergabe der labels in which

.use.label

set_label TRUE/FALSE

include.rownames

logical

by, by.x, by.y

id an merge

all, all.x, all.y

all an merge

sort

logical. Should the result be sorted on the by columns?

suffixes

a character vector of length n

include.label

labels

prefix

names

Value

data.frame(which, ...)

data.frame

Examples



# require(plyr)
# require(stp25tools)

df1 <- data.frame(a=1, b=2)
df2 <- data.frame(a=2, c=3, d=5)



do.call(plyr::rbind.fill, list(df1, df2))
Rbind2(df1, df2)


df1 = data.frame(CustomerId = c(1:6),
Product = c(rep("Oven", 3), rep("Television", 3)))

df2 = data.frame(CustomerId = c(4:7),
Product = c(rep("Television", 2), rep("Air conditioner", 2)))

df3 = data.frame(
  CustomerId = c(4:7),
  Product = c(rep("Television", 2), rep("Air conditioner", 2)),
  State = c(rep("California", 2), rep("New Jersey", 2))
)

Rbind2(df1, df3)

dplyr::bind_rows(df1, df2)


#' set.seed(1)
n <- 10
df1 <- data.frame(
  origin = sample(c("A", "B", "C", "D", "E"), n, replace = TRUE),
  N = sample(seq(9, 27, 0.5), n, replace = TRUE),
  P = sample(seq(0.3, 4, 0.1), n, replace = TRUE),
  C = sample(seq(400, 500, 1), n, replace = TRUE)
)
df2 <-
  data.frame(
    origin = sample(c("A", "B", "C", "D", "E"), n, replace = TRUE),
    foo1 = sample(c(TRUE, FALSE), n, replace = TRUE),
    X = sample(seq(145600, 148300, 100), n, replace = TRUE),
    Y = sample(seq(349800, 398600, 100), n, replace = TRUE)
  )


df3 <-
  data.frame(origin = sample(c("A", "B", "C", "D", "E"), n, replace = TRUE))
df4 <-
  data.frame(origin = sample(c("A", "B", "C", "D", "E"), n, replace = TRUE))

rownames(df1) <- paste("P", sprintf("%02d", c(1:n)), sep = "")
rownames(df2) <- rownames(df1)
rownames(df3) <- rownames(df1)
rownames(df4) <- rownames(df1)

df1$id <- df2$id <- df3$id <- df4$id <-  rownames(df1)
merge(df1,
      df2,
      by = "id",
      all.x = FALSE,
      all.y = FALSE)

Merge2(df1, df2, df3, df4, by = "id")




m <- data.frame(
  Item = 1:3,
  a = (1:3),
  b = (1:3) * 2,
  c = (1:3) * 3
)
sd <- data.frame(
  Item = (1:3),
  a = (1:3) * 4,
  b = (1:3) * 5,
  c = (1:3) * 6
)
combine_data_frame(m, sd)
combine_data_frame(m, sd, by = NULL)


stp4/stp25tools documentation built on Feb. 27, 2025, 11:14 p.m.