On Sep 23, 2011, at 8:43 AM, Metronome123 wrote:
Thanks, I will read the posting guide.
Please do it NOW. Before any further postings.
Q1: thanks for helping me out!
Q2: What I mean is that given the dataset:
subject1,class1_yes, class2_no, class3_yes, class4_no
subject2, class1_no, class2_no, class3_no, class4_yes
subject3, class1_yes, class2_no, class3_yes, class4_no
I want to count for each unique class combination the number of
subjects that share this whole combination.
In this case the result should be:
2 counts for the combination class1_yes, class2_no, class3_yes,
class4_no
1 count for the combination class1_no, class2_no, class3_yes,
class4_yes
Perhaps:
with( datfrm, table( interaction( <names of columns> ) ) )
Had you read the Posting Guide you would have found that you are
requested to post a working example and you are also given instruction
how a proper working example can be created from your own data. The
Posting Guide uses 'dump' but I usually use 'dput'. Then we would not
have needed to post guesswork and pseudo-code.
--
david.
Regards,
Lars
Op 23 sep. 2011 (w38), om 14:12 heeft Petr Pikal [via R] het
volgende geschreven:
[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.
______________________________________________
[hidden email] 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.
______________________________________________
[hidden email] 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.
If you reply to this email, your message will be added to the
discussion below:
http://r.789695.n4.nabble.com/Newbie-question-Converting-Table-tp3836468p3836611.html
To unsubscribe from Newbie question: Converting Table, click here.
--
View this message in context:
http://r.789695.n4.nabble.com/Newbie-question-Converting-Table-tp3836468p3836711.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]
______________________________________________
R-help@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.
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@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.