0
votes

I have two dataframes I have run t-tests on. Call the first one DfA and the second DfB. Head of DfA:

    ID           SCD        OCP         PDP        GCD          bin2
1 104             1          1           3          1            323
2 103             3          1           1          1            314
3 101             3          1           1          1            219
4 121             3          1           1          1            242
5 108             3          1           1          1            212
6 110             3          1           2          1            269

head of DfB:

    ID            SCD        OCP         PDP       GCD           bin2
1   39             1          1           1          1            289
2   41             1          1           1          1            314
3   42             1          1           1          1            225
4  144             1          1           1          1            292
5  146             1          1           1          1            295
6  148             1          1           1          1            315

The bin2 column is what I am trying to make a boxplot of. I tried this function after merging the two together by ID

DfAandDfB <- merge(DfA, DfB, by=c('ID'))
boxplot(t.test(DfAandDfB$bin2), data=data.frame, xlab='DfA_bin2', ylab='DfB_bin2')

This gave me the error: Error in x[floor(d)] + x[ceiling(d)] : non-numeric argument to binary operator even after I converted everything to numeric (bin2 was already numeric though)

I also tried doing the boxplot separately:

boxplot(t.test(dfA$bin2, DfB$bin2), data=data.fram, xlab='DfA_bin2', ylab='DfB_bin2')

Still getting the same error. Can I not make a boxplot from just the t-test value and instead only do it on the raw data? I'm thinking that is the issue and I just read the function arguments incorrectly. Anyone know?

1
t.test returns an object of class "list", you cannot make a boxplot (nor any other base R plot) of it. What are you trying to plot? Related Meta. - Rui Barradas
Yeah I fixed it. I read some instructions incorrectly I think. I plotted the bin2 column data easily by simply taking out the t.test() function. I don't know why that confused me so much. - AcidCatfish

1 Answers

0
votes

I think I found the answer:

DfAandDfB <- merge(DfA, DfB, by=c('ID'))
boxplot(DfAandDfB$bin2, data=data.frame, xlab='DfA and DfB groups', ylab='Average Bin2')

running a t-test in the boxplot function doesn't work.