[R] Frequencies from a matrix - spider from frequencies

Uwe Dippel udippel at uniten.edu.my
Mon Mar 15 16:26:31 CET 2010


Dennis Murphy wrote:
>
> The first part is straightforward. You didn't supply example data,
> but it's easy to generate it oneself:
>
> likmat <- matrix(sample(1:5, 310, replace = TRUE), nrow = 31)
> dim(likmat)
> # [1] 31 10
> frq <- t(apply(likmat, 2, table))   # 10 x 5 matrix, questions in rows

Yours works, mine doesn't. As I wrote, newbie.
The difference here is the naming of rows and columns. Your matrix looks 
like
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    2    3    3    4    5    2    1    2    2     2
 [2,]    2    1    3    1    3    2    1    5    2     4
while mine goes like this:
   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
1   1  2  3  4  5  6  7  8  9  10
2   4  4  4  3  4  3  4  4  3   4
and then the 'apply' gets me some
 > apply(m_learn, 2, table)
$V1
 1  3  4  5
 3  5 12  9
$V2
respectively
t(apply(m_learn, 2, table))
     V1        V2        V3        V4        V5        V6        V7      
[1,] Integer,4 Integer,5 Integer,4 Integer,5 Integer,5 Integer,5 Integer,6
     V8        V9        V10     
[1,] Integer,6 Integer,5 Integer,5
, while your matrix results exactly in what I was looking for.

I have attached the data as file, hoping for it to go through.

>
>
>
> The stars() function allows one to generate spider/radar plots as you
> requested. Since there are several forms that it can take, I suggest
> you run the example:
>
> example(stars)
>
> and mimic the one(s) you want.

Neither was what I had hoped for. (I attach the sample, hoping for it to 
go through. It is made with gnumeric.)

Thanks very much anyway, I really appreciate your help!

Uwe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: BA_M_learning_statements.png
Type: image/png
Size: 130508 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100315/9ded5a64/attachment.png>


More information about the R-help mailing list