Keras Fit Generator / Python call from R

I am still new to S/O so apologies if this question doesn't meet the standards on the first go.

I am trying to use the Keras package in R (using Tensorflow, Python and Anaconda), calling it for the purposes of using the fit generator function. Within this function it requires using the callback_model_checkpoint function. When I run the following code in RStudio, it seems to work fine, however when I run it in baseline R, it comes up with the error below.

Am using Windows 7 64bit and R 3.4.3.

Sample of my code:

model1 <- keras_model_sequential() %>% layer_flatten(input_shape = c(lookback / step, dim(scaled_dataset)[-1])) %>% layer_dense(units = 32, activation = "relu") %>% layer_dense(units = 1, activation = "sigmoid")

model1 %>% compile(loss = "binary_crossentropy",optimizer = optimizer_rmsprop(),metrics = c('accuracy'))

history1 <- model1 %>% fit_generator(train_gen,steps_per_epoch = 500,epochs = 20,validation_data = val_gen,validation_steps = val_steps,callbacks = callback_model_checkpoint(filepath="best_model1.hdf5",monitor = "val_loss",verbose = 0,mode = "auto",save_best_only = TRUE,period = 1))

best_model1 <- load_model_hdf5("best_model1.hdf5", custom_objects = NULL, compile = TRUE)

Error: [1780] OSError: Unable to create file (unable to open file: name = 'best_model1.hdf5', errno = 13, error message = 'Permission denied', flags = 13, o_flags = 302)

Any help or assistance would be much much appreciated - I am also new to R so might be missing something. Also please let me know if I need to clarify or provide further information

Many thanks