通过使用SparkR获取特定的行 [英] Get specific row by using SparkR

查看:179
本文介绍了通过使用SparkR获取特定的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在类型数据框中的SparkR数据集的数据。
我想获得进入50号为例。
在R I只需键入数据[50] ,但我这样做是sparkR当我得到这个消息

I have a dataset "data" in SparkR of type DataFrame. I want to get entry number 50 for example. In R I simply type data[50,] but when I do this in sparkR I get this message

错误:对象类型的S4不是subsettable

"Error: object of type 'S4' is not subsettable"

我能做些什么来解决这个问题?

What can I do to solve this ?

另外:我怎样才能(在同一列的大小)中添加一列中的数据

Furthermore: How can I add a column (of the same column-size) to the data?

推荐答案

你能做的唯一的事情就是

The only thing you can do is

all50 <- take(data,50)
row50 <- tail(all50,1)

SparkR没有row.names,因此你不能子集的索引。这种方法的工作,但你不希望使用它在大型数据集。

SparkR has no row.names, hence you can not subset on an index. This approach works, but you do not want to use it on big datasets.

另外你问题的第二部分是不可能的呢。您只能添加基于数字(例如一个常数列),或通过制作属于您的数据框列的转换列。
这实际上已经问<一个href=\"http://stackoverflow.com/questions/31589222/how-to-do-bind-two-dataframe-columns-in-sparkr\">How做绑定两个数据框列sparkR?。

Also the second part of your question is not possible yet. You can only add columns based on numbers (e.g. a constant column) or by making transformations of columns that belong to your DataFrame. This was actually already asked in How to do bind two dataframe columns in sparkR?.

这篇关于通过使用SparkR获取特定的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