I am very new to R and am just doing a course learning it. I am working with 3 categorical variables:
adult told they had asthma
adult still has asthma
gender
I am trying to find out of all those that said "Yes" to "told they had asthma", how many of those said "Yes" to "still has asthma". And finally, by gender.
I am really struggling to do even the first part. Is there anyway I can filter all the "Yes" from the first variable and then find all the "Yes" in the second variable?
I tried using the filter function, but for some reason, it comes back to "0 row" as the result.
Any advice and guidance will be greatly appreciated!
Does this mean I should convert the data into numerical variables first? Would that work better to what I am trying to do?
Also Re: fcas80, what does the following mean?
t <- table(df)
ftable(t)
My data frame is called Q1asthma, so I assume I substitute the first line with "Q1asthma <- Q1asthma (" . Is that correct? And am I supposed to substitute "t" with something else? Because I got the error message "could not find function "Q1asthma" (see screenshot). Screen Shot 2020-08-19 at 3.51.25 PM|690x387
Thank you so much again, I don't really know what I am doing, both your advice is greatly appreciated!!!
table(df) says convert the dataframe to a a table. ftable creates a contingency table for more than two variables.
Your data is already in a dataframe, so you don't need my first line df <- data.frame( ... I am only using it to generate some sample data to use with table and ftable.