Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

damnit R

Name: Anonymous 2013-03-25 18:56

okay i have a datafile like this
chr01.fsa    43109    44002    MACS_peak_1    200.81
chr01.fsa    45489    46376    MACS_peak_2    298.26
chr01.fsa    67930    70674    MACS_peak_3    2769.45
chr01.fsa    138889    139895    MACS_peak_4    60.97
etc.

and basically when I read the table, the numeric columns are treated as character vectors
trying the following

bed1<-read.table('myfile.txt',sep='\t')
apply(bed1,2,class)
         V1          V2          V3          V4          V5
"character" "character" "character" "character" "character"

wtf? columns 2,3,and 5 are clearly numeric.
i try to force them to numeric

transform(bed1,V2=as.numeric(V2),V3=as.numeric(V3))
apply(bed1,2,class)
         V1          V2          V3          V4          V5
"character" "character" "character" "character" "character"

It doesn't do a thing! I have also tried stringsAsFactors, colClasses, and they do not change my results

Here's the whole datafile i am totally out of ideas
http://pastebin.com/YqFNpBPQ

Name: Anonymous 2013-03-25 19:15

I just found the goddamned fucking answer

"apply coerce dataframes into matrices or arrays."

http://stackoverflow.com/questions/15173547/numeric-column-shows-as-character

FUCK WHY??
How do I process a row at a time while preserving the goddamn type information then????

Name: Anonymous 2013-03-25 19:29

By going the fuck back to /g/.

Name: Anonymous 2013-03-25 19:48

>>3
LLLLLLLLLLLEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
>EGIN GEIN GWI NGWINGWIN GROO XDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

Name: Anonymous 2013-03-25 19:59

Well, I guess I can figure it out but if there's a solution that doesn't use plyr for now that would be preferred. I have seen plyr is pretty much a replacement for the built-in apply functions crappiness

For example, here
http://stackoverflow.com/questions/3480813/mapping-over-the-rows-of-a-data-frame

It shows that adply is retaining the type info for one thing.
However I still have fuckin problems

One of the responders uses this code and has a different output than me
adply(x, 1, function(x) f(x$letter, x$number))
  X1 V1
1  1 a1
2  2 b2
3  3 c3

Mine says
adply(x, 1, function(x) f(x$letter, x$number))
  letter number V1
1      a      1 a1
2      b      2 b2
3      c      3 c3

And that is not inconsequential....goddamnit

Name: Anonymous 2013-03-25 20:05

Furthermore I don't have enough points to post comments on stackoverflow :((((

Don't change these.
Name: Email:
Entire Thread Thread List