[R] reading in data problems

Upasna Sharma upasna at iitb.ac.in
Fri Mar 11 14:40:33 CET 2005


Hi

I have a dataset (.txt file and .dat file) in which the length of one
record is 144. There is no header in the .txt or .dat file itself. When I
read this file using the read.table command, and want to drop some
coloumns by setting the argument colClasses to "NULL" for the columns that
I want to drop, it does not work, because the entire record of the length
144 is being treated as one column only, of the type 'character'. I tried
using read.fwf instead of read.table, but that doesn't seem to work
either. what should I do, if I want to read in only some columns from the
file?

If it helps, the description of the .dat file in the supporting documents
if given as follows:

Work-file:01(Wrk101r/u) (person level work-file) record length : 145

No.    field                     	    length 	byte-Position
1.	Id					2	1 - 2
2.	Rnd sch					3	3 - 5
3.	sub-sample-original           	        1       6
4.	sec					1	7
5.	State-reg				3	8 - 10
6.	Stratum					2	11 - 12
7.	Sub-stratum				1	13
8.	Dist					2	14 - 15
9.	Sub rnd					1	16
10.	Sub-sample-revised			1	17
11.	Fsu					5	18 - 22
12.	Segment					1	23
13.	HHd -sl. No.				2	24 - 25
14. 	Survey code				1	26
15.	Reason -sub				1	27
16.	Nss					3	28 - 30
17.	Nsc					3	31 - 33
18.	Mult -ss				10	34 - 43
19.	HHD -size				3	44 - 46
20.	Mpce					8	47 - 54
21.	Mpce code				2	55 - 56
22.	Cmpce code				2	57 - 58
23.	HHd Type				1	59
24.	Religion				1	60
25.	Social group				1	61
26.	Land possessed CODE			2	62 - 63
27.	Dwelling code				1	64
28.	Type dwelling				1	65
29.	Type structure				1	66
30.	Covered area				6	67 - 72
31.	Cook					2	73 - 74
32.	Light					1	75
33.	Meal taken outside			1	76
34.	Ceremony performed			1	77
35.	Pds purchase				1	78
36.	Get food				1	79
37.	Not get food in the month of Jan	2	80 - 81
38.	Not get food in the month of Feb	2	82 - 83
39.	Not get food in the month of Mar	2	84 - 85
40.	Not get food in the month of Apr	2	86 - 87
41.	Not get food in the month of May	2	88 - 89
42.	Not get food in the month of June	2	90 - 91
43.	Not get food in the month of July	2	92 - 93
44.	Not get food in the month of Aug	2	94 - 95
45.	Not get food in the month of Sep	2	96 - 97
46.	Not get food in the month of Oct	2	98 - 99
47.	Not get food in the month of Nov	2	100 -101
48.	Not get food in the month of Dec	2	102 -103
49.	Tot no. of month not getting food	2	104 -105
50.	Whether asked				1	106
51.	Time canvass				3	107 109
52.	Person sl. No.				3	110 -112
53.	Relation				1	113
54.	Sex					1	114
55.	Age					2	115 -116
56.	Marital status				1	117
57.	Edu code				2	118 -119
58.	Upst code 				2	120 -121
59.	Upnic code				2	122 -123
60.	Sbst code				2	124 -125
61.	Sbnic code				2	126 -127
62.	Cwst code 				2	128 -129
63.	Cwnic code 				2	130 -131
64. 	Days stayed away			2	132 -133
65.	No. meal/day				1	134
66.	Meal school				2	135 -136
67.	Meal employer				2	137 -138
68.	Meal other				2	139 -140
69.	Meal on payment				2	141 -142
70.	Meal at home				2	143 -144
_______________________________________________________________________


-- 
"The past is a history, the future is a mystery, and this moment is a
gift. That is why this moment is called 'the present'." Anonymous




More information about the R-help mailing list