How to do median splits within factor levels in R?

前端 未结 3 1752
有刺的猬
有刺的猬 2021-02-14 16:05

Here I make a new column to indicate whether myData is above or below its median

### MedianSplits based on Whole Data
#create some test data
myDataFrame=data.fra         


        
3条回答
  •  旧时难觅i
    2021-02-14 16:47

    You weren't looking for something like this, were you?

    Course$grade2 <- ifelse(Course$grade >= median(Course$grade), 1, 0)
    

提交回复
热议问题