[R] Data Manipulation

Peter Rote r.rote12 at googlemail.com
Thu Jan 21 02:19:42 CET 2010


Thank you Dieter, 

but i  still have a problem to write to file. The problem is the slash in
file names (Aerospace/Defense Products & Services ). If i want  it to C:/ab/
so "C:/ab/AdvertisingAgencies.txt" is ok but
"C:/ab/Aerospace/Defense-MajorDiversified.txt" is not

> head(AlexETF)
                        AlexETF.Industry         AlexETF.Ticker
1    Scientific & Technical Instruments                     A
2                              Aluminum                           AA
3                     Business Services                       AAC
4                       Credit Services                       AACC
5                     Regional Airlines                          AAI
6 Aerospace/Defense Products & Services             AAII

> by(AlexETF,AlexETF$Industry,function(a) {filename = paste(gsub("
> ","",a$Industry[1]),".txt",sep="")
+      print(filename)
+      
+    }
+ ) 
[1] "Accident&HealthInsurance.txt"
[1] "AdvertisingAgencies.txt"
[1] "Aerospace/Defense-MajorDiversified.txt"
[1] "Aerospace/DefenseProducts&Services.txt"
[1] "AgriculturalChemicals.txt"
[1] "AirDelivery&FreightServices.txt"



> by(AlexETF,AlexETF$Industry,function(a) {filename = paste("C:/ab/",gsub("
> ","",a$Industry[1]),".txt",sep="")
+      write.table(a,file=filename,col.names = FALSE)     
+    }
+ ) 
Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
  cannot open file 'C:/ab/Aerospace/Defense-MajorDiversified.txt': No such
file or directory



Thanks in advance,

Peter 

-- 
View this message in context: http://n4.nabble.com/Data-Manipulation-tp1018249p1032029.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list