-3

I'm trying to subset my data based on a condition but I'm getting the following error

m <- matrix(995:1005, ncol = 1) # create matrix
colnames(m) <- c("Total") # Assign col name

colnames(m)
a <- subset(m,Total>1000)

> colnames(m)
[1] "Total"
> a <- subset(m,Total>1000)
Error in subset.matrix(m, Total>1000) : object 'Total' not found

Am I overlooking something here? Thanks

Learner
  • 206
  • 5
  • 18

1 Answers1

1

You can use subset like:

m[subset(m, select = "Total") > 1000, ]
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213