are_na() should not work on lists #558
Comments
In general we consider it is not good UI to auto-map atomic vector functions over lists. |
Sorry if I wasn't clear, what I was hoping would be possible would be |
I am not sure I understand because |
But > rlang::are_na(head(airquality))
Ozone Solar.R Wind Temp Month Day
1 FALSE FALSE FALSE FALSE FALSE FALSE
2 FALSE FALSE FALSE FALSE FALSE FALSE
3 FALSE FALSE FALSE FALSE FALSE FALSE
4 FALSE FALSE FALSE FALSE FALSE FALSE
5 TRUE TRUE FALSE FALSE FALSE FALSE
6 FALSE TRUE FALSE FALSE FALSE FALSE > rlang::are_na(head(airquality$Ozone))
[1] FALSE FALSE FALSE FALSE TRUE FALSE There is not consistent behaviour in Base R for > is.infinite(airquality)
Error in is.infinite(airquality) :
default method not implemented for type 'list' It only works on a column, or a list is.infinite(airquality$Ozone)
Same as for > is.nan(airquality)
Error in is.nan(airquality) :
default method not implemented for type 'list'
> is.nan(airquality$Ozone)
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[10] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[19] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[28] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[46] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[55] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[64] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[73] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[82] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[91] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[100] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[109] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[118] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[127] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[136] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[145] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE Do you think
|
Well I think that's a bug ;) |
|
I think it would be helpful to have a verb/function that does always return a data.frame / matrix:
What do you think? |
Yes, but I think that would be out of scope for rlang, and sounds more like a vctrs function to me. |
OK fair enough - should I add this to the existing issue on |
Yes - I think the principle that we could now follow is that |
(And actually that's a nice description of a vectorised function - the shape of the output matches the shape of the input(s)) |
Hello!
At the moment in
is.nan
andis.infinite
don't work on dataframes, so I wonder if it would be useful to createis_inf
,are_inf
, andis_nan
andare_nan
equivalents?Happy to submit a PR for this if you think it would be in scope
Created on 2018-07-08 by the reprex package (v0.2.0).
The text was updated successfully, but these errors were encountered: