0
$\begingroup$

Essentially, this is my data set

X Class    Sex   Age Survived Freq
1   1st   Male Child       No    0
2   2nd   Male Child       No    0
3   3rd   Male Child       No   35
4  Crew   Male Child       No    0
5   1st Female Child       No    0
6   2nd Female Child       No    0
7   3rd Female Child       No   17
8  Crew Female Child       No    0
9   1st   Male Adult       No  118
10  2nd   Male Adult       No  154
11  3rd   Male Adult       No  387
12  Crew   Male Adult       No  670
13  1st Female Adult       No    4
14  2nd Female Adult       No   13
15  3rd Female Adult       No   89
16  Crew Female Adult       No    3
17  1st   Male Child      Yes    5
18  2nd   Male Child      Yes   11
19  3rd   Male Child      Yes   13
20  Crew  Male Child      Yes    0
21  1st Female Child      Yes    1
22  2nd Female Child      Yes   13
23  3rd Female Child      Yes   14
24  Crew Female Child      Yes    0
25  1st   Male Adult      Yes   57
26  2nd   Male Adult      Yes   14
27  3rd   Male Adult      Yes   75
28  Crew  Male Adult      Yes  192
29  1st Female Adult      Yes  140
30  2nd Female Adult      Yes   80
31  3rd Female Adult      Yes   76
32  Crew Female Adult      Yes   20

If there were no frequency but only single valued data, then I know how to invoke rpart to construct a decision tree for me. How to do it considering the frequency of each class?

I am a beginner in R. Thanks

$\endgroup$
1
  • $\begingroup$ Hi Sager, Welcome to Data science SO. If the answer that is posted for you works it is good to accept the answer! $\endgroup$
    – Stereo
    Commented Oct 23, 2016 at 15:31

1 Answer 1

1
$\begingroup$

To use the column named Freq as your case weights, you can call rpart with the argument weights=Freq.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.