0

I want to use this function here is the code on github to sample my dataset in 2 parts 90% traning data set ( for example) and 10% (the rest) are the test ( for example tried this code :


library(XLConnect)
library(readxl)
library(xlsx)
library(readxl)
ybi <- read_excel("D:/ii.xls")
#View(ybi)
test= stratified(ybi, 8, .1)

 no= (test$ID_unit) # to get indices of the testdataset samples
 train = ybi [-no,] # the indices for training data 


 write.xlsx(train,"D:/mm.xlsx",sheetName = "Newdata")

in fact my data have 8 attributes and 65534 row. I have selected by the code above just 10% based on the 8 eigth attribute which is the class it gives me without any problm the test set but not the training data ther error is on the figure (joined)error

how to fix it!

  • Where does the error occur? – Roman Luštrik May 17 '17 at 13:06
  • in the last instruction once I would like to write the data into excel file for future use q I have joined the error in the figure I sent ( is there any problm you can not see it !!) here is the error msg : > write.xlsx(train,"D:/mm.xlsx",sheetName = "Newdata") Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.OutOfMemoryError: Java heap space – Mekni Marwa May 17 '17 at 13:11
  • @RomanLuštrik It seems to be strange since the code is okey and the testing samples it gives me the excel file without any problm but for the 90% of training no excel file ( I suppose maybee it s due to the size !! 10% of 65534 row would be for test and it s okey ( I could be imported without pblm into excel) but not the case for the rest of the data : training samples . – Mekni Marwa May 17 '17 at 13:24
  • Please do not use comments to dump code/output. Edit your question and incorporate all the necessary information you think will help others help you solve the problem. In other words, make your example [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Roman Luštrik May 17 '17 at 13:51

1 Answers1

0

It looks like you JVM has no enough memory allocated for the heap.

As a quick fix, export system variable _JAVA_OPTIONS

export _JAVA_OPTIONS="-Xmx8G -Xms1G -Xcheck:jni"

you can also use:

options(java.parameters = "-Xmx8G")

and set -Xmx to a value that will make R happy.

Oo.oO
  • 12,464
  • 3
  • 23
  • 45