Re: [R] , Updating Table

2010-07-24 Thread Duncan Murdoch

On 24/07/2010 11:25 AM, Charles C. Berry wrote:

On Fri, 23 Jul 2010, Marcus Liu wrote:


Hi everyone,

Is there any command for updating table withing a loop?�


"Loops? We don't need no stinking loops!"
 (From 'The Good, the Bad, and the Rgly')


Actually, that quote comes from the TreasR of the SieRa MadRe.

Duncan Murdoch


tab <- table(data.raw, findInterval(seq(along=data.raw), ind+1 ) )
tab %*% upper.tri(tab,diag=T)

or

tab2 <- tapply( factor(data.raw), findInterval(seq(along=data.raw), ind+1 ), 
table)
Reduce( "+", tab2, accum=TRUE )

HTH,

Chuck

p.s. See the posting guide re including a reproducible example with 
requests like yours.


For instance, at i, I have a table as ZZ = table(data.raw[1:ind[i]]) 
where "ind" = c(10, 20, 30, ...).�Then , ZZ will be as follow


"A" "B" "C"
�3��� 10�� 2

At (i + 1), ZZ = table(data.raw[(ind[i]+1):ind[i+1]])

"A" "B" "D"
�4 �� 7��� 8

Is there any command that can update the table ZZ for each time so that in the 
above example, ZZ will be

"A" "B" "C" "D"
�7��� 17�� 2��� 8

Thanks.

liu




[[alternative HTML version deleted]]




Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901





__
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.


__
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.


Re: [R] , Updating Table

2010-07-24 Thread Charles C. Berry

On Fri, 23 Jul 2010, Marcus Liu wrote:


Hi everyone,

Is there any command for updating table withing a loop??


"Loops? We don't need no stinking loops!"
 (From 'The Good, the Bad, and the Rgly')

tab <- table(data.raw, findInterval(seq(along=data.raw), ind+1 ) )
tab %*% upper.tri(tab,diag=T)

or

tab2 <- tapply( factor(data.raw), findInterval(seq(along=data.raw), ind+1 ), 
table)
Reduce( "+", tab2, accum=TRUE )

HTH,

Chuck

p.s. See the posting guide re including a reproducible example with 
requests like yours.


For instance, at i, I have a table as ZZ = table(data.raw[1:ind[i]]) 
where "ind" = c(10, 20, 30, ...).?Then , ZZ will be as follow


"A" "B" "C"
?3??? 10?? 2

At (i + 1), ZZ = table(data.raw[(ind[i]+1):ind[i+1]])

"A" "B" "D"
?4 ?? 7??? 8

Is there any command that can update the table ZZ for each time so that in the 
above example, ZZ will be

"A" "B" "C" "D"
?7??? 17?? 2??? 8

Thanks.

liu




[[alternative HTML version deleted]]




Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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.


Re: [R] , Updating Table

2010-07-24 Thread Linlin Yan
If I am not wrong, it seems that you want to get factor counts in the
whole scale of data.raw. Maybe you can do that just like this:
table(data.raw)

On Sat, Jul 24, 2010 at 1:44 AM, Marcus Liu  wrote:
> Hi everyone,
>
> Is there any command for updating table withing a loop?  For instance, at i, 
> I have a table as ZZ = table(data.raw[1:ind[i]]) where "ind" = c(10, 20, 30, 
> ...).  Then , ZZ will be as follow
>
> "A" "B" "C"
>  3    10   2
>
> At (i + 1), ZZ = table(data.raw[(ind[i]+1):ind[i+1]])
>
> "A" "B" "D"
>  4    7    8
>
> Is there any command that can update the table ZZ for each time so that in 
> the above example, ZZ will be
>
> "A" "B" "C" "D"
>  7    17   2    8
>
> Thanks.
>
> liu
>
>
>
>
>        [[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.
>
>

__
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.


[R] , Updating Table

2010-07-23 Thread Marcus Liu
Hi everyone,

Is there any command for updating table withing a loop?  For instance, at i, I 
have a table as ZZ = table(data.raw[1:ind[i]]) where "ind" = c(10, 20, 30, 
...).  Then , ZZ will be as follow

"A" "B" "C"
 3    10   2

At (i + 1), ZZ = table(data.raw[(ind[i]+1):ind[i+1]])

"A" "B" "D"
 4    7    8

Is there any command that can update the table ZZ for each time so that in the 
above example, ZZ will be

"A" "B" "C" "D"
 7    17   2    8

Thanks.

liu



  
[[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.