Mohan L wrote on 09/08/2011 12:35:18 PM:
> 
> Hi All,
> 
> I have txt file like :
> 
> $ cat data.txt
> US   10
> UK   12
> Ind   4
> Germany   14
> France   8
> 
> > rawdata <- read.table(file='data.txt',sep='\t' , header=FALSE)
> 
> > rawdata
>        V1 V2
> 1      US 10
> 2      UK 12
> 3     Ind  4
> 4 Germany 14
> 5  France  8
> 
> I want to draw pie chart for the above data.
> 
> How to  split rawdata into :
> con <- c("US","UK","Ind","Germany","France");
> total <- (10,12,4,14,8)
> 


You could do this:
        con <- rawdata$V1
        total <- rawdata$V2

Or you could add in a col.names= argument to the read.table() function,

rawdata <- read.table(file='data.txt', sep='\t', header=FALSE, 
col.names=c("con", "total")) 
then refer to each vector in the data.frame as

rawdata$con

and 

rawdata$total

Jean


> 
> Any help will be appreciate.
> 
> Thanks & Rg
> Mohan L

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to