I'm working with an R data-frame and attempting to plot each column independently. I want the "fixed" variable to form the x-axis (strings) and the other 2, 3, or 4 (the function will need to handle all of these) to be separate lines. The way I am currently handling this: I have a vector containing the names of the attributes of the data-frame. However, obviously simply using the vector will not index it properly. So here's what the data frame looks like:
> retset
fixed st1 st2 st3 st4
1 str1 0.9335938 0.9445313 0.9170455 0.9090909
2 str2 0.9670732 0.9768750 0.9637500 0.9532895
3 str3 0.9037500 0.9325758 0.8890625 0.8546875
4 str4 0.9540541 0.9717949 0.9397436 0.9354167
5 str5 0.9154412 0.9382812 0.9090909 0.9117188
and then a vector that would have:
uniq <- c("st1", "st2","st3","st4")
and I want to plot it something like:
z<-ggplot(data=retset)
for (x in length(uniq)) {
z <- z + geom_line(data=retset, aes(x=fixed,y=uniq[x], color=uniq[x]))
}
Anybody have any suggestions?