On Fri, 2009-04-24 at 13:12 -0700, sjaffe wrote:
> small example:
>
> a<-c(1.1, 2.1, 9.1)
> b<-cut(a,0:10)
> c<-data.frame(b,b)
> d<-table(c)
> dim(d)
> ##result: c(10, 10)
>
> But only 9 of the 100 cells are non-zero.
> If there were 10 columns, the table have 10 dimensions each of length 10, s
On Fri, Apr 24, 2009 at 3:12 PM, sjaffe wrote:
>
> small example:
>
> a<-c(1.1, 2.1, 9.1)
> b<-cut(a,0:10)
> c<-data.frame(b,b)
> d<-table(c)
> dim(d)
> ##result: c(10, 10)
>
> But only 9 of the 100 cells are non-zero.
> If there were 10 columns, the table have 10 dimensions each of length 10, so
I think the easiest way to deal with this problem is
to paste together the values, use table on those, and
then unpaste (strsplit) them back. Using the 10 columns
with 10 levels example:
set.seed(25)
x = as.data.frame(replicate(10,sample(1:10,12,replace=TRUE)))
res = apply(x,1,paste,collapse=':
small example:
a<-c(1.1, 2.1, 9.1)
b<-cut(a,0:10)
c<-data.frame(b,b)
d<-table(c)
dim(d)
##result: c(10, 10)
But only 9 of the 100 cells are non-zero.
If there were 10 columns, the table have 10 dimensions each of length 10, so
have 10^10 elements, too much even to fit in memory
Dieter Menne w
Dieter Menne wrote:
sjaffe riskspan.com> writes:
I have data with many factors, each taking many values. However, only
relatively few combinations appear in the data, ie have nonzero counts, in
other words the resulting table is sparse. Say we have 10 factors each with
10 levels. The result of
sjaffe riskspan.com> writes:
>
> I have data with many factors, each taking many values. However, only
> relatively few combinations appear in the data, ie have nonzero counts, in
> other words the resulting table is sparse. Say we have 10 factors each with
> 10 levels. The result of table() wou
Hi Steve,
The general answer is yes, but the specific will depend on your
problem. Could you provide a small reproducible example to illustrate
your problem?
Hadley
On Fri, Apr 24, 2009 at 1:19 PM, sjaffe wrote:
>
> Perhaps this is a common question but I haven't been able to find the answer.
7 matches
Mail list logo