0

I've always wondered if there's a command in R that gives you the entire domain of values within a variable.

For example, let's say I have the following data.table:

dt
Household Number_of_children
1         0
2         3
3         3

Is there a command along the lines of summary() or str() that would return the list 0, 3?

I believe summary and str only do that when your variable is a character string. I don't know how to do this when your variable is an integer, numeric, etc.

alistaire
  • 42,459
  • 4
  • 77
  • 117
Arturo Sbr
  • 5,567
  • 4
  • 38
  • 76

1 Answers1

3

You can use unique() function, with column/vector as input.

unique(dt[,'Number_of_children'])