[R] Plot a line using ggplot2

Ebert,Timothy Aaron tebert @end|ng |rom u||@edu
Fri Dec 9 05:40:14 CET 2022

A number of problems.
The variable names are not helpful. PointEstx is not a point it is a value. I need an x and a y coordinate for a point.
row1 is not defined
While there is a function data.frame(), there is no data_frame(). Making this change gives an error that row1 is not defined. I solved the problem with row1<-row2+1.

The ggplot statement looks wrong.

Does this give you what you need?
ggplot(linedata,aes(x=PointEstx, y=PointEsty)) + geom_line()

Note I changed the comma to a plus sign and changed the brackets.


-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of Sorkin, John
Sent: Thursday, December 8, 2022 8:06 PM
To: r-help using r-project.org (r-help using r-project.org) <r-help using r-project.org>
Subject: [R] Plot a line using ggplot2

[External Email]


I am trying to plot a simple line using ggplot2. I get the axes, but I don't get the line. Please let me know what my error I am making.
Thank you,

# Define x and y values
PointEstx <- Estx+1.96*SE
PointEsty  <- 1

row2 <- cbind(PointEstx,PointEsty)
linedata<- data_frame(rbind(row1,row2))
# make sure we have a data frame

#plot the data
ggplot(linedata,aes(x=PointEstx, y=PointEsty), geom_line())

R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html&data=05%7C01%7Ctebert%40ufl.edu%7C5695e850b24347d9fcf908dad9818f28%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638061447740857132%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DPlvmxCIwlF1WqKWawzSmJbosiFGjnLwFIMKK7hFAco%3D&reserved=0
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list