如何从 bigr.frame 按索引 select?

how to select by index from a bigr.frame?

在标准 r 中,我可以 select 使用类似以下内容的索引:

newdf <- df[1:4,]

但是,如果我在 bigr.frame 上尝试上述操作,我得到:

Error: BigR[bigr.frame.[]]: The given filtering condition must be a logical bigr.vector.

[ {bigr}的文档如下:

Description

Filter rows and project columns of a dataset

Usage

"["(x, i, j, ..., drop = TRUE)

Arguments

x (bigr.frame or bigr.matrix) the object being operated on. If x is a bigr.frame or bigr.csv.matrix, both filtering and projection are supported. If x is a bigr.binary.matrix, only projections are supported.

i (bigr.vector) a logical operation that represents the filtering condition (only for bigr.frame and bigr.matrix objects)

j (character or integer) a vector representing columns to be projected. These could be column ids (i.e., integers) or column names (i.e., characters)

drop in the case of projecting one single column, parameter drop determines whether the result should be a bigr.vector (drop=TRUE) or a bigr.frame (drop=FALSE). Default value is drop=TRUE.

Value

the derived bigr.frame, bigr.matrix, or bigr.vector

See Also

bigr.frame bigr.matrix

Examples

air[air$UniqueCarrier %in% c("UA", "HA"), c(1,2,3,5:9)]

air[, c("Origin", "Dest")]

air[air$Dest == "SFO", 17]

class(air[, 17, drop=FALSE])

class(air[, 17, drop=TRUE])

我不清楚是否可以按索引 select。这可能吗?怎么样?

第一个参数需要逻辑条件,第二个参数代表列。

您正在寻找的相同功能可以通过 head(frame, no#OfRows)

airfile <- system.file("extdata", "airline.zip", package="bigr")
airfile <- unzip(airfile, exdir = tempdir())
airR <- read.csv(airfile, stringsAsFactors=F)
air <- as.bigr.frame(airR)
head(air, 4)

参考:https://www.ibm.com/support/knowledgecenter/SSPT3X_4.0.0/com.ibm.swg.im.infosphere.biginsights.tut.doc/doc/tut_Less_BigR_Stat2.html

您可以使用as.data.frame功能。

参考:https://www.ibm.com/support/knowledgecenter/SSPT3X_4.0.0/com.ibm.swg.im.infosphere.biginsights.bigr.doc/doc/frame_as.data.frame.html?lang=en

airfile <- system.file("extdata", "airline.zip", package="bigr")

airfile <- unzip(airfile, exdir = tempdir())

airR <- read.csv(airfile, stringsAsFactors=F)

空气 <- as.bigr.frame(airR)

airdf <- as.data.frame(空气)

newdf <- airdf[1:4,]

newdf