Skip to content

different behavior when multiply zero-column dataframe #61

@comicfans

Description

@comicfans
test.df <- data.frame(col1 = c(1,2))
test.df[,character(0)] * test.df$col1

GNU-R:
data frame with 0 columns and 0 rows

fastR:
Error in rep.int(seq_len(ncol(e1)), rep.int(nrow(e1), ncol(e1))) :
invalid 'times' value

purpose for these code is to process column without worry about column existence, for example

test.df <- data.frame(col1 = c(1,2))
column.process <- 'no_such'
column.selected <-  colnames(test.df)[ column.process %in%  colnames(test.df)]
test.df[,column.selected]  <- test.df[,column.selected] * test.df$col1
#  test.df didn't change

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions