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.
As alistaire mentioned in the comments***:
head(df[df$VAR1==1,],20)
***and if he puts it as an answer I'll delete this so that he can get credit, we just need answers in the answers section and for them to get marked as the solution for the benefit of future readers (most people won't look in comments for a solution)