user1828605
user1828605

Reputation: 1735

How to create boxplot of logical and numerical value in r?

I have a trivial question that I can't seem to figure out. I have a data matrix of dimension 20000 X 1. I have another logical variable called logVal of the length 20000. The logical value pertains to whether the matrix elements falls below certain value or not. If it does, the logVal is TRUE, or else it's FALSE. I want to make a boxplot to whether the logVal behaves differently for the matrix. But i can't seem to figure out how to do this. Can somebody please help?

Thanks in advance

Upvotes: 0

Views: 923

Answers (1)

Paulo E. Cardoso
Paulo E. Cardoso

Reputation: 5856

something like this?

df <- data.frame(v <- runif(20000, 0, 1))
df$g <- ifelse(df$v < 0.5, T, F)
with(df, boxplot(v~g))

boxplot

Upvotes: 1

Related Questions