[R] help with table

From: Hugh Kingston <hwfkingston_at_googlemail.com>
Date: Thu, 22 May 2008 22:26:01 +0200


Dear All,

I would be most grateful for help on this problem.

I have a binary response variable. It is classified by various factors. I would like to have a table with;

column 1
frequency response is 1 / (frequency the response is 1 + frequency the response is 0) #given the classifying factors are the same

column 2...(n-1)
states of classifying factors

column 3
(frequency the response is 1 + frequency the response is 0)

I want to do this to reduce the size of my table so i can use it for logistic regression without running out of memory.

some example data to illustrate the problem; response <- c(0,1,0,1,0,0,0,1)
predictor.a <- c(10,10,20,20,50,50,50,50) predictor.b <- c(2,2,3,3,5,5,5,5)
frame <- data.frame(r = response, p.a = predictor.a, p.b = predictor.b)

> frame

  r p.a p.b
1 0 10 2
2 1 10 2
3 0 20 3
4 1 20 3
5 0 50 5
6 1 50 5

desired result........

f       p.a  p.b  freq
0.5     10    2     2
0.5     20    3     2

0.25 50 5 4

many thanks,

Hugh

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 22 May 2008 - 20:35:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 23 May 2008 - 02:30:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive