I have a .txt file read into a table called power with over 2 million observations of 9 variables. I am trying to subset power by two rows containing either "01/02/2007" or "02/02/2007". After creating the subset, the RStudio environment said I ended up with zero observations, but the same variables.
How can I get a subset of the data with only rows containing "01/02/2007" and "02/02/2007"?
I saw a similar post, but still got an error on my dataset. See link: Select multiple rows conditioning on ID in R
My data:
#load data
> power <- read.table("textfile.txt", stringsAsFactors = FALSE, head = TRUE)
#subsetted first column called Date
> head(power$Date)
#[1] 16/12/2006 16/12/2006 16/12/2006 16/12/2006 16/12/2006 16/12/2006
> str(power$Date)
chr [1:2075259] "16/12/2006" "16/12/2006" "16/12/2006" "16/12/2006" ...
My code:
> subpower <- subset(power, Date %in% c("01/02/2007", "02/02/2007"))
Subset data:
> str(powersub$Date)
chr(0)