1

I have a problem with plotting my results. Previously (about two weeks ago) I can use same code at below to plot my data but now I'am getting error

data<- read.table("my_step.odt", header = FALSE, sep = "", quote="\"'", dec=".", as.is =  FALSE, strip.white=FALSE, col.names=c(.......); 
mgn_my <- data[1:49999,18]
sim  <- data[1:49999, 21]
plot(sim , mgn_my , type="l",xlab="Time (ns)",ylab="mx")

error

Error in table(x, y) : attempt to make a table with >= 2^31 elements

any suggestion?

Alexander
  • 4,527
  • 5
  • 51
  • 98
  • Did the `plot` command cause the error or did you call `table` on some of your variables? – josliber May 13 '14 at 02:08
  • Dear @josilber `plot` command caused it! – Alexander May 13 '14 at 02:45
  • Would you please provide a reproducible example, see [here](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – FFI May 13 '14 at 08:43
  • You should reduce your data size in any case. A plot of all 50 thousand points (or generating a line from same) will be indistinguishable from plotting every hundredth point. That said, there is clearly something wrong with either your dataset, or you have a typo and called the wrong object. `R` can easily plot 500k points. Or, possibly, you've overloaded `plot` somehow. – Carl Witthoft May 13 '14 at 11:19

1 Answers1

2

I have had a similar problem as you before. Based on my response from another post, here's what I would suggest before you run plot:

Option 1: Use droplevels

mgn_my <- droplevels(data[1:49999,18])

Option 2: Use apply. This approach seems "friendlier" if you are familiar with apply-family functions in R. For example:

mgn_my <- data[1:49999,18]
apply(mgn_my,1,plot)
Community
  • 1
  • 1
David C.
  • 1,974
  • 2
  • 19
  • 29