On Dec 8, 2009, at 4:12 PM, Gaurav Moghe wrote:
> Hi David,
>
> 1) My code is as follows:
> x=read.table("file",sep="\t")
> prate<-x[,2]
> lrates<-(x[,3])
> When I do:
> print (typeof(lrates)): I get "integer"
You've already received several solutions from people more R-savvy
than I, so I will try instead to explain what went wrong with your
code. I will bet you get:
> class(lrates)
[1] "factor"
typeof() can be rather misleading when it comes to factors. They are
represented internally as integers, even you they look like characters
when printed.
>
> When I do:
> for (line1 in lrates) {
> lsp<-unlist(strsplit(line1,"\\,"))
> }
> I get some intermediate value
If you had attempted the above with as.character(line1, "\\1,") it
might have worked, since you almost certainly were operating on a
factor. The as.character() coercion function will give you the
character labels of the levels of factors.
> 2) With options()$dec, I get "NULL"
No problem here. I was wondering if you might be somewhere that uses
the period as a comma and commas as decimal point.
--
David
>
> I wonder whether thats what you want,
> Gaurav
>
> On Tue, Dec 8, 2009 at 4:03 PM, David Winsemius <[email protected]
> > wrote:
> Two questions:
>
> What is your code?
>
> What do you get with:
> > options()$dec
> decimal_point
> "."
>
> -- David
>
>
> On Dec 8, 2009, at 3:55 PM, 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]]
>
> ______________________________________________
> [email protected] 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.
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>
>
>
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.