[R] contingency tables

mari681 marianna.bolognesi at gmail.com
Fri Mar 16 14:46:52 CET 2012

Ok, before I definetly give up, and throw the laptop out of the window, or
fill my data.frame manually, I'll ask for some help.
I have a data.frame named MyTable with 3 columns, that looks like this:

     V1              V2                       V3
red-j    appearanceblood-n 105.032
red-j   appearanceground-n  93.749
red-j      appearancesea-n 102.167
red-j      appearancesky-n   10.898
orange-j	appearanceobject-n	109.354
orange-j	as_adj_aspainting-n	93.248
orange-j	colorbanknote-n	159.167
orange-j	colorcar-n	117.985
yellow-j	appearanceskin-n	109.527
yellow-j	areacircle-n	87.064
yellow-j	areainfarction-n	120.759
yellow-j	as_adj_ascorn-n	219.739
yellow-j	as_adj_asflax-n	122.576
yellow-j	as_adj_asgold-n	90.814
green-j	appearancewater-n	91.477
green-j	architecturebuilding-n	103.582
green-j	architecturecourse-n	103.325
green-j	areaRio-n	106.614
green-j	areaauditorium-n	102.505
green-j	areacity-n	150.005
blue-j	appearancecypress-n	145.133
blue-j	appearancefirmament-n	148.655
blue-j	appearanceman-n	85.731
blue-j	appearancerange-n	90.706
blue-j	appearancesurface-n	100.991
blue-j	areagraph-n	92.708
blue-j	arealibrary-n	77.135
purple-j	appearanceleave-n	119.423
purple-j	appearancelesion-n	134.287
purple-j	colorViking-n	145.516
purple-j	coloramethyst-n	175.619
purple-j	colorbanknote-n	158.045
purple-j	colorbottle-n	132.395
purple-j	colorchocolate-n	141.833

The elements on the first column can be: red-j, orange-j, yellow-j, green-j,
blue-j or purple-j. Elements on column 2 are contexts in which the color
appears. And in column 3 there is a kind of frequency measurement between
color and context.

I am trying to build a new data.frame where the 6 colors in column 1 are
placed as column names, all the unique contexts in column 2 are placed as
row names and the values on column 3 are in the correspondent cells (or 0 if
an intersection color-context is empty).
Easy to prepare the empty data.frame, but I cant find out how to fill it up
with the frequencies.
Ideas? Anybody has a ready script for this?

Thank you!!!


View this message in context: http://r.789695.n4.nabble.com/contingency-tables-tp4478204p4478204.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list