小编Pra*_*nth的帖子

R-Error:data_frames只能包含1d原子矢量和列表

我正在尝试应用dplyr包并使用以下函数计算数据集中每个卡号的条目数:

freq<- function(data){
  data <- complete.dupremoved[order(-complete.dupremoved$SUMMA),]
  aggregate(count ~., data=transform(complete.dupremoved,count=1), length)
  complete.dupremoved$count <-complete.dupremoved[complete.dupremoved$KLIENDIKAARDINR,]
  sample <- count(complete.dupremoved, vars = "KLIENDIKAARDINR")
  complete.dupremoved<- merge(complete.dupremoved,sample, by ="KLIENDIKAARDINR")
  return(complete.dupremoved)
}
Run Code Online (Sandbox Code Playgroud)

显示的错误是错误:data_frames只能包含1d原子向量和列表.

当我这样做:lapply(complete.dupremoved,class)

有些列是数字,因子,字符,整数.任何解决方案如何解决?调试器还提供以下内容:

function (x) 
{
    stopifnot(is.list(x))
    if (length(x) == 0) {
        x <- list()
        class(x) <- c("tbl_df", "tbl", "data.frame")
        attr(x, "row.names") <- .set_row_names(0)
        return(x)
    }
    names_x <- names2(x)
    if (any(is.na(names_x) | names_x == "")) {
        stop("All columns must be named", call. = FALSE)
    }
    ok <- vapply(x, is_1d, logical(1))
    **if (any(!ok)) {
        stop("data_frames can only …
Run Code Online (Sandbox Code Playgroud)

r plyr dplyr

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

dplyr ×1

plyr ×1

r ×1