I am building an R function that would plot multiple Force Vs. Displacement lines in one graph. Here is my set of data:
myrows displacememnt force displacememnt force displacememnt force displacememnt force displacememnt
[1,] 1 0.000000e+00 0 0.000000e+00 0 0.000000e+00 0 0.000000e+00 0 0.000000e+00
[2,] 2 4.292647e-08 0 8.829379e-08 0 4.194021e-08 0 4.136511e-08 0 -3.818898e-08
[3,] 3 1.284946e-09 0 1.343980e-07 0 4.665416e-08 0 3.375577e-08 0 -4.819687e-09
[4,] 4 4.380121e-08 0 1.742593e-07 0 7.184801e-09 0 3.734106e-08 0 3.210356e-08
[5,] 5 8.224440e-08 0 2.558701e-07 0 1.245641e-07 0 8.266907e-08 0 1.024775e-07
[6,] 6 1.269747e-07 0 3.842161e-07 0 1.223706e-07 0 1.666898e-07 0 1.407497e-07
All I want to do is plot multiple force vs. displacement within the same graph. But I dont know how to split up the data , I tried melt function:
meltedData <- melt(dataset,id.vars="myrows")
> head(meltedData)
Var1 Var2 value
1 1 myrows 1
2 2 myrows 2
3 3 myrows 3
4 4 myrows 4
5 5 myrows 5
6 6 myrows 6
This is the minimal reprsentation of the dataset.
Would anyone be able to assist me to acheive my objective i.e. to plot multiple force v displacement lines within one plot?
Final plot what it looks like:


plot()function to plot the first series, and uselines()orpoints()to add subsequent seriesdput(dataset)would make it easier to reproduce your example.