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. 呃,如何使 .NET 程序,在 64位 系统 中,以 32位 模式运行。

    其实最简单的方法就是在解决方案中,把平台设为 x86 就好了哈~   但是今天遇到一个第三方的软件,它调用的一个 dll 是 32位 的,可能它没有测试过在 64位 系统下运行的情况,它在编译时是按默 ...

  2. Android 如何在Eclipse 引入外部纯Java项目(不是打成Jar使用)

    应用情景--如标题: 在Eclipse的 “Android启动项目”中引入“外部的纯Java项目”,能运行的只有是基于Android的测试代码才可以. 一直很纳闷,如果外部写好一个Java插件(例如服 ...

  3. ios开发-引导页实现

    源码:http://files.cnblogs.com/ios8/%5Bcode4app.com%5DIntroductionTutorialView_10843.zip 可以看看demo,很简单,我 ...

  4. [svc]linux性能监控

    参考 w - Show who is logged on and what they are doing. [root@n1 ~]# w # w - Show who is logged on and ...

  5. Logcat + money 笔记

    如下命令:将过滤后的日志按照指定格式输出到指定的文件中 adb logcat -v time -s Test_Tag:v > logcat_local.txt A:其中 -v time 用来指定 ...

  6. redis 指定IP访问

    配置IPTABLES -A INPUT -s 10.100.0.5 -p tcp --dport 6379 -j ACCEPT -A INPUT -s 10.100.0.219 -p tcp --dp ...

  7. NonWindowJoin

    package org.apache.flink.table.runtime.join /** * Connect data for left stream and right stream. Bas ...

  8. IIS6 301重定向和IIS7 301重定向

    IIS6 301重定向 1.先在IIS里把网站正常发布,例如域名为(www.114390.com) 2.再硬盘上建一个空文件夹 3.再到IIS里建一个网站,例如域名为(114390.com),指向这个 ...

  9. Leetcode:Scramble String 解题报告

    Scramble String Given a string s1, we may represent it as a binary tree by partitioning it to two no ...

  10. 关于Python中深拷贝与浅拷贝的理解(一)---概念

    import copy a = [1, 2, 3, 4, ['a', 'b']] #原始对象 b = a #赋值,传对象的引用 c = copy.copy(a) #对象拷贝,浅拷贝 d = copy. ...