merge {SparkR}R Documentation

Merges two data frames

Usage

merge(x, y, ...)

## S4 method for signature 'SparkDataFrame,SparkDataFrame'
merge(x, y, by = intersect(names(x),
  names(y)), by.x = by, by.y = by, all = FALSE, all.x = all,
  all.y = all, sort = TRUE, suffixes = c("_x", "_y"), ...)

Arguments

x

the first data frame to be joined

y

the second data frame to be joined

by

a character vector specifying the join columns. If by is not specified, the common column names in x and y will be used.

by.x

a character vector specifying the joining columns for x.

by.y

a character vector specifying the joining columns for y.

all.x

a boolean value indicating whether all the rows in x should be including in the join

all.y

a boolean value indicating whether all the rows in y should be including in the join

sort

a logical argument indicating whether the resulting columns should be sorted

Details

If all.x and all.y are set to FALSE, a natural join will be returned. If all.x is set to TRUE and all.y is set to FALSE, a left outer join will be returned. If all.x is set to FALSE and all.y is set to TRUE, a right outer join will be returned. If all.x and all.y are set to TRUE, a full outer join will be returned.

See Also

join

Other SparkDataFrame functions: SparkDataFrame-class, [[, agg, arrange, as.data.frame, attach, cache, collect, colnames, coltypes, columns, count, dapply, describe, dim, distinct, dropDuplicates, dropna, drop, dtypes, except, explain, filter, first, group_by, head, histogram, insertInto, intersect, isLocal, join, limit, mutate, ncol, persist, printSchema, registerTempTable, rename, repartition, sample, saveAsTable, selectExpr, select, showDF, show, str, take, unionAll, unpersist, withColumn, write.df, write.jdbc, write.json, write.parquet, write.text

Examples

## Not run: 
##D sc <- sparkR.init()
##D sqlContext <- sparkRSQL.init(sc)
##D df1 <- read.json(sqlContext, path)
##D df2 <- read.json(sqlContext, path2)
##D merge(df1, df2) # Performs a Cartesian
##D merge(df1, df2, by = "col1") # Performs an inner join based on expression
##D merge(df1, df2, by.x = "col1", by.y = "col2", all.y = TRUE)
##D merge(df1, df2, by.x = "col1", by.y = "col2", all.x = TRUE)
##D merge(df1, df2, by.x = "col1", by.y = "col2", all.x = TRUE, all.y = TRUE)
##D merge(df1, df2, by.x = "col1", by.y = "col2", all = TRUE, sort = FALSE)
##D merge(df1, df2, by = "col1", all = TRUE, suffixes = c("-X", "-Y"))
## End(Not run)

[Package SparkR version 2.0.0 Index]