0

I have a df w/ 3 variables: VOT, K, G. I want to make a plot of the K and G responses as a function of VOT. Any ideas for the best way to do this?

Here is some code I tried:

plot.K.Responses <- ggplot(mydf, aes(VOT, K,  group=VOT)) +
  geom_line() +
  geom_point() +
  facet_wrap(~VOT)
plot.K.Responses
pdf("plot.K.Responses", 18, 18, bg="transparent")
plot(plot.ID)
dev.off()
Lee Drown
  • 35
  • 2
  • 6
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. But if you don't know what you want the plot to look like and are just seeking general data visualization recommendations, then that's not a specific programming question and is off-topic for Stack Overflow. Maybe try [stats.se] instead where questions about data visualizations are on-topic – MrFlick Feb 18 '20 at 21:45

1 Answers1

0

Is this the result you are looking for? I made the df longer so it separately contains all the VOT and K and G observations. This makes it easier to graph using a grouped option like color.

library(tidyverse)
mydf <- data.frame(VOT = runif(10), K = runif(10), G = runif(10))

mydf <- mydf %>%
  pivot_longer(cols = c("K", "G"))

plot.K.Responses <- ggplot(mydf, aes(y = VOT, x = value, color = name)) +
                             geom_point() + 
                             geom_line()

plot.K.Responses
  • Hi! Thank you so much for your response. This turned my "VOT" column into decimal values. Is there a way to avoid this? – Lee Drown Feb 19 '20 at 13:42
  • I just tested the code I had here using VOT as an integer column and nothing seems to change it into a decimal column. You can use ```as.integer()``` to drop the decimal part though. – David Christafore Feb 19 '20 at 14:10