On 09/21/2010 05:02 AM, Gregory Ryslik wrote:
> Hi,
>
> I think I've found away around that issue. The following works. If
this method is inefficient and one has something faster, I'll appreciate
it though!
>
> lapply(mylist, function(x) as.numeric(as.character(x)))
You could avoid making them f
Hi,
I think I've found away around that issue. The following works. If this method
is inefficient and one has something faster, I'll appreciate it though!
lapply(mylist, function(x) as.numeric(as.character(x)))
Cheers,
Greg
On Sep 20, 2010, at 10:48 PM, David Winsemius wrote:
>
> On Sep 20,
On Sep 20, 2010, at 10:28 PM, David Winsemius wrote:
On Sep 20, 2010, at 10:12 PM, Gregory Ryslik wrote:
Hi,
I have a list of 5 main elements where each main element has 247
atomic entries either 0 or 1. I need to get this into a 247x5
matrix so I do "do.call(cbind, mylist)". However,
Hi Gregory,
May be this?
# some data
set.seed(123)
x <- factor(sample(0:1, 20, TRUE))
x
# [1] 0 1 0 1 1 0 1 1 1 0 1 0 1 1 0 1 0 0 0 1
# Levels: 0 1
as.numeric(as.factor(x))
# [1] 1 2 1 2 2 1 2 2 2 1 2 1 2 2 1 2 1 1 1 2
as.numeric(as.character(x))
[1] 0 1 0 1 1 0 1 1 1 0 1 0 1 1 0 1 0 0 0 1
HT
Hm,
Now that you mention it, I believe they are factors. They just appeared as 0 or
1 so I treated them as numbers.
Once I found out they were factors I tried using the as.numeric() but that
makes it 1 or 2 as before. How do I actually make it keep the factor number?
Thanks,
Greg
On Sep 20, 2
On Sep 20, 2010, at 10:12 PM, Gregory Ryslik wrote:
Hi,
I have a list of 5 main elements where each main element has 247
atomic entries either 0 or 1. I need to get this into a 247x5 matrix
so I do "do.call(cbind, mylist)". However, it renumbers 0 to a 1
and the 1 to a 2 so that my matr
Hi,
I have a list of 5 main elements where each main element has 247 atomic entries
either 0 or 1. I need to get this into a 247x5 matrix so I do "do.call(cbind,
mylist)". However, it renumbers 0 to a 1 and the 1 to a 2 so that my matrix is
filled with 1's and 2's.
I understand I can fix it
7 matches
Mail list logo