To plot three vectors of data of different lengths in different colors using ggplot2 package in R, you can create a new data frame with the three vectors as columns, each with a corresponding label column. Then, you can use the melt()
function from the reshape2
package to convert the data frame from wide to long format, with a separate row for each combination of labels and values.
Once the data frame is in the desired format, you can use ggplot()
function to create a scatter plot with the values as the y-axis variable, labelled by the label column, and colored by the variable column.
Here is an example code snippet:
main.r523 chars20 lines
This will create a scatter plot with the values of each vector plotted in different colors, labeled by the corresponding label column.
gistlibby LogSnag