R – reading tabular data files

commandline session

> dfrm <- read.table("first.txt",sep="-")
> print(dfrm
dfrm
> print(dfrm)
    V1      V2
1 Name Jeffrin
2  Age      35
3  Sex    Male
> dfrm <- read.table("first.txt",sep=" ")
> print(dfrm)
            V1
1 Name-Jeffrin
2       Age-35
3     Sex-Male
> dfrm <- read.table("first.txt",sep=".")
> print(dfrm)
            V1
1 Name-Jeffrin
2       Age-35
3     Sex-Male
> class(dfrm$V1)
[1] "factor"
> class(dfrm$V1)
[1] "factor"
> class(dfrm$V2)
[1] "NULL"
> class(dfrm$V3)
[1] "NULL"
>

$ 4.2.20 6 506---> cat first.txt
Name-Jeffrin
Age-35
Sex-Male
$ 4.2.20 7 507--->

This post has no comments. Be the first to leave one!

Join the discussion

Your email address will not be published. Required fields are marked *




Copyright © 2009,  2010,  2011,  2012,  2013, 2014     BeautifulWork Project    e-mail:  ahiliation@yahoo.co.in
BeautifulWork Project comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.