[R] Sorting a data frame with values of different lengths

William Armstrong William.Armstrong at noaa.gov
Tue Jun 7 16:05:37 CEST 2011


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.
8                mibe  8        1004.5
1                mibe  1           746
10               mibe 10           746
6                mibe  6         811.5
2                mibe  2         818.5
11               mibe 11         822.5
4                mibe  4           879
5                mibe  5           888
9                mibe  9           901
7                mibe  7         903.5
3                mibe  3         919.5
> 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" ...
 $ as.numeric.W.     : chr  "746" "818.5" "919.5" "879" ...


--
View this message in context: http://r.789695.n4.nabble.com/Sorting-a-data-frame-with-values-of-different-lengths-tp3579653p3579691.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list