How do I perform this complicated ANOVA type analysis in R? I have the following type of dataset:

        |          |             |            variable_r         |
subject |  gender  |  age_group  |     Cond_1    |     Cond_2    |
--------|----------|-------------|---------------|---------------|
   1    |    m     |      1      | r (A) | r (B) | r (A) | r (B) |
   2    |    f     |      2      | r (A) | r (B) | r (A) | r (B) |
...
   8    |    f     |      2      | r (A) | r (B) | r (A) | r (B) |

So two genders, two age groups, two conditions (Cond_1 and Cond_2) under which the experiment was done and two ways the subjects were prompted (A and B). r is the numerical result from each experiment. So two within-subject variables (prompt A/B and Cond 1/2) and two between-subject variables (age group 1/2 and gender m/f) (right?). I should calculate the statistically significant effects of each variable and their interactions.
How can I do this in R (or Python)? My googling found a lot of information about different types of ANOVA analyses, but I wasn't able to apply that information to my case.
Thanks!
e: the subjects were tested 4 times
 A: yes, this is entirely possible in R. Not only that, there are many ways of doing it. One way that I would suggest is with a mixed linear model from the package 'nlme'
You would need to structure your data (dt) so that there were four observations for each participant. Something like this:
Subject Gender  Age Condition   DV
1       1       2   1a          X
1       1       2   1b          X
1       1       2   2a          X
1       1       2   2b          X
2       1       1   1a          X
2       1       1   1b          X
2       1       1   2a          X
2       1       1   2b          X
3       2       2   1a          X
3       2       2   1b          X
3       2       2   2a          X
3       2       2   2b          X

There should be an option within the package to automatically convert your dataset. After that, use something like the following code:
library(nlme)
lme(DV ~ Gender + Age + Condition, data = dt, random = ~ 1 | Subject)

Hope this helps point you in the right direction!
