Skip to content

table , exclude - count the frequency in a data frame but exclude one value

2 messages · John, William Dunlap

#
Hi,

   I have a data frame with two variables x, y, both of which take values
in the set {1,2,3}. I'd like to count the frequency by the command "table",
but exclude the value "1" in variable x, but keep "1" in variable y. Is it
possible?  When I use "exclude", value 1 in both x and y are excluded.
Thanks,
x
y   1 2 3
  1 0 0 1
  2 0 1 0
  3 1 0 0
x
y   2 3
  2 1 0
  3 0 0
x
y   2 3
  2 1 0
  3 0 0
x
y   2 3
  2 1 0
  3 0 0
x
y   2 3
  2 1 0
  3 0 0
Error in as.vector(exclude, typeof(x)) :
  (list) object cannot be coerced to type 'integer'
#
table converts its non-factor arguments to factors using the exclude
argument that you supply.  If you want the arguments to be handled
differently, then convert them to factors
yourself, in the way you want.  E.g.,
y
x   1 2 3
  2 0 1 0
  3 1 0 0
y
x   3 2 1
  2 0 1 0
  3 0 0 1



Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Apr 26, 2016 at 2:21 PM, jpm miao <miaojpm at gmail.com> wrote: