r - writeLines() not producing a valid makefile -


i'm trying auto-generate makefile using r, , have run peculiar problem.

the makefile produced using following code:

v <- "histogram.tsv: histogram.r\r\trscript histogram.r" fileconn <- file("makefile") writelines(v,  fileconn) close(fileconn) 

this produces following makefile

histogram.tsv: histogram.r     rscript histogram.r 

this makefile doesn't build, when manually type in tab before "rscript" does! when compare text generated write.lines generated hand, identical() returns true.

it works fine when test on linux mint. it's probable distribution not forgiving when comes carriage return characters, typically used in windows. can try removing carriage return characters or use dos2unix:

in dos/windows text files line break, known newline, combination of 2 characters: carriage return (cr) followed line feed (lf). in unix text files line break single character: line feed (lf). in mac text files, prior mac os x, line break single carriage return (cr) character. nowadays mac os uses unix style (lf) line breaks.

sudo apt-get install dos2unix dos2unix makefile 

in case, you'd need insert newline character, hence set v follows:

v <- "histogram.tsv: histogram.r\n\trscript histogram.r" 

you can try messier way of writing makefile, in order avoid such sort of problems:

target: dependencies; \ command1; \ command2 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -