[R] read.table and factor
Bill Simpson
wsi at gcal.ac.uk
Mon Feb 21 12:01:27 CET 2000
Thanks very much Peter
> as.numeric(as.character()) should do it
yes, this works, thanks.
>
> > How can I either tell read.table to leave the first two cols as numeric
> > (not factors) or convert them from factors into the proper numeric values?
>
> If they're not read as numeric, then they must contain non-numeric
> elements. Either fix the typo (!) or set na.strings in the call to
> read.table.
No, so far as I can tell neither std nor cf contain non-numeric elements.
This problem arises with every data file I read (the files are created by
a C program). I attach a file--std and cf are numeric, yet read.table
d<-read.table("~/papers/letter/data/ws60.dat",header=TRUE)
makes d$std and d$cf factors.
Bill
-------------- next part --------------
std cf hit miss fa cr
920 980 40 15 14 31
950 1010 24 23 23 30
1190 1250 26 21 27 26
1010 1070 33 10 28 29
1040 1100 35 10 11 44
1070 1130 40 17 13 30
890 950 44 14 13 29
830 890 34 13 11 42
1160 1220 30 17 14 39
1130 1190 32 19 20 29
860 920 37 8 17 38
800 860 34 14 11 41
980 1040 33 14 15 38
1100 1160 32 11 16 41
860 920 45 9 10 36
1040 1100 26 14 19 41
1130 1190 41 12 13 34
950 1010 31 18 22 29
890 950 36 12 9 43
1160 1220 20 24 14 42
800 860 33 14 10 43
1100 1160 29 18 7 46
1010 1070 39 10 14 37
1070 1130 40 9 15 36
830 890 47 9 5 39
980 1040 40 7 18 35
1190 1250 28 18 18 36
920 980 49 2 14 35
830 890 39 1 6 54
1040 1100 36 19 6 39
980 1040 34 9 15 42
1100 1160 36 13 14 37
860 920 47 10 15 28
800 860 41 12 6 41
1010 1070 30 10 10 50
1190 1250 26 12 18 44
950 1010 33 9 25 33
1130 1190 34 13 11 42
1160 1220 40 15 17 28
920 980 42 10 15 33
890 950 41 14 7 38
1070 1130 39 13 12 36
More information about the R-help
mailing list