Is this what you want:
> x <- data.frame(n=sample(10, n, TRUE), text=sample(LETTERS, n, TRUE))
> table(x$text, x$n)
1 2 3 4 5 6 7 8 9 10
A 6 5 2 0 8 1 5 3 6 4
B 2 2 5 2 2 7 5 4 4 5
C 7 4 6 4 3 6 3 6 5 4
D 9 5 1 6 3 1 3 2 6 3
E 2 6 4 3 3 5 2 7 6 3
F 6 5 3 5 3 5 1 2 2 10
G 4 4 2 5 5 3 2 7 3 3
H 4 4 4 5 3 3 3 6 3 4
I 9 3 6 1 4 4 3 4 3 4
J 4 7 3 4 3 3 4 1 2 5
K 2 5 5 3 3 6 9 6 5 3
L 3 3 5 4 3 3 3 3 5 5
M 3 9 2 3 2 0 2 3 5 6
N 4 1 0 5 8 4 4 3 6 2
O 3 4 3 4 8 4 2 5 5 4
P 3 6 2 6 4 4 3 4 3 6
Q 5 2 2 5 3 3 0 2 5 4
R 1 5 6 4 5 4 2 2 4 4
S 6 2 4 2 1 7 0 1 1 2
T 4 3 1 7 2 3 4 1 8 1
U 4 5 11 8 3 2 5 3 4 5
V 6 3 1 1 1 0 2 5 5 3
W 3 5 1 4 4 5 6 3 4 2
X 5 4 3 5 5 6 3 3 3 6
Y 6 6 6 3 2 1 3 4 4 1
Z 3 6 1 5 6 1 8 1 3 4>
On Fri, May 8, 2009 at 4:48 AM, Erika Ahl <erika.ahl@gmail.com> wrote:
> Hi all,
>
> I have a relative large amount (several thousand rows, but a small
> amount of unique objects) of data in a format like this:
>
> 1 text_string
> 1 text_string
> 1 text_string
> 2 text_string
> 2 text_string
> 3 text_string
> 3 text_string
> 3 text_string
> 3 text_string
> 3 text_string
> .
> .
> .
> n text_string
>
> I want to create an n x p matrix, n objects (=40) and p unique text
> strings. Nij is number of occurrences of a text string j in object i.
>
>
> What is the most efficient way of creating this matrix?
>
> Best regards,
>
> Erika Ahl
>
> ______________________________________________
> 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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
[[alternative HTML version deleted]]