-help@r-project.org
Sent: Tue, June 7, 2011 10:05:37 AM
Subject: Re: [R] Sorting a data frame with values of different lengths
Also, I tried changing a line to store W as numeric:
sample_info<-c(pds_gagehandles[i],p,as.numeric(sample_W))
But it is still sorting incorrectly:
> W_table[order(W
Thanks for catching that, Sarah.
It seems like the problem was that I was using the c() function to combine
terms (including W) that I was adding to a data frame.
This caused R to convert the numeric W to a character string.
I fixed this by using data.frame() and then rbind() instead of c() and
Hi,
On Tue, Jun 7, 2011 at 10:01 AM, William Armstrong
wrote:
> Hi Sarah,
>
> str(W_table) gives me:
>
>> str(W_table)
> 'data.frame': 11 obs. of 3 variables:
> $ pds_gagehandles.i.: Factor w/ 1 level "mibe": 1 1 1 1 1 1 1 1 1 1 ...
> $ p : chr "1" "2" "3" "4" ...
> $ W
Also, I tried changing a line to store W as numeric:
sample_info<-c(pds_gagehandles[i],p,as.numeric(sample_W))
But it is still sorting incorrectly:
> W_table[order(W_table$as.numeric.W.),]
pds_gagehandles.i. p as.numeric.W.
8mibe 81004.5
1mibe 1
Hi Sarah,
str(W_table) gives me:
> str(W_table)
'data.frame': 11 obs. of 3 variables:
$ pds_gagehandles.i.: Factor w/ 1 level "mibe": 1 1 1 1 1 1 1 1 1 1 ...
$ p : chr "1" "2" "3" "4" ...
$ W : chr "746" "870.5" "767" "1066" ...
here is the script I am usi
Hi,
It looks to me that your data frame is being sorted as text.
What does
str(W_table)
show?
How was W_table created? Your W column appears to not be numeric.
Sarah
On Tue, Jun 7, 2011 at 9:51 AM, William Armstrong
wrote:
> Hi all,
>
> I am attempting to run a script in which I permute my da
6 matches
Mail list logo