[R] Using R to create pdf's from each file in a directory

Robert A LaBudde ral at lcfltd.com
Sat Apr 21 05:06:53 CEST 2007

At 09:40 PM 4/20/2007, gecko951 wrote:
>list <- dir("/tmp/data")
>for(x in list){
>d <- read.table(x, sep="\t", header=TRUE) # read data
>pdf("/tmp/graph/x.pdf")                              # file for graph

I'm a tyro at R, but it's obvious here that the line


has the intended file name string 'x' embedded with the literal 
string enclosed in quotation marks. Obviously he needs "/tmp/graph/" 
string concatenated with x and then ".pdf".

I would suggest a fix, but I am unable to find in the documentation 
how to concatenate two strings into a single string.

So I will amplify gecko951's question to include "How you you 
concatenate two strings in R?". I.e.,


What operator or function returns "abcdef" as a result?


Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: ral at lcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"

More information about the R-help mailing list