
Last chance! 50% off unlimited learning
Sale ends in
Selects a set of columns with names or Column expressions.
select(x, col, ...)# S4 method for SparkDataFrame
$(x, name)
# S4 method for SparkDataFrame
$(x, name) <- value
# S4 method for SparkDataFrame,character
select(x, col, ...)
# S4 method for SparkDataFrame,Column
select(x, col, ...)
# S4 method for SparkDataFrame,list
select(x, col)
a SparkDataFrame.
a list of columns or single Column or name.
additional column(s) if only one column is specified in col
.
If more than one column is assigned in col
, ...
should be left empty.
name of a Column (without being wrapped by ""
).
a Column or an atomic vector in the length of 1 as literal value, or NULL
.
If NULL
, the specified Column is dropped.
A new SparkDataFrame with selected columns.
Other SparkDataFrame functions:
SparkDataFrame-class
,
agg()
,
alias()
,
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()
,
exceptAll()
,
except()
,
explain()
,
filter()
,
first()
,
gapplyCollect()
,
gapply()
,
getNumPartitions()
,
group_by()
,
head()
,
hint()
,
histogram()
,
insertInto()
,
intersectAll()
,
intersect()
,
isLocal()
,
isStreaming()
,
join()
,
limit()
,
localCheckpoint()
,
merge()
,
mutate()
,
ncol()
,
nrow()
,
persist()
,
printSchema()
,
randomSplit()
,
rbind()
,
rename()
,
repartitionByRange()
,
repartition()
,
rollup()
,
sample()
,
saveAsTable()
,
schema()
,
selectExpr()
,
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()
# NOT RUN {
select(df, "*")
select(df, "col1", "col2")
select(df, df$name, df$age + 1)
select(df, c("col1", "col2"))
select(df, list(df$name, df$age + 1))
# Similar to R data frames columns can also be selected using $
df[,df$age]
# }
Run the code above in your browser using DataLab