cancel
Showing results for 
Search instead for 
Did you mean: 
suxinji
Employee Alumni
Employee Alumni
 

Overview

In this recipe, you'll learn how to convert R DataFrame into Spark DataFrame. You can use as.DataFrame() or createDataFrame()to convert R data frame into Spark DataFrame

Solution

We assume that you would like to use R to transform the data and the R DataFrame df_r_select was already created:

The df_spark is now a Spark DataFrame that can be saved as a MV.

# convert R data frame into a Spark data frame
df_spark <- as.DataFrame(df_r_select)
# convert R data frame into a Spark data frame - method 2
df_spark <- createDataFrame(df_r_select)

Screen Shot 2022-04-05 at 7.13.05 PM.png

Best Practices Index
Best Practices

Just here to browse knowledge? This might help!

Contributors
Version history
Last update:
‎04-06-2022 04:52 PM
Updated by: