SparkR-Install
SparkR-Install
标签: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的更多相关文章
- 在CentOS上安装并运行SparkR
环境配置—— 操作系统:CentOS 6.5 JDK版本:1.7.0_67 Hadoop集群版本:CDH 5.3.0 安装过程—— 1.安装R yum install -y R 2.安装curl-de ...
- Apache Spark技术实战之5 -- SparkR的安装及使用
欢迎转载,转载请注明出处,徽沪一郎. 概要 根据论坛上的信息,在Sparkrelease计划中,在Spark 1.3中有将SparkR纳入到发行版的可能.本文就提前展示一下如何安装及使用SparkR. ...
- shiny server SparkR web展示界面(二)
1. 需要先在Mac OS中安装好R,Rstudio中,这个比较简单,掠过 2. 下载编译好的spark(spark-2.0.0-bin-hadoop2.6.tgz)可以在Spark官网下载到你所需 ...
- shiny server SparkR web展示界面(一)
1. shiny server简介 shiny-server是一种可用把R 语言以web形式展示的服务,下面就讲讲如何在自己的服务器上构建Shiny Server.下一篇主要介绍如何集成sparkR后 ...
- CentOS下SparkR安装部署:hadoop2.7.3+spark2.0.0+scale2.11.8+hive2.1.0
注:之前本人写了一篇SparkR的安装部署文章:SparkR安装部署及数据分析实例,当时SparkR项目还没正式入主Spark,需要自己下载SparkR安装包,但现在spark已经支持R接口,so更新 ...
- SparkR安装部署及数据分析实例
1. SparkR的安装配置 1.1. R与Rstudio的安装 1.1.1. R的安装 我们的工作环境都是在Ubuntu下操作的,所以只介绍Ubuntu下安装R的方法 ...
- Apache Spark 2.2.0 中文文档 - SparkR (R on Spark) | ApacheCN
SparkR (R on Spark) 概述 SparkDataFrame 启动: SparkSession 从 RStudio 来启动 创建 SparkDataFrames 从本地的 data fr ...
- sparkR介绍及安装
sparkR介绍及安装 SparkR是AMPLab发布的一个R开发包,为Apache Spark提供了轻量的前端.SparkR提供了Spark中弹性分布式数据集(RDD)的API,用户可以在集群上通过 ...
- centos 部署 SparkR
---恢复内容开始--- 环境配置—— 操作系统:CentOS 6.5 JDK版本:1.7.0_67 Hadoop集群版本:CDH 5.3.0 安装过程—— 1.(1)安装R yum install ...
- SparkR安装
一.在虚拟机中安装R语言 1.下载R语言压缩包R-3.2.2.tar.gz,放在目标目录下 ★在此特别提醒,尽量安装3.2.?版本的R,更高版本的R容易出现依赖包安装不全的问题. # mv R-3.2 ...
随机推荐
- mongodb更新数组元素中的字段,数组$占位符
pppCodes为数组,PPPCode,expiredOn为数组元素中的字段 db.getCollection('users').findOneAndUpdate({ _id: userId, 'pp ...
- React Native使用init新建项目出现异常
情况说明 最近在使用使用react-native init之后没有生成app.js, index.js等文件,缺少了很多文件,如图: 原因 因为近期rn更新,某些东西不适配,然后暂时能找到的方法就是指 ...
- 通过Redis、Memcache的 incr 原子操作防刷机制的使用差别
我的版本如下: Redis:3.2.100 Memcache:1.4.4 最近在处理服务器压力测试的时候,想到一个方案,在一定时间段内限制用户访问次数.具体的实现就是通过redis的院子操作incre ...
- System.out.println()和System.err.println()
在一次笔试中遇到了一个System.err.println()的输出,之前没有见过,回来查一查,自己还是见识太短,来补充一下. 首先看一看jdk中 来一个简单的实验 第一次显示 第二次显示 1. 发现 ...
- C++学习笔记54:关联容器,函数对象
关联容器的特点 1.每个关联容器都有一个键(key) 2.可以根据键高效查找元素 集合set 集合用来存储一组无重复的元素,由于集合的元素本身是有序的,可以高效地查找元素,也可以方便地指定大小范围的元 ...
- 批量操作数据库数据mybatis.xml
批量插入数据 <insert id="equipment_Add" parameterType="cn.wtsr.core.web.dao.vo.equipment ...
- Yii2 rules验证规则大全
1.required : 必须值验证属性 [['字段名'],required,'requiredValue'=>'必填值','message'=>'提示信息']; #说明:CRequire ...
- invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific
今天写vfl自动给布局之时,出现了 invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific- break on _C ...
- px与rem的换算
在线转化工具: http://www.ofmonkey.com/front/rem rem是相对于根元素<html>,这样就意味着,我们只需要在根元素确定一个参考值,这个参考值设置为多少, ...
- redis:sentinel监控服务器
1. Sentinel工具完成监控--操作步骤 (1)把redis解压包中的sentinel.conf拷贝到redis的安装目录下: [root@192 redis]# cp /opt/redis-4 ...