[R] Importing data with different delimters
P.Dalgaard at biostat.ku.dk
Mon Jun 16 17:41:35 CEST 2008
Greg Snow wrote:
> It looks like your original data may be tab seperated, if that is the case then just use read.delim or use sep='\t' in read.table or scan.
I think that was only half the problem. If you do that, you end up with
one column containing both City and State, comma-separated. Presumably,
the path of least resistance is just to do this and then use string
processing with sub() or strsplit() to split the "City, State" strings.
>> I have a data file with 56 entries that looks like this:
>> City State JanTemp Lat Long
>> Mobile, AL 44 31.2 88.5
>> Montgomery, AL 38 32.9 86.8
>> Phoenix, AZ 35 33.6 112.5
>> Little Rock, AR 31 35.4 92.8
>> Los Angeles, CA 47 34.3 118.7
>> San Francisco, CA 42 38.4 123.0
>> I would like to "read" this data into a dataframe. Is it
>> possible to do without editing the datafile?
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help