Displaying 20 results from an estimated 400 matches similar to: "odds ratios for n-way tables: seeking an *apply-able method"
2011 Feb 18
3
How to change dataframe to tables
The data is in the attachment.
What I wanna get is:
, , Sex = Male
Eye
Hair Brown Blue Hazel Green
Black 32 11 10 3
Brown 53 50 25 15
Red 10 10 7 7
Blond 3 30 5 8
, , Sex = Female
Eye
Hair Brown Blue Hazel Green
Black 36 9 5 2
Brown 66 34 29 14
Red 16 7 7 7
Blond 4
2006 Dec 06
2
vcd package, assoc()
Hello,
I am trying to use the extended assocplot() function: assoc(), from vcd
package. Trouble is that it cannot even run its own examples on my
installation. I get this output:
$> example(assoc)
assoc> data("HairEyeColor")
assoc> (x <- margin.table(HairEyeColor, c(1, 2)))
Eye
Hair Brown Blue Hazel Green
Black 68 20 15 5
Brown 119 84 54
2005 Nov 12
1
how to make automatically each level from data.frame to vector
Dear R-helpers,
Suppose I have dataset like this below:
data(HairEyeColor)
dfHEC <- as.data.frame(as.table(HairEyeColor))
my.dfHEC <- data.frame(Hair=rep(dfHEC$Hair,dfHEC$Freq),
Eye=rep(dfHEC$Eye,dfHEC$Freq),
Sex=rep(dfHEC$Sex,dfHEC$Freq))
my.dfHEC
my.dfHEC$Hair
my.dfHEC$Eye
my.dfHEC$Sex
and I know all levels for Hair, Eye and Sex.
In my case, I
2009 Dec 15
2
Diagonal Labels on "Beside" Bars in Barplot
My question is based on an example provided in the following:
Referencing:
Statistics with R
Vincent Zoonekynd
<zoonek at math.jussieu.fr>
6th January 2007
URL:
http://zoonek2.free.fr/UNIX/48_R/all.html
data(HairEyeColor)
a <- as.table( apply(HairEyeColor, c(1,2), sum) )
# Provided Example
barplot(a, beside = TRUE,
legend.text = attr(a, "dimnames")$Hair)
# I
2007 Jul 18
0
HSAURtable question
It appears that HSAURtable only works on two dimensional tables. Is this
correct?
For example, here is HairEyeColor:
, , Sex = Male
Eye
Hair Brown Blue Hazel Green
Black 32 11 10 3
Brown 38 50 25 15
Red 10 10 7 7
Blond 3 30 5 8
, , Sex = Female
Eye
Hair Brown Blue Hazel Green
Black 36 9 5 2
2003 Jun 13
0
mca & contingency tables - error: "All variables must be factors"
Hi,
I would like to do a multiple correspondence analysis with the mca function in
the MASS library on data that I have as a contingency table (which I've tried
converting to a data frame).
For example,
=========
> data(HairEyeColor)
> hair.df <- as.data.frame(HairEyeColor)
> hair.df
Hair Eye Sex Freq
1 Black Brown Male 32
2 Brown Brown Male 38
3 Red
2009 Aug 04
4
array slice notation?
Suppose I have an n-diml array A and I want to extract the first "row" -- ie
all elements A[1, ...]
Interactively if I know 'n' I can write A[1,,,,,] with (n-1) commas.
How do I do the same more generally, eg in a script?
(I can think of doing this by converting A to a vector then extracting the
approp elements then reshaping it to an array, but I wonder if there isn't a
2010 Oct 03
1
plyr: a*ply with functions that return matrices-- possible bug in aaply?
I have an application where I have a function to calculate results for
a 2-way table or matrix, which
returns a matrix with one less row and column. To keep this short, the
function below captures the structure:
fun2way <- function(f){
if (!length(dim(f)) ==2) stop("only for 2-way arrays")
R <- dim(f)[1]
C <- dim(f)[2]
f[1:(R-1), 1:(C-1)]
}
Now, I want to
2006 Dec 01
3
Make many barplot into one plot
Dear all,
## I have 4 tables like this:
satu <- array(c(5,15,20,68,29,54,84,119), dim=c(2,4),
dimnames=list(c("Negative", "Positive"), c("Black",
"Brown", "Red", "Blond")))
dua <- array(c(50,105,30,8,29,25,84,9), dim=c(2,4),
dimnames=list(c("Negative", "Positive"),
2010 Jun 06
1
I need help in analyzing
I'm sory for my weak english. I need to analyze this subject :
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 y
0 0 1 0 0 1 0 0 1 0 czarne
1 1 0 0 0 0 1 0 0 0 rude
0 0 1 0 0 1 1 0 0 0 braz
0 0 1 0 1 0 1 0 0 0 blond
1 0 0 0 0 1 0 0 0 1 rude
1 1 0 0 0 0 0 0 0 1 blond
0 0 1 1 0 0 0 0 1 0 czarne
1 0 0 1 0 0 1 0 0 0 blond
0 0 1 0 0 1 1 0 0 0 blond
1 0 0 0 0 1 1 0 0 0 czarne
0 0 1 0 0 1 0 0 0 1 czarne
1 0 1 0 0 0
2010 Oct 29
2
make many barplot into one plot
Dear R users
I would like to group my barplot graph (see example on the R help link). The proposed R code, adding individual bars to the plot, looks really overwhelming. My specific dataset just consists of five groups and three different levels within each groups (the individual bars). The .txt file is read as matrix (horizontal: group, vertical: levels).
The R trellis barchart (function
2013 May 09
0
Replace rows in dataframe based on values in other columns
Hi,
dat1<- read.table(text="
Restaurant owner purchase_date
??????????? 23 Chuck 3/4/2011
??????????? 23 Chuck 3/4/2011
??????????? 23 Chuck 3/4/2011
??????????? 23 Chuck 3/4/2011
??????????? 23 Bob??????? 1/1/2013
??????????? 23 Bob??????? 1/1/2013
??????????? 23 Bob???????? 1/1/2013
??????????? 15 Hazel 4/11/2010
??????????? 15 Hazel 4/11/2010
??????????? 15 Hazel 4/11/2010
???????????
2008 Apr 27
1
parallel max, min, and median of dataframe columns
Hello, all,
I have a dataframe of three rows and umpteen columns. I want to show the
maximum, minimum, and median with a vertical line and a central dot (I'd
use a boxplot, but with only three data points, that's overkill; I can't
just use points, because of overlap and some of the other data plotted on
the graph).
This works:
> boxplot(data_frame,
2004 Jan 02
1
bwplot and panel.bwplot
Hello,
I am trying to use "bwplot" to display whisker boxes according to some conditioning factors ("age" has two values 1/2). I get the following messages:
> library(trellis)
> bwplot(dvk95~age|site*season,panel=function(x,y){panel.bwplot(x,y)})
Error in tapply(1:0, structure(list(INDICES = numeric(0)), .Names = "INDICES"), :
arguments must have
2002 Jan 30
1
mosaicplot(formula, data)--- bugged?
I have been tinkering with mosaicplot() and friends as a way
of learning R. As part of this, I've written a pair.table()
method for mosaic matrices, and would like to extend mosaicplot
to work with loglin and logln (MASS) objects. I'm using
R 1.4.0 on Win 98.
I've been trying to figure out the formula interface, and think
there's a bug, but not sure how to find it, yet alone fix
2013 Aug 18
1
How does R_UnboundValue and removing variables work?
Reading "R Internals" made me believe that R_UnboundValue was a placeholder
that would be skipped over in variable lookup. viz. the section of R
Internals "Hash tables" says "items are not actually deleted but have their
value set to R_UnboundValue.", which seems to align with what I read in
envir.c.
So, I reasoned, if I have a function that returns R_UnboundValue,
2002 Feb 08
2
bugs or imperfect implementation?
I am using R to teach, and here are a couple of things that I thought
would work didn't work.
1. I noticed the utility data(***,package=***) recently and like it
very much, but unless I type in the whole word "package" I'll get an
error in 1.4.0. For example, data(cats,package=MASS) works fine but
data(cats,pac=MASS) doesn't.
2. drop1 doesn't seem to be as smart as
2008 Sep 26
2
adjusting textsize and spacing in mosaic (vcd package)
I'm trying to find a way to change the font size in a mosaic plot (the
grid version, not the base graphics one).
Here's an example to demonstrate:
#Basic plot
library(vcd)
mosaic(HairEyeColor, shade = TRUE)
#Bad first guess: this stops the default cell colouring, and doesn't
change the font size
mosaic(HairEyeColor, shade = TRUE, gp=gpar(fontsize=16))
#This successfully changes
2008 Nov 16
3
chisq.test with simulate.p.value=TRUE (PR#13292)
Full_Name: Reginaldo Constantino
Version: 2.8.0
OS: Ubuntu Hardy (32 bit, kernel 2.6.24)
Submission from: (NULL) (189.61.88.2)
For many tables, chisq.test with simulate.p.value=TRUE gives a p value that is
obviously incorrect and inversely proportional to the number of replicates:
> data(HairEyeColor)
> x <- margin.table(HairEyeColor, c(1, 2))
>
2002 Sep 13
1
[R] proposal: mosaicplot with sub and las
Two proposals for mosaicplot():
- The argument "sub" should not be ignored.
Example: mosaicplot( HairEyeColor, sub = 'test of sub' )
- To be able to discern also longer axis labels
the argument "las" or par(las=2) should not be ignored.
Example: mosaicplot( HairEyeColor, las=2 )
Thanks
Wolfram