[R] Reading the non delimited file with no particular patterns in the data to R

Clint Bowman clint at ecy.wa.gov
Fri Jul 10 20:08:47 CEST 2015


Is this what your are expecting?

> test <- read.fwf("test.dat", width = c(10, 4, 1, 4, 9, 
12,26,1,1,1,1,1,1,3,8))
> test
   V1   V2 V3 V4       V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15
1  1 2015  1  4 0.766696  1  1  0  0   0   0   0   0   0  10
2  2 2015  1  4 1.458186  1  1  0  0   0   1   0   0   0  20
3  3 2015  1  4 0.185492  1  1  0  0   0   0   0   0   0  15
4  4 2015  1  4 0.961584  1  1  0  0   0   0   0   0   0   3
5  5 2015  1  4 0.650091  2  0  0  0   1   0   0   0   0  NA
6  6 2015  1  4 0.430350  1  1  0  0   0   0   0   0   0  20
7  7 2015  1  4 3.192895  2  1  0  1   1   0   0   0   0   0
8  8 2015  1  4 0.617127  1  1  0  1   0   1   0   0   0  15
9  9 2015  1  4 0.399207  1  1  0  0   0   0   0   0   0  10

Clint

Clint Bowman			INTERNET:	clint at ecy.wa.gov
Air Quality Modeler		INTERNET:	clint at math.utah.edu
Department of Ecology		VOICE:		(360) 407-6815
PO Box 47600			FAX:		(360) 407-7534
Olympia, WA 98504-7600

         USPS:           PO Box 47600, Olympia, WA 98504-7600
         Parcels:        300 Desmond Drive, Lacey, WA 98503-1274

On Fri, 10 Jul 2015, jagadishpchary wrote:

> I am beginner in R and I want to read a ASCII file to R environment. However,
> the ASCII file is a non delimited and the data is not continuous (have some
> blank spaces between the variables) so in order to read the data i have used
> the below syntax i.e
> test <- read.fwf("D:/R_process/ASCII.txt", width = c(10, 4, 1, 4, 9, 9,
> 1,1,1,1,1,1,1,3,8))
>
> Now i am able to read it but the data read is wrong. Actually my out put
> should have only the applicable variables data but not the blank data.
> Attached is the ASCII data. Please let me know how should i write the syntax
> to read only the applicable data in the file.
>
> Thanks for your help in advance. test.txt
> <http://r.789695.n4.nabble.com/file/n4709699/test.txt>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Cross-tabulation-with-top-one-variable-and-side-as-multiple-variables-tp4708379p4709699.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list