0

I am new to using the ggplot2 package and am unfortunately having trouble with the basics. My data set is in a csv comma delimited file which has been working in R using plot functions but doesn't seem to be working in ggplot2. My csv file looks as follows:

Depth Min Max Average Mode
34    2   38  5.64    2
44    2   25  6.27    2
etc....

The code I am using is as follows:

Statsnineteen <- read.csv(file="C:/Users/Holly/Documents/Software Manuals/R
Stuff/Stats_nineteen.csv", header=TRUE, sep=",")
p1 <- ggplot(Max, Depth, data = Statsnineteen)
p1 <- p1 + layer(geom="path") + coord_flip()

It then comes up with the following error message between the two p1 lines:

Error in inherits(mapping, "uneval") : object 'Max' not found

I know it can read the table as when I use:

Statsnineteen <- read.table(file.....)
head(Statsnineteen, n=52)

It brings up my data table. Don't suppose anyone knows if there is a command I've missed out or if there is something wrong with my code? Thanks in advance for any help, Holly

0

1 Answer 1

2

I think what you need is

p1 <- ggplot(data = Statsnineteen, aes(x=Max, y=Dept))
Sign up to request clarification or add additional context in comments.

2 Comments

note that p1 <- qplot(Max, Depth, data = Statsnineteen) should also work. I think that the ggplot approach is much clearer.
If this answer has solved your problem please mark it as accepted. Doing so lets others know the question has been answered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.