one of the columns in my data frame -z- contains weekdays. I would like to remove rows that have "Sunday" and "Saturday" as factor.
I used without success r<-z[-c(z$x=="Sunday" & z$x=="Saturday", ]
and
r<-subset(z, x!=="Sunday" & x!=="Saturday")
. x
is the name of the column.
Could you please help figure it out? Thanks. The data:
y x
1 1 Monday
2 2 Monday
3 3 Monday
4 4 Monday
5 5 Monday
6 6 Monday
7 7 Monday
8 8 Friday
9 9 Friday
10 10 Friday
11 11 Friday
12 12 Sunday
13 13 Sunday
14 14 Sunday
15 15 Sunday
16 16 Saturday
17 17 Saturday
18 18 Saturday
19 19 Saturday
20 20 Saturday
UPDATE:
I accepted the answer as it worked with the df I provided. When I try to apply it to the df I have it does not do anything. I use
flexW<-subset(flex, Day!="Sunday" & Day!="Saturday")
The selected variable from the data frame:
str(flex) 'data.frame': 177237 obs. of 14 variables: .... $ Day : Factor w/ 7 levels " Friday"," Monday",..: 2 2 2 2 2 2 2 2 2 2 ...