Remove entire row with an empty entry in one column

Hello,

I have empty row values for some of the entries in a column titled start_station_id. I would like to delete every row that has no value in that particular column. I have tried
month1[!month1$start_station_id == "", " ",]
but the rows don't get deleted. The column is the the 6th in the data frame if that is relevant here.
Is there another solution?

install.packages("tidyverse")
library(tidyverse)
setwd("/cloud/project")

month1 <- read.csv("202101-divvy-tripdata.csv")

month1$started_at <- ymd_hms(month1$started_at)
month1$ended_at <- ymd_hms(month1$ended_at)
month1$time_diff_mins <- round(difftime(month1$ended_at,month1$started_at, units="mins"), 2)

month1[!month1$start_station_id == "", " ",]

Are you sure that the "empty" entries in the column contain the empty string "" or are they NA. There is a difference, as can be seen in this code.

DF <- data.frame(start_station = c("A", "", "", NA, "B"))
DF
  start_station
1             A
2              
3              
4          <NA>
5             B
sum(is.na(DF$start_station))
[1] 1
sum(DF$start_station == "", na.rm = TRUE)
[1] 2

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.