Reputation:
I have my data:
x <- list(10,50,100,250,500,2500)
y <- list(0.09090909,0.01960784,0.003984064,0.003984064,0.001996008,0.0003998401)
I want to link my data to code found on this website
log_c <- seq(-12, 0, by = 0.1)
df <- data.frame(log_c = log_c, response = V(log_c, E, HS, log_EC50))
ggplot(df, aes(log_c, response)) +
geom_line()
I want to put the x data in place of log_c and y data in place of response. These are my beginnings in R, so I am asking for help
Upvotes: 1
Views: 135
Reputation: 226087
At a minimum this will work:
c()
instead of list()
). Put them into a data frame (not strictly necessary, but best practice):df <- data.frame(x=unlist(x), y = unlist(y))
library(ggplot2)
ggplot(df, aes(x, y)) + geom_line()
To get your graph looking a little more like the example in your post,
scalefun <- function(y) (y-min(y))/diff(range(y))
ggplot(df, aes(x, y = scalefun(y))) + geom_line() + scale_x_log10()
Upvotes: 5
Reputation: 78917
Same logic as @Ben Bolker: Just another way:
library(tidyverse)
tibble(x,y) %>%
unnest() %>%
ggplot(aes(x, y))+
geom_line()
Upvotes: 1