my $R = Statistics::R->new(); $R->set( 'filenames', \@filenames ); $R->set( 'id', $id ); $R->set( 'par1', $par1 ); $R->set( 'par2', $par2 ); $R->run_from_file( "genoplot_by_id.build_df.R" ); $R->run_from_file( "genoplot_by_id.build_plot.R" ); $R->run( qq`setwd("$plot_dir")` ); $R->run( qq`ggsave( filename = paste("$plot_path", "$plot_format", sep = "."), plot = geno.plot, width = $plot_width, height = $plot_height)` );