>
> [R] Newbie question: Converting Table
>
> Hi,
>
> I'm new to R, and I have searched helpfiles and this forum on my 2
> questions. Hope you guys can help me out! :-)
You did not search enough. You probably want table or xtabs
Q1
untested
res <- xtabs(~subject+class, data=your.file)
ifelse(res==1, "yes", "no")
Q2
I do not understand what exactly do you want. Please be more specific.
BTW, if you are in it you'd rather give a look to posting guide.
Regards
Petr
>
> Many thanks in advance!
>
> Cheers,
>
>
> Lars
>
> Q1: I imported a csv file with columnames subject and class. There are
about> 1000 different classes...
> It looks like this:
> subject1, class1
> subject1, class2
> subject2, class1
> subject2, class3
> ...
> subject999, class1
> subject999, class2
>
> Now I want to transform this in R into a table (with columnnames
> subject,class1,class2,...) like:
> subject1, yes, yes, no, ...
> subject2, yes, no, yes, ...
> ...
>
> Q2: I want to count the matching class patterns in the previous table
> (output: in a table with columns count, class1, ...). In this example
for> only the subjects1,2 and 999 it looks like this:
> 2,yes,yes,no,..
> 1,yes,no,yes
> ...
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Newbie-
> question-Converting-Table-tp3836468p3836468.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.