Create table function in Spark in R not working

João_Andre  (3) 询问的问题 | 2016年12月10日 06:03BLUEMIXRSPARK

Hello, I'm trying to create a simple table in Bluemix Spark (R) but getting a error I can't understand or find useful reference about. Has anyone seen something similar? Any suggestions, please?

  1. one <- rep(1,2)
  2. two <- rep(2,2)
  3. my_table <- table(one,two)
  4. my_table
  5. Error: class(objId) == "jobj" is not TRUE
  6. Traceback:
  7. 1. table(one, two)
  8. 2. callJMethod(sqlContext, "table", tableName)
  9. 3. stopifnot(class(objId) == "jobj")
  10. 4. stop(sprintf(ngettext(length(r), "%s is not TRUE", "%s are not all TRUE"),
  11. . ch), call. = FALSE, domain = NA)
 
   0
 

4 个答案

· 添加您的答案

  • 排序:
 

由 Sven Hafeneger (176回答 | 01月04日 07:10

I think this happens due to how in R the libraries are loaded. In this case the last library loaded is "SparkR", which has a function exported with the name "table". The SparkR::table function is used, if you not fully qualify the function. That explains why in the traceback "callJMethod(sqlContext, "table", tableName)" is stated.

On workaround is to qualify the function. This worked for me for R - Spark 1.6

  1. one <- rep(1,2)
  2. two <- rep(2,2)
  3. my_table <- base::table(one,two)
  4. my_table

However, it is interesting that it works for R - Spark 2.0.

 
   1   分享
 
 

由 RolandWeber (56回答 | 2016年12月12日 00:34

Does your code snippet work in other R environments? It looks very much different from the table examples that I could find. Are you sure that "rep" in your example generates a "factor"? Maybe you have to call the "factor" function explicitly, as shown in the first link?

http://www.cyclismo.org/tutorial/R/types.html#tables

https://www.stat.berkeley.edu/classes/s133/factors.html

https://www.r-bloggers.com/r-function-of-the-day-table/

 
   0   分享
 
 

由 João_Andre (3回答 | 2016年12月13日 12:12

Hello, yes, it used to work. I got it working now after changing kernel to "R with Spark 2.0".

Thanks for your help and the links provided.

João

 
   0   分享
 
 

由 João_Andre (3回答 | 01月24日 06:56

@Sven, thanks for your clear explanation.

 
   0   分享
 
 
总结:
在sparkR中使用R的原生函数报错时
在函数前加base:::
例如z为r中的data.frame
对其在sparkr中使用table函数则需如下形式

base:::table(z)

j解决sparkr中使用某些r的原生函数 发生错误Error: class(objId) == "jobj" is not TRUE的问题的更多相关文章

  1. R语言学习笔记——C#中如何使用R语言setwd()函数

    在R语言编译器中,设置当前工作文件夹可以用setwd()函数. > setwd("e://桌面//")> setwd("e:\桌面\")> s ...

  2. Xcode中使用svn时,报证书验证错误Error validating server certificate for

    转:http://blog.csdn.net/yhawaii/article/details/7511141 今天使用Xcode自带的svn客户端时,总是连接不上服务器,报如下错误: Error va ...

  3. 解决vs2010“创建或打开C++浏览数据库文件 发生错误”的问题 Microsoft SQL Server Compact 3.5

    有网友说打开vs2010安装光盘,搜索 SSCERuntime_x86-chs.msi,重新安装之.于是果断搜索,发现SSCERuntime_x86-chs.msi,另外发现一个SSCEVSTools ...

  4. geotrellis使用(十六)使用缓冲区分析的方式解决投影变换中边缘数据值计算的问题

    Geotrellis系列文章链接地址http://www.cnblogs.com/shoufengwei/p/5619419.html 目录 前言 问题探索 采样说明 实现方案 总结 一.前言     ...

  5. 解决JQuery中datatables设置隐藏显示列多次提交后台刷新数据的问题

    此次项目开发过程中用到了Jquery的Datatables插件,无疑他是数据列表展示,解决MVC中同步过程中先走控制器后返回视图,查询数据过程中无法提示等待的弊端, 而且他所提供的各种方法也都有较强的 ...

  6. Android开发中出现cannot be resolved to a variable错误,也就是R文件不能生成。

    最近开始学过习Android开发,配置完成开发环境后,在创建第一个Android项目就出现了cannot be resolved to a variable错误,也就是R文件不能生成的问题. 以下是从 ...

  7. 15、解决14中csv用excel打开乱码的问题 open('zhihu.csv','w',newline='',encoding='utf-8-sig')

    解决14中csv用excel打开乱码的问题 ,其实就是在写csv的时候把 utf-8 改成 utf-8-sig open('zhihu.csv','w',newline='',encoding='ut ...

  8. 解决scrollView中嵌套编辑框导致不能上下滑动的问题

    EditText设置maxLines之后,文本行数超过maxLines,会网上折叠,上下滑动能够浏览全部文本. 若EditText外层有scrollView.在EditText上下滑动,不会像正常情况 ...

  9. 如何快速排查解决Android中的内存泄露问题

    概述 内存泄露是Android开发中比较常见的问题,一旦发生会导致大量内存空间得不到释放,可用内存急剧减少,导致运行卡顿,部分功能不可用甚至引发应用crash.对于复杂度比较高.多人协同开发的项目来讲 ...

随机推荐

  1. 临摹一个像素风格高楼shader

    原始效果地址:http://glslsandbox.com/e#40050.0 是一个的城市高楼感的shader,比较像素风 可以拿来做游戏背景,或者基于这个思路做一些别的效果 这个是我后来找的版本, ...

  2. Atitit spring 3.0 3.1 3.2 4.0 4.3 5.0 新特性

    Atitit spring 3.0 3.1 3.2 4.0 4.3 5.0 新特性 Spring3.0的新特性及其分析 - 我的人生不甘于平庸! - ITeye技术网站.html Spring3.0带 ...

  3. Android 源码阅读笔记

    Zygote: .Zygote 是系统启动之后创建的第二个进程2.Zygote 创建zygote Socket.虚拟机3.Zygote 在虚拟机中通过forkSystemServer, 创建Serve ...

  4. ElasticSearch + xpack 使用

    ElasticSearch 是一个高可用开源全文检索和分析组件.提供存储服务,搜索服务,大数据准实时分析等.一般用于提供一些提供复杂搜索的应.我们为什么要选择 ElasticSearch ?因为它是一 ...

  5. sql 中的 STUFF()使用说明,以及千分位的常用函数

    STUFF 删除指定长度的字符并在指定的起始点插入另一组字符. 语法 STUFF ( character_expression , start , length , character_express ...

  6. (转载)javascript将base64编码的图片数据转换为file并提交

    /** * @param base64Codes * 图片的base64编码 */ function sumitImageFile(base64Codes){ var form=document.fo ...

  7. window函数 resetAccumulator

    /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreem ...

  8. android 调用系统相机拍照 获取原图

      好吧,为了这个问题又折腾了一整天.之前在网上找来的方法,如果在onActivityResult中直接用data.getData()的方式来生成bitmap,其实获取的是拍照生成的缩略图!看看尺寸就 ...

  9. python for

    与其它大多数语言一样,Python 也拥有 for 循环.你到现在还未曾看到它们的唯一原因就是,Python 在其它太多的方面表现出色,通常你不需要它们. 其它大多数语言没有像 Python 一样的强 ...

  10. docker之创建MariaDB镜像的方法

    一.基于commit命令方式创建 docker的安装 ? 1 2 3 [root@test01 ~]# yum install docker [root@test01 ~]# systemctl en ...