-----Original Message-----
From: smartpink111 at yahoo.com
Sent: Tue, 21 May 2013 18:57:56 -0700 (PDT)
To: r-help at r-project.org
Subject: Re: [R] Something Very Easy
HI,
I am not sure about what you expect as output.
dat1<- read.table(text="
Offense Play
Y??????? A
N??????? B
Y??????? A
Y??????? C
N??????? B
N??????? C
",sep="",header=TRUE,stringsAsFactors=FALSE)
?with(dat1,tapply(Play,list(Offense),table))
#$N
#
#B C
#2 1
#
#$Y
#
#A C
#2 1
#or
with(dat1,tapply(factor(Play),list(Offense),table))
#$N
#
#A B C
#0 2 1
#
#$Y
#
#A B C
#2 0 1
A.K.
I have lines of data that look like this:
Offense Play
Y A
N B
Y A
Y C
N B
N C >
with a bunch of other variables.
I just want to get a table like
table(Play[Offense=="Y"])?>but one that would return, for the data
A 2
C 1
Instead of what I get now, from
table(Play[Offense=="Y"]): >
A 2
B 2
C 2