VanyaS
VanyaS

Reputation: 33

Reading True or False Values in a matrix

I am Completely new to R, and it is being used in my Stats class. We aren't given a book on it either so it is something I am expected to just figure out by looking up.

I am trying to read how many true values are stored in the first column in an 10000 x 2 matrix. for example I run something like:

result[,1]=="G" #Here I want to return a number that tells me how many True value there are

What command should I use to accomplish this?

Upvotes: 0

Views: 73

Answers (1)

Jilber Urbina
Jilber Urbina

Reputation: 61154

Just sum all the TRUE values

sum(result[,1]=="G")

this will tell you how many G's there are in the first column of result

Upvotes: 4

Related Questions