Hello, I hope you are well.
I am new to r and pretty out of my depth. I have run a 3 x 7 experiment looking at how people perceive different emotions (anger, disgust, fear, happy, pain, sad and surprise) across different presentation conditions (dynamic, dynamic-text and text). My supervisor wants me to make a line graph showing the emotion ratings across the three different conditions. So the 7 different emotions will be along the x axis, and there will be 3 lines for the different conditions showing the different mean scores for each emotion. I was trying to follow use the example someone kindly shared here Steve’s Data Tips and Tricks - Plotting Multiple Lines on a Graph in R: A Step-by-Step Guide.
The code I am working on, based on the above example.
Emotion <- (c("Anger", "Disgust", "Fear", "Happy", "Pain", "Sad", "Surprise"))
D <- c(41.33333333, 52.36796537, 33.27536232, 19.59090909, 34.33333333, 49.12735849, 27.6746988)
names (D) <- Emotion
T <- c(70.31606218, 48.5019305, 24.28333333, 18.22727273, 40.20481928,47.0349345 , 46.2020202)
names (T) <- Emotion
DT <- c(42.59106529, 44.00877193, 18.86666667,13.88235294, 24.2875, 44.96103896, 34.47619048)
names (DT) <- Emotion
View(data)
x <- Emotion
y1 <- c(D)
y2 <- c(DT)
y3 <- c(T)
matplot(x, cbind(y1, y2, y3), type = "l", lty = 1,
col = c("red", "blue", "green"), xlab = "X",
ylab = "Y", main = "Multiple Lines Plot")
legend("topright", legend = c("Line 1", "Line 2", "Line 3"),
col = c("red", "blue", "green"),
lty = 1)
I am not sure what I am doing wrong and how to fix it. I get this error message when trying to plot the graph.
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log = log, recycle = TRUE) :
NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
4: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
If anyone has any suggestions I am all ears and would really appreciate it. Have a lovely day! Thank you.