0

Newbie r question..

I'm looking to generate a frequency count of the number of occurrences of "?" within my data set.

Should look something like this:

encounter_id 0
patient_nbr 0
race 2273
gender 0
weight 98569

I used the following to get a count for the column "weight" but would like a more stream-lined approach to counting all "?" for all columns.. I don't want to have to retype the below function for EACH column..

table(dataset$weight[dataset$weight=="?"])

Any help is appreciated.

gvo369
  • 1
  • 3

1 Answers1

0

Try this code.

dataset$weight_questmark <- ifelse(dataset$weight == "?", 1, 0)
sum(dataset$weight_questmark)
Wooheon
  • 339
  • 1
  • 9