I have 569 rows of data related to breast cancer. In column A, each row either has a value of 'M' or 'B' in the cell (malignant or benign). In column B, the concavity of the nucleus of each tumour is given. I want to find the mean concavity for all malignant tumours, and for all benign tumours, separately.
Edit: first 25 rows of columns A and B given below as an example
> df2
data2.diagnosis data2.concavity_mean
1 M 0.3001000
2 M 0.0869000
3 M 0.1974000
4 M 0.2414000
5 M 0.1980000
6 M 0.1578000
7 M 0.1127000
8 M 0.0936600
9 M 0.1859000
10 M 0.2273000
11 M 0.0329900
12 M 0.0995400
13 M 0.2065000
14 M 0.0993800
15 M 0.2128000
16 M 0.1639000
17 M 0.0739500
18 M 0.1722000
19 M 0.1479000
20 B 0.0666400
21 B 0.0456800
22 B 0.0295600
23 M 0.2077000
24 M 0.1097000
25 M 0.1525000
How do I ask R to give me "the mean of rows in column B, given their value in column A is M" and then "given their value in column A is B"?