E Atescelik
2012-May-06 19:56 UTC
[R] question about transforming data into data frame object
Hi,I had a question about transforming data into data frame object with two
columns. I have data "genal2.txt" (see attachment) My data frame
called "genal2frame" has to be in the form: genal2frame[1:6,]
y mut
1 0.5105618 0.005
2 0.3428392 0.005
3 0.5490900 0.005
4 0.4460895 0.010
5 0.5214594 0.010
6 0.4009612 0.010 Thanks in advance! Kind regards,Esra Atescelik
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: genal2.txt
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20120506/5f153e8c/attachment.txt>
Jeff Newmiller
2012-May-06 20:51 UTC
[R] question about transforming data into data frame object
Not sure what your question was. Perhaps you could look up the reshape2 package
and ask a more specific question?
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live
Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
E Atescelik <eatescelik at hotmail.com> wrote:
>
>
>
>
>Hi,I had a question about transforming data into data frame object with
>two columns. I have data "genal2.txt" (see attachment) My data
frame
>called "genal2frame" has to be in the form: genal2frame[1:6,]
> y mut
>1 0.5105618 0.005
>2 0.3428392 0.005
>3 0.5490900 0.005
>4 0.4460895 0.010
>5 0.5214594 0.010
>6 0.4009612 0.010 Thanks in advance! Kind regards,Esra Atescelik
> ______________________________________________
>R-help at 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.
David Winsemius
2012-May-07 04:20 UTC
[R] question about transforming data into data frame object
On May 6, 2012, at 3:56 PM, E Atescelik wrote:> Hi,I had a question about transforming data into data frame object > with two columns. I have data "genal2.txt" (see attachment) My > data frame called "genal2frame" has to be in the form: > genal2frame[1:6,] > y mut > 1 0.5105618 0.005 > 2 0.3428392 0.005 > 3 0.5490900 0.005 > 4 0.4460895 0.010 > 5 0.5214594 0.010 > 6 0.4009612 0.010 Thanks in advance! Kind regards,Esra > Atescelik <genal2.txt>dat <- read.table("genal2.txt", header=TRUE) tdat <- as.data.frame(t(dat)) tdat$time <- sub("X0\\.", "", rownames(tdat)) names(tdat) <- c("x.1","x.2","x.3","grp") longdat <- reshape(tdat, idvar=4, direction="long", varying=1:3) longdat[order(longdat$grp), c("x", "grp") ] -- David Winsemius, MD West Hartford, CT