SparkR-Install

时间:2017-03-30 23:05:18      阅读:17      评论:0      收藏:0      [点我收藏+]

标签:too   下载   安装jdk   context   writing   磁盘   anti   1.5   products

1.下载R

https://cran.r-project.org/src/base/R-3/

1.2 环境变量配置:

1.3 测试安装:

2.下载Rtools33

https://cran.r-project.org/bin/windows/Rtools/

2.1 配置环境变量

2.2 测试:

3.安装RStudio

https://www.rstudio.com/products/rstudio/download/ 直接下一步即可安装

4.安装JDK并设置环境变量

4.1环境变量配置:

4.2测试:

5.下载Spark安装程序

5.1 URL: http://spark.apache.org/downloads.html

5.2解压到本地磁盘的对应目录

6.安装Spark并设置环境变量

7.测试SparkR

注意:如果发现了提示 WARN NativeCodeLader:Unable to load native-hadoop library for your platform.....using

builtin-java classes where applicable  需要安装本地的hadoop库

8.下载hadoop库并安装

http://hadoop.apache.org/releases.html

9.设置hadoop环境变量

10.重新测试SparkR

10.1 如果测试时候出现以下提示,需要修改log4j文件INFO为WARN,位于\spark\conf下

10.2 修改conf中的log4j文件:

10.3 重新运行SparkR

11.运行SprkR代码

在Spark2.0中增加了RSparkSql进行Sql查询

dataframe为数据框操作

data-manipulation为数据转化

ml为机器学习

11.1 使用crtl+ALT+鼠標左鍵 打开控制台在此文件夹下

11.2 执行spark-submit xxx.R文件即可

12.安装SparkR包

12.1 将spark安装目录下的R/lib中的SparkR文件拷贝到..\R-3.3.2\library中,注意是将整个Spark文件夹,而非里面每一个文件。

源文件夹:

目的文件夹:

12.2  在RStudio中打开SparkR文件并运行代码dataframe.R文件,采用Ctrl+Enter一行行执行即可

SparkR语言的dataframe.R源代码如下

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# library(SparkR) # Initialize SparkContext and SQLContext
sc <- sparkR.init(appName="SparkR-DataFrame-example")
sqlContext <- sparkRSQL.init(sc) # Create a simple local data.frame
localDF <- data.frame(name=c("John", "Smith", "Sarah"), age=c(19, 23, 18)) # Convert local data frame to a SparkR DataFrame
df <- createDataFrame(sqlContext, localDF) # Print its schema
printSchema(df)
# root
# |-- name: string (nullable = true)
# |-- age: double (nullable = true) # Create a DataFrame from a JSON file
path <- file.path(Sys.getenv("SPARK_HOME"), "examples/src/main/resources/people.json")
peopleDF <- read.json(sqlContext, path)
printSchema(peopleDF) # Register this DataFrame as a table.
registerTempTable(peopleDF, "people") # SQL statements can be run by using the sql methods provided by sqlContext
teenagers <- sql(sqlContext, "SELECT name FROM people WHERE age >= 13 AND age <= 19") # Call collect to get a local data.frame
teenagersLocalDF <- collect(teenagers) # Print the teenagers in our dataset
print(teenagersLocalDF) # Stop the SparkContext now
sparkR.stop()

13.Rsudio 运行结果

END~

