The error in vapply ... values ​​should be length 1, but FUN (X [[11]]) is length 0

I have never been very experienced with R and come back from absence, so I retrain a lot. I have a data set (named data) that has the latitude and longitude of the fields. Some of the observations have a "0" in these fields, which is invalid data. I am writing an R notebook to document my results.

I have:

    Let start by finding out how many records have 0 for latitude and longitude. If it a great deal of records, we might not be able to rely on these fields:
```{r}
nrow(filter(data, latitude == 0.0))
nrow(filter(data, longitude == 0.0))
```
Okay, there are 12 rows that have 0 for latitude and 12 rows that have 0 for longitude. I'm willing to bet these are the same rows. Let find out.

```{r}
filter(data, latitude == 0.0)
```

The first two lines starting with nrow () display the expected result:

[1] 12
[1] 12

However, the same filter statement that I expect to display 12 lines matching the filter criteria gives me an error when starting the block:

Error in vapply(x, obj_sum, character(1L)) : values must be length 1,
 but FUN(X[[11]]) result is length 0

I do not understand why I am getting this error. The variable "data" is the tible, if that matters.

I would be happy to explain what is happening here.

+6
1

, , 2 , .

, , . :

```{r}
library (dplyr)
library (purrr)

# create data
mydata <- 
  tibble(col_a = rep(c("a", "b"), 5)) %>% 
  mutate(col_b = map(col_a, function (x) { list(a = x, b = x, c = x) }))

# filter
mydata %>% filter (col_a == "a")
```

, , / . , R-markdown ( Ctrl + Enter R-studio), :

Error in vapply(x, obj_sum, character(1L)) : values must be length 1,
 but FUN(X[[1]]) result is length 3

"" - col_b.

, . ?

+4

Source: https://habr.com/ru/post/1015228/


All Articles