I'm working with occurrence records and want to remove records that are missing coordinates, with the line:
records0 <- records[records$decimalLatitude == 0 | records$decimalLongitude == 0,]
(decimalLatitude
and decimalLongitude
are two of my columns)
But when I look at records0
, it shows the right number of rows for which the coordinates are missing, but all of the other columns are empty as well (shows NA
when they should still contain the rest of my data).
Why could that be? (The object records
containing my dataset looks as it should.)
records <- fread("Occurrences-Example.csv")
dput(records[1:4, ]) structure(list(rightsHolder = c("", "", "Naturalis Biodiversity Center", "Naturalis Biodiversity Center"), type = c(NA, NA, NA, NA), decimalLatitude = c(-4.565474, NA, NA, -0.832667), decimalLongitude = c(12.480469, NA, NA, 13.9735 ), scientificName = c("Gigasiphon gossweileri (Baker f.) Torre & Hillc.", "Gigasiphon gossweileri (Baker f.) Torre & Hillc.", "Bauhinia humblotiana Baill.", "Gigasiphon gossweileri (Baker f.) Torre & Hillc.")), row.names = c(NA, -4L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x7f8dfc812ee0>)
records0 <- records[records$decimalLatitude == 0 | records$decimalLongitude == 0,] records0 Empty data.table (0 rows) of 5 cols: rightsHolder,type,decimalLatitude,decimalLongitude,scientificName