Geekuna Matata
Geekuna Matata

Reputation: 1439

How do I reformat my data for ggplot?

I have four dataframes (say A,B,C and D). The data in each dataframe is of the format given below. But each dataframe is of a different length.

 lon       lat           area              fd              tp       rt
-85.40944   41.88833    274.5387    1.100000e+02    50.00000000 60.0000000
-85.40944   41.88833    274.5387    1.140000e+02    31.00000000 83.0000000
-85.40944   41.88833    274.5387    6.040000e+02    76.00000000 528.0000000
-85.40944   41.88833    274.5387    1.000000e+00    1.00000000  0.0000000
-85.40944   41.88833    274.5387    3.340000e+02    32.00000000 302.0000000

I want to extract (for example) FD columns and the LON columns from four dataframes. And after that plot something like this, but instead of one blob, it will be four blobs of Lon v/s FD figures. enter image description here

Questions:

  1. Because of uneven lengths, I am unable to use MELT. How do I do it so that it is easier to plot in ggplot2?

Upvotes: 0

Views: 164

Answers (1)

baptiste
baptiste

Reputation: 77106

reshape2::melt(list(A=A, B=B, C=C, D=D), id="fd", meas="lon")

Upvotes: 1

Related Questions