Given the data.frame below, I would like to return the frequency of obs based on condition session and leaving the other conditions (cond 1, cond 2, cond 3) intact
> session obs cond1 cond2 cond3
1 A close 30 0
1 A open 30 0
1 A close 30 0
1 B close 30 10
1 C close 27 2
2 A close 30 1
2 A close 30 6
2 A close 30 6
2 A close 30 6
2 B close 30 2
The data table has 4921 lines.
Cond1 and cond 3 are character
class; cond 2 is integer
By doing trial<-count(data, data$'obs', data$'cond1', mdata$ession)
I can see how many obs per session in cond 1, for example.
But I need the following output to compare the frequencies of the observation in each condition:
session obs freq obs cond1 cond2 cond3
1 A 0.4 close 30 0
1 A 0.2 open 30 0
1 B 0.2 close 30 10
1 C 0.2 close 27 2
2 A 0.6 close 30 6
2 B 0.2 close 30 2
2 A 0.2 close 30 1
Being a noob in R, I tried using
ddply(data,c("session","obs","cond1", "cond2", "cond3"),summarize,freq=sum(obs/session))
but this is clearly a oversimplification and the other examples of similar questions I found here, also did not solve my problem.
Any ideas? Many thanks!!