1
votes

(R beginner here...) I have a dataset like:

> head(q)
            Date Time System User
1 2011-10-01 00:00:01   12.4  4.6
2 2011-10-01 01:00:02   27.4  1.8
3 2011-10-01 02:00:01   15.2  1.0
4 2011-10-01 03:00:01   19.8  2.4
5 2011-10-01 04:00:02   19.2  3.4
6 2011-10-01 05:00:01   17.8  1.8
> nrow(q)
[1] 2207

Where 'Date Time' was formed from raw csv data with as.POSIXct(...) But when I try a plot with more than 1300 rows:

> qplot(q$'Date Time',q$'User');dev.off()
Error: cannot allocate vector of size 9.8 Gb

And it's the same with:

> ggplot(q,aes(q$'Date Time',q$'User'))+geom_point(); dev.off()
Error: cannot allocate vector of size 9.8 Gb

What can I do to make it work? I want a scatter of system performance metrics which is spread over three months - the data is hourly so theres about 2200 rows.

1
I was running this inside an interactive "R" session and it seems if I run this from a script with Rscript I do not have the problem at all. I have a lot to learn about R memory management it seems :)Paul Hedderly

1 Answers

4
votes

You are using the aes function wrong. You use:

ggplot(q,aes(q$'Date Time',q$'User'))+geom_point()

while the correct would be:

ggplot(q,aes_string(x = 'Date Time', y = 'User')) + geom_point()

There is no need to feed a vector of data to aes. You could try to see if it helps. In addition, A good tip is also to use ggsave to save your ggplot's to file.