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)> rawdataV1 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) Any help will be appreciate. Thanks & Rg Mohan L
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]]
On 09/09/2011 03:35 AM, Mohan L wrote:> 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) >Hi Mohan, Anything wrong with: pie(rawdata$V2,labels=rawdata$V1) Jim