Thank you very much for response. Finally I took David's way. Others' work
well for this specific case. But I find problem is there are more than one
column of character variables.
z=c('ab','ah','bc','ah','dv')
x=substr(z,start=1,stop=1)
y=substr(z,start=2,stop=2)
v1=5:9
v2=7:11
data=data.frame(x,
require(reshape)
cast(data, first+second~ ., sum)
Nikhil Kaza
Asst. Professor,
City and Regional Planning
University of North Carolina
nikhil.l...@gmail.com
On Jun 29, 2010, at 3:05 PM, Yi wrote:
first=c('u','b','e','k','j','c','u','f','c','e')
second
=
c
('usa
','Brazil
','England','Korea',
On Jun 29, 2010, at 3:05 PM, Yi wrote:
Hi, folks,
I am sorry that I did not state the problem correctly yesterday.
Please let me address the problem by the following codes:
first=c('u','b','e','k','j','c','u','f','c','e')
second
=
c
('usa
','Brazil
','England','Korea','Japan','China','usa','
Hi:
If you can deal with alphabetic order, the following seems to work:
v <- aggregate(third ~ first, data = data, FUN = sum)
v$second <- levels(data$second)
v[, c(1, 3, 2)]
first second third
1 b Brazil 2
2 c China15
3 e England13
4 f France 8
5 j Jap
4 matches
Mail list logo