[R] question on simple graph

Christopher W. Ryan cryan at binghamton.edu
Wed Feb 1 02:37:59 CET 2012


Without knowing more about what you are trying to accomplish, and what 
you have tried so far (code) it's difficult to say. But I'll venture 
this: are you sure you need a graph? Seems like a table might suffice.

BT <- sample(1:5, 50, replace=TRUE)
RA <- sample(1:5, 50, replace=TRUE)
table(BT)
table(RA)
dd <- data.frame(better <- BT, race=RA)
str(dd)
dd.table <- xtabs(~better+race, data=dd)

# doesn't this table convey what you want?
prop.table(dd.table,2)

# if for some reason a graph is essential, this creates one:
mosaicplot(dd.table)

Is this sort of what you had in mind?

--Chris Ryan
SUNY Upstate Medical University
Clinical Campus at Binghamton

Rebecca Lisi wrote:
> I am having trouble generating a graph.
>
> I want to know the % of respondents who answered that they "strongly
> agree" or "agree" the "America owes R's ethnic group a better chance"
> (BTTRCHNC) and I want to organize it by racial group (RACESHRT).
>
> "BTTRCHNC" is organized ordinally from 1 through 5 with 1=Strongly
> Agree, 5=Strongly Disagree
> "RACESHRT" is ordinally organized from 1 through 5 where each number
> represents a racial group category, i.e. white, black, Asian, etc.
>
> Any hints for how to proceed?
>
>
> The information contained in this e-mail is confidential...{{dropped:9}}
>
> ______________________________________________
> 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.



More information about the R-help mailing list