Read data .dat into R -


this question has answer here:

i import data set r: http://www.stat.ufl.edu/~winner/data/retail92.dat

really appreciate if me. tried read.csv, read.table none of them worked. don't know how specific variables' length in sas.

you can use function discerns columns based on number of characters (fixed width). need trim whitespace, though. can use function trimws.

xy <- read.fwf("http://www.stat.ufl.edu/~winner/data/retail92.dat",                   widths = c(38, 6, 8, 8, 8))  > head(xy)                                       v1    v2    v3     v4     v5 1 acadia, la                             3.672 0.882 12.364  3.872 2 ada, id                                9.251 1.152 21.384  3.861 3 adams, co                              7.489 0.911 16.718  3.507 4 adams, in                              7.822 1.216 15.772  2.470 5 aiken, sc                              6.451 1.032 18.474 19.201 6 alachua, fl                            8.240 1.052 17.505  3.862 > str(xy) 'data.frame':   845 obs. of  5 variables:  $ v1: factor w/ 845 levels "acadia, la                            ",..: 1 2 3 4 5 6 7 8 9 10 ...  $ v2: num  3.67 9.25 7.49 7.82 6.45 ...  $ v3: num  0.882 1.152 0.911 1.216 1.032 ...  $ v4: num  12.4 21.4 16.7 15.8 18.5 ...  $ v5: num  3.87 3.86 3.51 2.47 19.2 ... 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -