Thank you very much, everyone! Extremely helpful!
I really liked these two solutions:
# reshape is really cool + it gives me the value I need!
library(reshape2)
solution1-subset(melt(x, id = c('y', 'z')), value 0)
# This one is also very good, just need one additional loop - to
include
Hello!
I've tried for a while - but can't figure it out. I have data frame x:
y=c(a,b,c,d,e)
z=c(m,n,o,p,r)
a=c(0,0,1,0,0)
b=c(2,0,0,0,0)
c=c(0,0,0,4,0)
x-data.frame(y,z,a,b,c,stringsAsFactors=F)
str(x)
Some of the values in columns a,b, and c are 0:
I need to write a loop through all the cells
On May 21, 2011, at 9:12 AM, Dimitri Liakhovitski wrote:
Hello!
I've tried for a while - but can't figure it out. I have data frame x:
y=c(a,b,c,d,e)
z=c(m,n,o,p,r)
a=c(0,0,1,0,0)
b=c(2,0,0,0,0)
c=c(0,0,0,4,0)
x-data.frame(y,z,a,b,c,stringsAsFactors=F)
str(x)
Some of the values in columns
Dmitri:
1. I did not read your whole missive. I prefer mystery novels. ;-)
2. I suggest you banish Excel language (cells) from your vocabulary
and think in R's terms of whole objects that one indexes into.
3. If I understand correctly, you can't combine results into a data
frame, because they
Dimitri Liakhovitski-2 wrote:
Hello!
I've tried for a while - but can't figure it out. I have data frame x:
y=c(a,b,c,d,e)
z=c(m,n,o,p,r)
a=c(0,0,1,0,0)
b=c(2,0,0,0,0)
c=c(0,0,0,4,0)
x-data.frame(y,z,a,b,c,stringsAsFactors=F)
str(x)
Some of the values in columns a,b, and c are 0:
Hi:
Does this work for the first problem?
library(reshape2)
subset(melt(x, id = c('y', 'z')), value 0)
y z variable value
3 c oa 1
6 a mb 2
14 d pc 4
The second problem is so convoluted I don't even know where to start...
HTH,
Dennis
On Sat, May 21,
6 matches
Mail list logo