[R] Filling In Grid based on 0 and 1

Rui Barradas ruipbarradas at sapo.pt
Thu Jun 28 11:06:20 CEST 2012


Hello,

This seems simple:

# 100 Bernoulli trials
x <- sample(c(0,1), 100, replace = TRUE)
image(1:10, 1:10, matrix(x, 10), col=0:1)

Hope this helps,

Rui Barradas

Em 27-06-2012 17:06, vp726 escreveu:
> Hi,
> I'm wondering if I can do this in R.  I have a data set with questions
> (x-value) and respondents (y-value).  If the respondent answered the
> question they get a 1 and if the respondent didn't answer the question they
> have a 0.  Is there anyway where I can graph something similar to a grid
> where if a person answered a questions (value of 1) a cell gets shaded and
> if a person didn't answer (value 0) the cell doesn't get shaded.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Filling-In-Grid-based-on-0-and-1-tp4634650.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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