Holly Elliott
Holly Elliott

Reputation: 103

R: ggplot2 trouble reading a csv data file, object and mapping error

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

Upvotes: 0

Views: 2607

Answers (1)

nzcoops
nzcoops

Reputation: 9380

I think what you need is

p1 <- ggplot(data = Statsnineteen, aes(x=Max, y=Dept))

Upvotes: 2

Related Questions