Use get() instead of eval().
And, probably, some arguments are missing in call to paste(). 
Maybe, extension?

That is, 
for(i in test) 
  write.table(get(i),file=paste(i,"txt",sep="."),row.names=FALSE,sep="\t")

If you want file names matching exactly names of your matrices, and being
without extension,
you don't need to call paste() at all:

for(i in test) 
  write.table(get(i),file=i,row.names=FALSE,sep="\t")


Luis Ridao Cruz wrote:
> 
> R-help,
> 
> I have a character vector whose elements are the names of matrixes.
> Something like this:
> 
>> test <- ls(pattern="Oki")
>  [1] "aaOki"    "aOki"     "bOki"     "c1Oki"    "c2Oki"    "c3Oki"   
> "cOki"     "dOki"     "eOki"     "fOki"     "gprsOki"  "hOki"     "iOki"
>    
> [14] "jOki"     "kOki"     "lOki"     "mOki"   ......................
> 
> An example:
> 
>> aaOki
>               x        y
>  [1,] -6.333333 61.41667
>  [2,] -4.833333 61.41667
>  [3,] -4.833333 61.25000
>  [4,] -5.000000 61.25000
>  [5,] -5.000000 61.16667
>  [6,] -5.166667 61.16667
>  [7,] -5.166667 61.00000
>  [8,] -5.333333 61.00000
>  [9,] -5.333333 60.91667
> [10,] -5.500000 60.91667
> [11,] -5.500000 60.83333
> [12,] -5.666667 60.83333
> [13,] -5.666667 60.75000
> [14,] -5.833333 60.75000
> [15,] -5.833333 60.66667
> [16,] -6.000000 60.66667
> [17,] -6.000000 60.50000
> [18,] -6.166667 60.50000
> [19,] -6.166667 61.00000
> [20,] -6.333333 61.00000
> [21,] -6.333333 61.41667
> 
> ..
> ..
> 
> ..
> 
> What I want to do is to export these objects to text files
> by doing:
> 
> for(i in test)
> write.table(eval(i),file=paste(i),row.names=FALSE,sep="\t")
> 
> but it doesn't work.
> 

-- 
View this message in context: 
http://www.nabble.com/exporting-character-vector-to-text-files-tf4157676.html#a11829294
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to