Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGZILLA #16648] complete.cases() give misleading message #6035

Open
MichaelChirico opened this issue May 18, 2020 · 2 comments
Open

[BUGZILLA #16648] complete.cases() give misleading message #6035

MichaelChirico opened this issue May 18, 2020 · 2 comments

Comments

@MichaelChirico
Copy link
Owner

I have a data frame:

df
    Time Treat

1 2015-03-28 1
2 2015-03-28 1
3 2015-03-28 1

dput(df)

structure(list(Time = structure(list(sec = c(0, 0, 0), min = c(0L,
0L, 0L), hour = c(0L, 0L, 0L), mday = c(28L, 28L, 28L), mon = c(2L,
2L, 2L), year = c(115L, 115L, 115L), wday = c(6L, 6L, 6L), yday = c(86L,
86L, 86L), isdst = c(0L, 0L, 0L), zone = c("CST", "CST", "CST"
), gmtoff = c(NA_integer_, NA_integer_, NA_integer_)), .Names = c("sec",
"min", "hour", "mday", "mon", "year", "wday", "yday", "isdst",
"zone", "gmtoff"), class = c("POSIXlt", "POSIXt")), Treat = c(1L,
1L, 1L)), .Names = c("Time", "Treat"), row.names = c(NA, 3L), class = "data.frame")

when I apply complete.cases() on it, it gives error message:

complete.cases(df)

Error in complete.cases(df) : not all arguments have the same length

It seems that complete.case() cannot handle the first column. I think it should give a warning message such as the class/type is not supported, instead of error message without any hints about the error.

version
           _                           

platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 2.3
year 2015
month 12
day 10
svn rev 69752
language R
version.string R version 3.2.3 (2015-12-10)
nickname Wooden Christmas-Tree


METADATA

  • Bug author - Jinsong Zhao
  • Creation time - 2015-12-30 01:01:58 UTC
  • Bugzilla link
  • Status - UNCONFIRMED
  • Alias - None
  • Component - Misc
  • Version - R 3.2.2
  • Hardware - Other Other
  • Importance - P5 enhancement
  • Assignee - R-core
  • URL -
  • Modification time - 2016-01-03 21:30 UTC
@MichaelChirico
Copy link
Owner Author

The problem here is that complete.cases doesn't use the R function length() to determine the length of the Time column, it uses the C macro LENGTH, which ignores the fact that Time is of class POSIXlt, and sees it as a length 11 list.

A workaround is to convert the time to POSIXct instead of POSIXlt.

It looks quite messy to fix this properly, so I'll just add a note to the documentation warning about the problem.


METADATA

  • Comment author - Duncan Murdoch
  • Timestamp - 2016-01-02 16:01:54 UTC

@MichaelChirico
Copy link
Owner Author

It actually looks pretty straightforward to translate the C code to R code which will pay attention to the classes. If that doesn't slow it down too much, I'll make that change.


METADATA

  • Comment author - Duncan Murdoch
  • Timestamp - 2016-01-03 21:30:41 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant