OP, you need to reorganize your data to follow Tidy Data guidelines. Luckily, there's a lot of ways to do this in R
. I usually default to using tidyr
and dplyr
via gather()
, where you need to "gather" all the columns together and use those column names as "key" and the "value" would be the observations (the row values).
Since OP did not share their data in a format that is easy to work with.. here's a reprex:
set.seed(1234)
df <- data.frame(NA)
for(i in LETTERS){ df[[i]]=sample(1:10, size=1) }
df <- df[,-1] # gives you data frame with 1 row and 26 columns
That gives you a data frame with 26 columns ("A" through "Z"), where one observation for each column is a random integer from 1 to 10. Here's how to gather them together and use to make a plot:
library(dplyr)
library(tidyr)
library(ggplot2)
df <- df %>% gather(key=y, value=x) # result = data frame with 2 columns and 26 rows
ggplot(df, aes(x=x, y=y)) + geom_point()
