Nanmdi,
I think this is simply because a lot of time is taken transforming the
matrix from logical (default when you create it) to numeric (when you
add the number to [1,1]. If you do the same thing again to [1,2], it
is done instantaneously:
> a <- matrix(nrow=1,ncol=1)
> system.time(a[1,
Still it is pretty slow when entering values into a large matrix. Case in
point:
> a <- matrix(nrow=1,ncol=1)
> system.time(a[1,1] <- 1903908.80385)
user system elapsed
30.840 6.226 41.416
> is.matrix(a)
[1] TRUE
Is there a better way to enter values into large matrices? If I hav
On Wed, Apr 16, 2008 at 03:56:26PM -0600, Matthew Keller wrote:
> Yes Chuck, you're right.
>
just a comment:
> Thanks for the help. It was a data.frame not a matrix (I had called
> as.matrix() in my script much earlier but that line of code didn't run
> because I misnamed the object!). My bad. T
Rolf Turner wrote:
> On 17/04/2008, at 9:33 AM, Charles C. Berry wrote:
>
>
>
>>I'll lay odds that Matthew's 'matrix' is actually a data.frame, and
>>I'll not be surprised if the columns are factors.
>
>
>
>
> I suspect that you're right.
>
> ***Why*** can't people distinguish
Yes Chuck, you're right.
Thanks for the help. It was a data.frame not a matrix (I had called
as.matrix() in my script much earlier but that line of code didn't run
because I misnamed the object!). My bad. Thanks for the help. And I'm
VERY relieved R isn't that inefficient...
Matt
On Wed, Apr 16
On 17/04/2008, at 9:33 AM, Charles C. Berry wrote:
> I'll lay odds that Matthew's 'matrix' is actually a data.frame, and
> I'll not be surprised if the columns are factors.
I suspect that you're right.
***Why*** can't people distinguish between data frames and matrices?
If
On Thu, 17 Apr 2008, Rolf Turner wrote:
>
> On 17/04/2008, at 7:52 AM, Matthew Keller wrote:
>
>> Hello all,
>>
>> I should probably know this by now... Anyway:
>>
>> I have a large matrix (dim(data) is 3000 18000). In each element are
>> one of the following character strings "0/0", "1/1", "1/2"
On 17/04/2008, at 7:52 AM, Matthew Keller wrote:
> Hello all,
>
> I should probably know this by now... Anyway:
>
> I have a large matrix (dim(data) is 3000 18000). In each element are
> one of the following character strings "0/0", "1/1", "1/2", "2/2". I
> wanted to replace "0/0" with NA and th
Hello all,
I should probably know this by now... Anyway:
I have a large matrix (dim(data) is 3000 18000). In each element are
one of the following character strings "0/0", "1/1", "1/2", "2/2". I
wanted to replace "0/0" with NA and the other three with 0,1,2
respectively. To accomplish just the f
9 matches
Mail list logo