[R] A whine and a request

John Vokey vokey at uleth.ca
Wed Jun 14 08:53:58 CEST 2006


guRus and useRs,

As I instruct my students: "With R what is difficult in anything  
else, is easy, usually one line of code; but, what is easy in  
anything else, is *&^%$%#$... (translation: next to impossible) in R."

I just ran into such a case that has, to put it mildly, driven me to  
use spreadsheets (if that is not a sign of complete desperation, I  
don't know what is).  It has nothing to do with particular versions  
of R or what OS I am using, but something more fundamental.  Here it  
is.  First, I have a very large data-set (the size, though, is not  
the issue) that at base has a single binary response (score 0/1) for  
each line of the data.  Different, large blocks of the data  
correspond to the responses of single participants to stimuli  
differing in feature x, where the distribution of particular  
differences in feature x is different for each participant. Table  
(and ftable) commands are great for reducing these data to isolate  
the Freqs with which particular x values occur within each  
participant, which is what I want, including how the frequency with  
which the participant responded 1 (or 0) to that level of feature x.   
So, assiduous use of table() gives me more or less what I want:  
within participant, the values of x, the associated frequencies of 0  
responses to those values of x, and the associated frequencies of 1  
responses to those values of x.  Now, what I WANT is the simple  
regression of the proportion of 1 responses (out of the sum of 0 and  
1 responses) to each value of x on the values of x.  What table()  
gives me is close, but useless, as I can't access the columns.  But,  
applying data.frame() to the results from table, gives me access to  
the columns as variables, but returns the (re)expanded data, which  
does not allow me to compute the simple proportions I want.  After  
too many hours of trying way too many desperate commands, I gave up.   
I printed the table(), copied it to the clipboard, pasted it into a  
spreadsheet, computed the proportions, fixed the header, saved it as  
a text file, and the read it back into R to do the regressions.   
There has got to be an easier way.
--
Please avoid sending me Word or PowerPoint attachments.
See <http://www.gnu.org/philosophy/no-word-attachments.html>

-Dr. John R. Vokey



More information about the R-help mailing list