I'm working in R and i've a problem :(. I've this dataframe that i want to plot using ggplot:
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
1 -0.8067465 -0.4170181 0.9380890 0.613084937 0.4583916 0.4175951 -0.7183698 -0.3479931 -0.3392734 -0.8516039
2 -0.2893608 -0.8066911 0.1534129 0.008801641 -0.1916244 -0.6729157 0.6154498 0.1914066 0.3660398 0.9019622
3 -0.9536465 0.9645535 -0.6915938 0.328425519 -0.4197832 -0.2064765 -0.4328127 0.7849686 -0.2665250 0.6206650
I need to plot each column together to another one, just like facet_grid does it. In the X-axis i only need, for each plot, adjust the limits based in an intervale (e.g.:[-1,1]), but not a specific column/variable. The Y-axis works fine.
My principal problem is that i didn't know how to generate each plot using column name and their three points (or n points) in the same graph for every column in a dataframe. I tried some like this:
ggplot(q12, aes(x = V1, y = row.names(q12))) +
geom_point()+
facet_grid(.~ V1)
that generate this plot and i want some like this.
I know that V1
has to be the list of columns, but i have no idea how to do. Use colnames(q12)
doesn't works, and the i need the three points in the same graph.
In my previous experience using ggplot i had a column with an ID o an attribute for plotting. This case is a little different, i research a lot to do it, but i didn't find any solution. I tried with melt without results, maybe i didn't know how it works.
If someone could help me step by step, for learn it, i would be very grateful.
Data
structure(list(V1 = c(-0.8067465, -0.2893608, -0.9536465), V2 = c(-0.4170181,
-0.8066911, 0.9645535), V3 = c(0.938089, 0.1534129, -0.6915938
), V4 = c(0.613084937, 0.008801641, 0.328425519), V5 = c(0.4583916,
-0.1916244, -0.4197832), V6 = c(0.4175951, -0.6729157, -0.2064765
), V7 = c(-0.7183698, 0.6154498, -0.4328127), V8 = c(-0.3479931,
0.1914066, 0.7849686), V9 = c(-0.3392734, 0.3660398, -0.266525
), V10 = c(-0.8516039, 0.9019622, 0.620665)), .Names = c("V1",
"V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10"), class = "data.frame", row.names = c("1",
"2", "3"))