Sorry if this is a duplicate, but I cannot find the information elsewhere on SO, although this seems like such a simple problem. I have a data frame with several columns as factors. Some of them are integers, and some are strings. I would like to extract rows corresponding to a specific coefficient. For example,
my_data <- read.table(file = "my_data.txt", header = TRUE)
my_data[ my_data$age == 20, ]
It works, but if I then try
my_data[ my_data$gender == "male", ]
This does not match. I realized that this is not the same thing, since checking the class my_data$name[1]gives a coefficient, while I check it against a string.
Any ideas what I'm doing wrong here?
Greetings
Sample data: Age Age 1 20 men 0.5 4 22 women 0.7 3 14 women 0.3