alias {SparkR}R Documentation

alias

Description

Returns a new SparkDataFrame or a Column with an alias set. Equivalent to SQL "AS" keyword.

alias

Usage

## S4 method for signature 'Column'
alias(object, data)

## S4 method for signature 'SparkDataFrame'
alias(object, data)

Arguments

object

x a SparkDataFrame or a Column

data

new name to use

Value

a SparkDataFrame or a Column

Note

alias(Column) since 1.4.0

alias(SparkDataFrame) since 2.3.0

See Also

Other colum_func: between, cast, endsWith, otherwise, over, startsWith, substr

Other SparkDataFrame functions: SparkDataFrame-class, agg, arrange, as.data.frame, attach,SparkDataFrame-method, broadcast, cache, checkpoint, coalesce, collect, colnames, coltypes, createOrReplaceTempView, crossJoin, cube, dapplyCollect, dapply, describe, dim, distinct, dropDuplicates, dropna, drop, dtypes, except, explain, filter, first, gapplyCollect, gapply, getNumPartitions, group_by, head, hint, histogram, insertInto, intersect, isLocal, isStreaming, join, limit, localCheckpoint, merge, mutate, ncol, nrow, persist, printSchema, randomSplit, rbind, registerTempTable, rename, repartition, rollup, sample, saveAsTable, schema, selectExpr, select, showDF, show, storageLevel, str, subset, summary, take, toJSON, unionByName, union, unpersist, withColumn, withWatermark, with, write.df, write.jdbc, write.json, write.orc, write.parquet, write.stream, write.text

Examples

## Not run: 
##D df <- createDataFrame(iris)
##D 
##D head(select(
##D   df, alias(df$Sepal_Length, "slength"), alias(df$Petal_Length, "plength")
##D ))
## End(Not run)
## Not run: 
##D df <- alias(createDataFrame(mtcars), "mtcars")
##D avg_mpg <- alias(agg(groupBy(df, df$cyl), avg(df$mpg)), "avg_mpg")
##D 
##D head(select(df, column("mtcars.mpg")))
##D head(join(df, avg_mpg, column("mtcars.cyl") == column("avg_mpg.cyl")))
## End(Not run)

[Package SparkR version 2.3.0 Index]