SparkR-Install的更多相关文章

  1. 在CentOS上安装并运行SparkR

    环境配置—— 操作系统:CentOS 6.5 JDK版本:1.7.0_67 Hadoop集群版本:CDH 5.3.0 安装过程—— 1.安装R yum install -y R 2.安装curl-de ...

  2. Apache Spark技术实战之5 -- SparkR的安装及使用

    欢迎转载,转载请注明出处,徽沪一郎. 概要 根据论坛上的信息,在Sparkrelease计划中,在Spark 1.3中有将SparkR纳入到发行版的可能.本文就提前展示一下如何安装及使用SparkR. ...

  3. shiny server SparkR web展示界面(二)

    1.  需要先在Mac OS中安装好R,Rstudio中,这个比较简单,掠过 2. 下载编译好的spark(spark-2.0.0-bin-hadoop2.6.tgz)可以在Spark官网下载到你所需 ...

  4. shiny server SparkR web展示界面(一)

    1. shiny server简介 shiny-server是一种可用把R 语言以web形式展示的服务,下面就讲讲如何在自己的服务器上构建Shiny Server.下一篇主要介绍如何集成sparkR后 ...

  5. CentOS下SparkR安装部署:hadoop2.7.3+spark2.0.0+scale2.11.8+hive2.1.0

    注:之前本人写了一篇SparkR的安装部署文章:SparkR安装部署及数据分析实例,当时SparkR项目还没正式入主Spark,需要自己下载SparkR安装包,但现在spark已经支持R接口,so更新 ...

  6. SparkR安装部署及数据分析实例

    1. SparkR的安装配置 1.1.       R与Rstudio的安装 1.1.1.           R的安装 我们的工作环境都是在Ubuntu下操作的,所以只介绍Ubuntu下安装R的方法 ...

  7. Apache Spark 2.2.0 中文文档 - SparkR (R on Spark) | ApacheCN

    SparkR (R on Spark) 概述 SparkDataFrame 启动: SparkSession 从 RStudio 来启动 创建 SparkDataFrames 从本地的 data fr ...

  8. sparkR介绍及安装

    sparkR介绍及安装 SparkR是AMPLab发布的一个R开发包,为Apache Spark提供了轻量的前端.SparkR提供了Spark中弹性分布式数据集(RDD)的API,用户可以在集群上通过 ...

  9. centos 部署 SparkR

    ---恢复内容开始--- 环境配置—— 操作系统:CentOS 6.5 JDK版本:1.7.0_67 Hadoop集群版本:CDH 5.3.0 安装过程—— 1.(1)安装R yum install ...

  10. SparkR安装

    一.在虚拟机中安装R语言 1.下载R语言压缩包R-3.2.2.tar.gz,放在目标目录下 ★在此特别提醒,尽量安装3.2.?版本的R,更高版本的R容易出现依赖包安装不全的问题. # mv R-3.2 ...

随机推荐

  1. ES6快速入门(三)类与模块

    类与模块 一.类 一)类的声明 class Person { constructor(name) { this.name = name; } sayName() { console.log(this. ...

  2. Vue.Js初学踩坑

    1 Vue2之后取消了v-bind的.sync修饰符,意味着父子组件的数据不能以此来实现双向绑定. 2 Vue2之后取消了filterBy过滤器,所以以下这种用法是错误的了. <tbody> ...

  3. 编程菜鸟的日记-初学尝试编程-寻找2到n之间的素数并输出

    //输入一个整数n,输出2到n之间的具体素数值 #include <iostream> #include <algorithm> #include <cmath> ...

  4. 反编译安卓apk以及jar包

    https://www.jianshu.com/p/c9b553cf2b51 https://blog.csdn.net/bzlj2912009596/article/details/78268896

  5. 打开沙盒文件iOS

    有时使用数据库是需要查看或者更换沙盒里的数据库等文件 那么如何拿到真机的沙盒 查看真机沙盒教程 打开Devices 在xcode的上部导航栏里,选择window -> Devices and S ...

  6. java第二周的学习知识3(==与equals)

    ==与equals()的之间的差别1)对于==,如果作用于基本数据类型的变量,则直接比较其存储的 “值”是否相等:如果作用于引用类型的变量,则比较的是所指向的对象的地址 2)对于equals方法,注意 ...

  7. ES6_函数方法

    //2017/7/15 //Javascript 中的方法:在一个对象中绑定函数,称为这个对象的方法. */ var boy={ name:'xiaoming', birth:2007, age:fu ...

  8. 牛客网--C++-2017/8/19

    “\t\v\\0”长度=4:\0:字符串结束符:\\0:\将\0进行了转义,所以\0是两个字符 类的友元函数的访问权限跟类内部的方法相同,但是友元函数不属于本类的对象,一般它是另一个类的成员函数,不能 ...

  9. Sublime Text 显示韩文和文件编码

    菜单  Preferences –> Settings 右侧的User {    "font_size": 12,    "show_encoding": ...

  10. android:第十章,后台的默默劳动者——服务,学习笔记

    一.多线程 1)本章首先介绍了安卓的多线程编程,说明在子线程中如果要修改UI,必须通过Handler, Message, MessageQueue, Looper来实现,但是这样毕竟太麻烦了.  2) ...