[R] OK - I got the data - now what? :-)
Mark Wardle
mark at wardle.org
Sun Jul 5 09:00:01 CEST 2009
Hi. Essentially your data is currently in "wide" format, with repeated
measures in different columns. For most analysis and in particular for
graphing, it is frequently helpful to reshape your data into a "long"
format, with one row per data value and additional variables to list
experiment or subject identifier, experimental conditions etc.
see ?reshape and Dr. Wickham's reshape package (http://had.co.nz/reshape/)
Good luck,
Mark
2009/7/5 Mark Knecht <markknecht at gmail.com>:
> OK, I guess I'm getting better at the data part of R. I wrote a
> program outside of R this morning to dump a bunch of experimental
> data. It's a sort of ragged array - about 700 rows and 400 columns,
> but the amount of data in each column varies based on the length of
> the experiment. The real data ends with a 0 following some non-zero
> value. It might be as short as 5 to 10 columns or as many as 390. The
> first 9 columns contain some data about when the experiment was run
> and a few other things I thought I might be interested in later. All
> the data starts in column 10 and has headers saying C1, C2, C3, C4,
> etc., up to C390 The first value for every experiment is some value I
> will normalize and then the values following are above and below the
> original tracing out the path that the experiment took, ending
> somewhere to the right but not a fixed number of readings.
>
> R reads it in fine and it looks good so far.
>
> Now, what I thought I might do with R is plot all 700 rows as
> individual lines, giving them some color based on info in columns 1-9,
> but suddenly I'm lost again in plots which I think should be fairly
> easy. How would I go about creating a plot for even one line, much
> less all of them? I don't have a row with 1,2,3,4 to us as the X axis
> values. I could go back and put one in the data but then I don't think
> that should really be required, or I could go back and make the
> headers for the whole array 1:400 and then plot from 10:400 but I
> thought I read that headers cannot start with numbers.
>
> Maybe the X axis values for a plot can actually be non-numeric C1, C2,
> C3, C4, etc and I could use line (C1,0) to (C2,5) and so on? Or maybe
> I should strip the C from C1 and be left with 1? Maybe the best thing
> is to copy the data for one line to another data.frame or array and
> then plot that?
>
> Just sort of lost looking at help files. Thanks for any ideas you can
> send along. Ask questions if I didn't explain my problem well enough.
> Not looking for anyone to do my work, just trying to get the concepts
> right
>
> Cheers,
> Mark
>
> ______________________________________________
> 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.
>
>
--
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK
More information about the R-help
mailing list