I'm just learning to use R, so it may seems as a noob question for you, but I have some problems with function “subset”. I tried to find an answer in previous questions, but failed(
For example, I have a data frame q with 3 variables x, y, z
q = read.csv("test.csv",encoding = "UTF-8",
header = TRUE, sep = ",", na.strings = c("",NA))
Variable x has 4 meanings a, b, c, d
I'm trying to make a data frame q1 only with 2 meanings of variable x - a & c
q1 = subset(q, q$x == 'a' | q$x == 'c')
As a result I have new data frame with 2 meanings of variable x (I check it by opening new dataframe).
But when I table variable x from new dataset q1, I see again 4 meanings, but with the number of b & d =0.
What do I do incorrectly? Why do I see b & d, when I table x in new data set?
Thanks for your help!