[R] paste? 'cmd /c c:\\pheno\\whap --file c:\\pheno\\smri --alt 1'
Dear R users, This command works (calling a programm -called whap- with file specifiers etc.): system('cmd /c c:\\pheno\\whap --file c:\\pheno\\smri --alt 1 --perm 500', intern=TRUE) Now I need to call it from a loop to replace the 1 by different number, however I get lost using the quotes: I tried numerous versions of: i-1 system(paste(c('cmd /c c:\\pheno\\whap --file c:\\pheno\\smri --alt, i, --perm 500', sep= )), intern=TRUE) However no luck! I would be gratefull for any help. Thanks, Marco __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] paste? 'cmd /c c:\\pheno\\whap --file c:\\pheno\\smri --alt 1'
On Mon, 2006-09-25 at 18:58 +0200, Boks, M.P.M. wrote: Dear R users, This command works (calling a programm -called whap- with file specifiers etc.): system('cmd /c c:\\pheno\\whap --file c:\\pheno\\smri --alt 1 --perm 500', intern=TRUE) Now I need to call it from a loop to replace the 1 by different number, however I get lost using the quotes: I tried numerous versions of: i-1 system(paste(c('cmd /c c:\\pheno\\whap --file c:\\pheno\\smri --alt, i, --perm 500', sep= )), intern=TRUE) However no luck! I would be gratefull for any help. Thanks, Marco You need to escape the quote () chars in the paste()d string so that they get passed to your command properly. Also, you don't want to use c() within the paste() function, as the paste() function already concatenates the component vectors. Note: i - 1 paste('cmd /c c:\\pheno\\whap --file c:\\pheno\\smri --alt, i, --perm 500', sep=) Error: syntax error in paste('cmd /c c R sees the double quote before the second 'c' as the end of the string: 'cmd /c Now use \ to escape the internal quotes: paste('cmd /c \c:\\pheno\\whap --file c:\\pheno\\smri --alt , i, --perm 500\', sep=) [1] 'cmd /c \c:\\pheno\\whap --file c:\\pheno\\smri --alt 1 --perm 500\' Use '\' to escape each of the double quotes within the string, so that R can differentiate string delimiters versus characters within the string. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] paste? 'cmd /c c:\\pheno\\whap --file c:\\pheno\\smri --alt 1'
Use single outer quotes so that the inner double quotes are not interpreted as the end of the string. cmd - 'cmd /c ...whatever... ' system(cmd, intern = TRUE) On 9/25/06, Boks, M.P.M. [EMAIL PROTECTED] wrote: Dear R users, This command works (calling a programm -called whap- with file specifiers etc.): system('cmd /c c:\\pheno\\whap --file c:\\pheno\\smri --alt 1 --perm 500', intern=TRUE) Now I need to call it from a loop to replace the 1 by different number, however I get lost using the quotes: I tried numerous versions of: i-1 system(paste(c('cmd /c c:\\pheno\\whap --file c:\\pheno\\smri --alt, i, --perm 500', sep= )), intern=TRUE) However no luck! I would be gratefull for any help. Thanks, Marco __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.