0

I am a beginner in R. I have one numeric variable and one factor with two levels. I made a table of them.

How do I know the mean value of the numeric for each level?

1 Answers1

0

Lets make a dataframe with name DF. x1 - numeric, x2 - factor

DF

   x1 x2
 1  1  a
 2  2  b
 3  3  a
 4  4  b
 5  5  a
 6  6  b

> requires(dplyr)
> DF <- DF%>%group_by(x2)%>%summarise(avg = mean(x1))
AntonCH
  • 272
  • 2
  • 3
  • 13