in reply to Calling R codes from PERL using system coomand

Howdy anikng, and welcome to the Monastery!

I'm not familiar with R, but if you can't use non-core modules, this page suggests that you can invoke R like this to execute commands from a file:

R CMD BATCH /path/to/file.R

Alternatively, there is a module, Statistics::R, to interface R with Perl. So if installing that is an option, you could also do this:

use Statistics::R; my $R = Statistics::R->new(); my $csvfile = "C:/Users/Anil/Desktop/sam.csv"; my @R_commands = ( 'library(gplots)', 'library(RColorBrewer)', "all.data <- read.csv($csvfile)", 'row.names(all.data) <- all.data$sample' 'all.data <- all.data[, -1]' 'data.prop <- all.data/rowSums(all.data)', 'scaleyellowred <- colorRampPalette(c("lightyellow", "red"), space + = "rgb")(100)', 'heatmap(as.matrix(data.prop), Rowv = NA, Colv = NA, col = scaleye +llowred)' ); $R->run(@R_commands); $R->stop();

Totally untested, though.

There's also a ->run_from_file() method if you'd rather read commands from an external file than embedding them in your Perl script.

Replies are listed 'Best First'.
Re^2: Calling R codes from PERL using system coomand
by anikng (Initiate) on Jul 25, 2014 at 01:54 UTC

    Thank u very much AppleFritter.. I will go on with Statistics::R. Your code gave me the idea!!! anikng, ROK