Thanks a lot to everyone who replied. I used some of Stephan Kolassa's
suggestions (thanks, Stephan). Here's my final code which worked (with
comments to explain novices like me who come looking for the same answer)

x=read.table("file",sep="\t",colClasses="character")
prate<-x[,2]
lrate<-x[,3] #this reads column 3

for (i in (0:nrow(x))) {    #for each row in the file
  line1<-lrate[i]      #define it separately
  lsp<-as.vector(as.numeric(unlist(strsplit(line1,"\\,"))))  #explanation
below
  }

1) strsplit Splits line by comma into a list
2) unlist "unlists" the list
3) as.vector(as.numeric()) converts it to a numeric vector for plotting a
boxplot

It is possible that the other approaches in this thread also work, some more
efficiently

Thanks again to everyone who replied

Gaurav


On Tue, Dec 8, 2009 at 4:05 PM, Phil Spector <spec...@stat.berkeley.edu>wrote:

> Gaurav -
>   Here's one way:
>
>  x = textConnection('ID1          0.342             0.01,1.2,0,0.323,0.67
>>
> + ID2         0.010              0.987,0.056,1.3,1.5,0.4
> + ID3         0.146              0.1173,0.1494,0.211,0.1257
> + + ')
>
>> y = read.table(x,stringsAsFactors=FALSE)
>> res = apply(y,1,function(x)as.numeric(strsplit(x[3],',')[[1]]))
>> names(res) = y[,1]
>> boxplot(res)
>>
>
>                                        - Phil Spector
>                                         Statistical Computing Facility
>                                         Department of Statistics
>                                         UC Berkeley
>                                         spec...@stat.berkeley.edu
>
>
>
> On Tue, 8 Dec 2009, Gaurav Moghe wrote:
>
>  Hi all,
>>
>> I'm a beginner user of R. I am stuck at what I thought was a very obvious
>> problem, but surprisingly, I havent found any solution on the forum or
>> online till now.
>>
>> My problem is simple. I have a file which has entries like the following:
>> #ID       Value1            List_of_values
>> ID1          0.342             0.01,1.2,0,0.323,0.67
>> ID2         0.010              0.987,0.056,1.3,1.5,0.4
>> ID3         0.146              0.1173,0.1494,0.211,0.1257
>> ...
>> ...
>>
>> I want to split the third column (by comma) into individual values and put
>> them in a variable so that I can plot a boxplot with those values, one
>> boxplot per row . I have been having three issues:
>> 1) R identifies the third column as an integer, instead of a list of lists
>> 2) I havent been able to split the third column into individual values
>> 3) How do I get it in a format suitable for plotting a boxplot?
>>
>> Any suggestions? I'd really appreciate any help on this.
>>
>> Thank you,
>> Gaurav
>>
>>        [[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.
>>
>>

        [[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