0
$\begingroup$

I'm performing a t-test for some simple data. The data I imported (plant.growth) had column one (pesticide) has whether the plant received pesticide A or B and column two had the amount grown in inches (height).

When I run the t test, t.test(height~treatment), my t-value and my confidence intervals are negative. I would prefer them to be positive but I don't know how to get the binary data to flip (ie have the sample mean of A be subtracted from the sample mean of B. I'm still really new to R, and I can't seem to find a simple way to do this.

Thank you for your help!

$\endgroup$

1 Answer 1

0
$\begingroup$
treatment <- relevel(treatment, ref = "B")
t.test(height ~ treatment)

Or alternatively

treatment <- factor(treatment, levels=c("B","A"))

would also have worked.

$\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.