Suppose that a certain disease ($D$) has a prevalence of $\dfrac3{1000}$. Also suppose that a certain symptom ($S$) has a prevalence (in the general population = people with that disease$ $D and people without that disease [probably with other disease, but it's not important]) of $\dfrac5{1000}$. In a previous research, it was discovered that the conditional probability $P(S|D) = 30\%$ (the probability to have the symptom $S$, given the disease $D$ is $30\%$).
First question: Could be $P(S|D)$ interpreted as equivalent to the prevalence of the symptom $S$ in the group of people having the disease $D$?
Second question: I want to create in R a dataset, which shows that:
$$P(D|S) = \frac{P(S|D)P(D)} {P(S)}$$ With my fictional data, we can compute $P(D|S)=0.18$, that is interpreted in this way: given a patient with the symptom $S$, the probability that he has the disease $D$ is $18\%$.
How to do this? If I use simply the sample
function, my dataset is lacking of the information that $P(S|D)=30\%$:
symptom <- sample(c("yes","no"), 1000, prob=c(0.005, 0.995), rep=T)
disease <- sample(c("yes","no"), 1000, prob=c(0.002, 0.998), rep=T)
So my question is: how to create a good dataset, including the conditional probability I desire?
EDIT: I posted the same question also on stackoverflow.com (https://stackoverflow.com/questions/7291935/how-to-create-a-dataset-with-conditional-probability), because, in my opinion, my question is inherited to the R language program, but also to statistical theory.