I want to create a plot with the following data:
> dput(Data)
structure(list(Subject = c("1", "2", "3", "4", "5", "6", "7",
"13", "14", "15", "16", "17", "18", "20", "22", "24", "25", "27",
"28"), `Time given (in seconds)` = c(150, 150, 150, 150, 150,
150, 150, 300, 300, 300, 300, 300, 300, NA, NA, NA, NA, NA, NA
), `Time spent (in seconds)` = c(63.461, 150.014, 150.113, 150.012,
150.014, 150.02, 150.012, 159.232, 198.006, 221.791, 264.997,
293.73, 246.836, 101.439, 151.4, 157.709, 165.721, 319.134, 425.268
), `Number of "a's" counted` = c(78, 55, 83, 76, 73, 45, 50,
105, 105, 102, 97, 173, 101, 65, 67, 100, 50, 99, 93)), row.names = c(NA,
-19L), class = c("tbl_df", "tbl", "data.frame"))
As you can see, there are some subjects who got 150 seconds, some of them got 300 seconds, and some of them got unlimited time (=NA) to complete a certain task. I want to plot these 3 groups in a scatter plot that measures time spent on the task on the x=-axis and number of 'A's counted on the y-axis. I created the following things to get this done:
Data1 <- Data[-(8:19),]
Data2 <- Data[(8:13),]
Data3 <- Data[-(1:13),]
x1 <- Data1$`Time spent (in seconds)`
x2 <- Data2$`Time spent (in seconds)`
x3 <- Data3$`Time spent (in seconds)`
y1 <- Data1$`Number of "a's" counted`
y2 <- Data2$`Number of "a's" counted`
y3 <- Data3$`Number of "a's" counted`
And I tried to run the following code to create the scatterplot:
ggplot <- ggplot(Data, aes(x=`Time spent (in seconds)`,y=`Number of "a's" counted`)) + geom_point(colour="blue")
ggplot
But I don't know how I can create a plot with all 3 groups and then give each of them a different colour. Can somebody help me to create a scatterplot with this data? Thanks in advance!