Reputation: 28905
I have a data frame "myframe":
> myframe
myframe
exp obs
8 6 10
9 7 11
10 7 10
12 7 9
17 9 8
29 7 8
31 7 7
37 5 5
43 9 12
and I want to plot the two columns.
plot(myframe$exp,myframe$obs)
and I get
Why is this happening and how do I fix it?
Here is the output of dput(myframe):
> dput(myframe)
dput(myframe)
structure(list(exp = c(6L, 7L, 7L, 7L, 9L, 7L, 7L, 5L, 9L), obs = structure(c(1L,
2L, 1L, 19L, 18L, 18L, 17L, 16L, 3L), .Label = c("10", "11",
"12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22",
"23", "25", "5", "7", "8", "9", "b", "y"), class = "factor")), .Names = c("exp",
"obs"), row.names = c(8L, 9L, 10L, 12L, 17L, 29L, 31L, 37L, 43L
), class = "data.frame")
>
Upvotes: 1
Views: 4797
Reputation: 61973
obs is being treated as a factor right now. You can convert it to numeric using the following code
myframe$obs <- as.numeric(levels(myframe$obs))[myframe$obs]
Plotting should work just fine now.
Upvotes: 2