O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Initialize SparkSession object:
> sparkR.session() # From your R console or RStudio# Alternatively, you may launch sparkR shell which comes with predefined SparkSession.> bin/sparkR
  1. Create Spark DataFrame:
> irisDF <- createDataFrame(iris) //Create a Spark DataFrame> showDF(irisDF,4) //Print the contents of the Spark DataFrame+------------+-----------+------------+-----------+-------+|Sepal_Length|Sepal_Width|Petal_Length|Petal_Width|Species|+------------+-----------+------------+-----------+-------+| 5.1| 3.5| 1.4| 0.2| setosa|| 4.9| 3.0| 1.4| 0.2| setosa|| 4.7| 3.2| 1.3| 0.2| setosa|| 4.6| 3.1| 1.5| 0.2| setosa|+------------+-----------+------------+-----------+-------+only showing top 4 rows
  1. The following is a subsetting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required