Home > Software design >  How to rearrange a dataset to make facet graphing more easily done (original dataset combines two da
How to rearrange a dataset to make facet graphing more easily done (original dataset combines two da

Time:09-02

I been trying to find some resources similar to this but my current dataset looks like this:

lwg_date bon_date lwg_length bon_length
May April 1 31
May April 10 14
May April 12 12
March May 19 11
April May 5 17

and from the examples I see for facet graphs, an ideal format seems to be like this:

Type date length
LWG May 1
BON April 31
LWG May 10
BON April 24
LWG May 12

...and so on...

I have been trying with R's rearrangement functions, tried something with facet wraps, and have tried using loops and if statements. However, I still have been unable to figure this out so my questions are:

  1. This new format would make facet graphs easier, correct? (date, length, and count of overlapping histograms.) I struggled to do such a graph with the older data but perhaps I'm being going about it wrong.

  2. If this new dataset is better, what would be a good method?

Thank you in advance.

CodePudding user response:

I guess you're referring to the concept of Tidy Data (see: enter image description here

Data:

library(readr)

df <-
read_table("lwg_date    bon_date    lwg_length  bon_length
May April   1   31
May April   10  14
May April   12  12
March   May 19  11
April   May 5   17")
  • Related