cannot allocate vector of size 1130878.1 Gb

The txt data file is uploaded as pdf. If you just rename it back to txt, it is readable.

Running the code below gives me an error: cannot allocate vector of size 1130878.1 Gb. I don't understand. The dataframe is not even 1 MB by object.size(m3Spike)

place_fields.txt.pdf (357.5 KB)

knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
m3Spike = read.table('place_fields.txt', sep = ',')

ggplot(m3Spike, aes(x=V1, y=V2)) +
  geom_raster(aes(fill=factor(V3))) +
  scale_fill_manual(values=c("0"="white", "1"="black"))


ggplot(m3Spike, aes(x=V1, y=V2)) + geom_point() works though.

Your problem is with the precision of your variables, they generate too many positions to fill in for the raster geom, if you decrease precision the plot works.

library(readr)
library(ggplot2)
m3Spike <- read_csv("place_fields.txt", col_names = FALSE)
summary(m3Spike)
#       X1                 X2                 X3        
# Min.   :-0.01503   Min.   :-0.01792   Min.   :0.0000  
# 1st Qu.: 0.12336   1st Qu.: 0.20277   1st Qu.:0.0000  
# Median : 0.33193   Median : 0.49112   Median :0.0000  
# Mean   : 0.40739   Mean   : 0.49657   Mean   :0.2706  
# 3rd Qu.: 0.67656   3rd Qu.: 0.79212   3rd Qu.:1.0000  
# Max.   : 1.01660   Max.   : 1.01200   Max.   :1.0000 

ggplot(m3Spike, aes(x=round(X1*100,0), y=round(X2*100,0))) +
  geom_raster(aes(fill=factor(X3))) +
  scale_fill_manual(values=c("0"="white", "1"="black"))

3 Likes

should have thought of that. Thank you

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.