I've never been very skilled with R and am coming back after an absence so I'm re-learning a lot. I've got a dataset (named data) that has fields latitude and longitude. Some of the observations have '0' in these fields, which is invalid data. I'm writing an R notebook to document my findings.
I have:
Let's start by finding out how many records have 0 for latitude and longitude. If it's 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's find out.
```{r}
filter(data, latitude == 0.0)
```
The first two lines that start with nrow() both display the output I expect:
[1] 12
[1] 12
However, the same filter statement, which I expect to output the 12 rows that match the filter criteria, gives me an error when I run the chunk:
Error in vapply(x, obj_sum, character(1L)) : values must be length 1,
but FUN(X[[11]]) result is length 0
I don't understand why I'm getting this error. The 'data' variable is a tibble, if that makes a difference.
I'd sure appreciate an explanation of what's happening here.
data
exists in your global environment but isn't created when you knit/etc.data
might be part of that.