-Original Message-
Here's the relevant portion of the as.table Help file:
But ... is an argument to table(), not to as.table; this part of the help file
is not referring to as.table.
The first argument to as.table is x, which is an 'arbitrary R object'. as.table
is a generic; it
as.table(dat1)
#Error in as.table.default(dat1) : cannot coerce to a table
You _can_ coerce to a matrix first:
as.table( as.matrix(dat1) )
S Ellison
***
This email and any attachments are confidential. Any use...{{dropped:8}}
Yes. My error was previously pointed out to me and there was further
offlist discussion. Maybe I should have kept it onlist, but I was
reticent about displaying my stupidity. :( Mea Culpa.
Cheers,
Bert
On Thu, Apr 11, 2013 at 9:11 AM, S Ellison s.elli...@lgcgroup.com wrote:
-Original
Hello all,
I have data in the form of a table:
X Y1Y2
0.1 3 2
0.2 2 1
And I would like to transform in the form:
X Y
0.1 Y1
0.1 Y1
0.1 Y1
0.1 Y2
0.1 Y2
0.2 Y1
0.2 Y1
0.2 Y2
Any ideas how?
Thanks in advance,
IOanna
(res)
res
# X Y
#1 0.1 Y1
#2 0.1 Y1
#3 0.1 Y1
#4 0.1 Y2
#5 0.1 Y2
#6 0.2 Y1
#7 0.2 Y1
#8 0.2 Y2
A.K.
- Original Message -
From: IOANNA ii54...@msn.com
To: 'r-help-r-project.org' r-help@r-project.org
Cc:
Sent: Monday, April 8, 2013 8:09 AM
Subject: [R] Reshaping a table
Hello all
To: IOANNA
Cc: R help
Subject: Re: [R] Reshaping a table
Hi,
Try this:
dat1-read.table(text=
X Y1 Y2
0.1 3 2
0.2 2 1
,sep=,header=TRUE)
res-do.call(rbind,lapply(split(dat1,seq_len(nrow(dat1))),function(x)
{Y=rep(colnames(x)[-1],x[-1]); X=rep(x[,1],length(Y
about the problem.
A.K.
- Original Message -
From: Bert Gunter gunter.ber...@gene.com
To: arun smartpink...@yahoo.com
Cc: dcarl...@tamu.edu dcarl...@tamu.edu
Sent: Monday, April 8, 2013 1:33 PM
Subject: Re: [R] Reshaping a table
Thanks.
Here's the relevant portion of the as.table Help
7 matches
Mail list logo