I use head(df,20)
to see the first twenty rows of my data.
Then I want to see the first twenty rows of my data where VAR1 equal to 1.
I use this head(df[df$VAR1==1],20)
But it shows
Error in `[.data.frame`(df, df$VAR1== 1) :
undefined columns selected
How do I fix it? Thanks in advance.