0
votes

So I want to do a simple plot where the following x-coordinates should be plotted as points. This is what my data.frame looks like:

   gap_pos
1 50646312
2 50647076
3 50647511
4 50647512
5 50647513
6 50647546

Now I have tried to do it as simple as possible:

gap_plot <- ggplot() + geom_point(data=gaps, aes(x=gap_pos))

Then the following error occurred:

Error in exists(name, envir = env, mode = mode) : 
argument "env" is missing, with no default

What can I do about this? I am totally stuck.

Edit:

The following two lines do not return an error but still do not plot anything.

gap_plot <- ggplot() + geom_point(data=gaps, aes(x=gap_pos , y = gap_pos))
gap_plot <- ggplot() + geom_point(data=gaps, aes(x=gap_pos , y = 1))
2
for geom_point() you should supply both x and y coordinatesNader Hisham
If I add y=1 it returns no error but it also does not plot anything.JadenBlaine
if you want to plot only these points you can assign y to be the same value of x so it will be something like this gap_plot <- ggplot() + geom_point(data=gaps, aes(x=gap_pos , y = gap_pos)) but I'm not sure if you want this resultNader Hisham
It's the same result like adding y =1 it returns no error anymore but it does not plot anything :/JadenBlaine
No , It should work fine I think you're not executing the plot try to run gap_plot , check this code gap_plot <- ggplot() + geom_point(data=gaps, aes(x=gap_pos , y = gap_pos)) gap_plotNader Hisham

2 Answers

1
votes

You have to give a y aesthetic for points. I'd add a factor with a single level to make a nice y axis:

> gap=data.frame(gap_pos=c(50646312, 50647076, 50647511, 50647512, 50647513, 50647513, 50647546))
> gap$data=factor("Data")
> ggplot() + geom_point(data=gap, aes(x=gap_pos, y=data))+ylab("")

Which gives: single Y plot

1
votes

This should work

gaps = data.frame(gap.pos = c(50646312, 50647076, 50647511, 50647512, 50647513, 50647546))
gap_plot <- ggplot(gaps) + geom_point(aes(x=gap.pos, y=1))

you have to call the plot you produced to actually see the plot

gap_plot