[R] conditional replacement - readLines

Christian Schulz ozric at web.de
Fri Nov 26 09:58:10 CET 2004


Hi,

i have list with 2575  cgi files which i have read with readLines - all 
Lines have the type "chr".
Now i want replace the 2. line with a condition in 4. line and  write  
the files back  to dir.

How i could avoid the incompatible problem, or is it better
doing something with awk!?

 for (i in 1:2575){
datenrep <- 
ifelse(daten[[i]][4]=="type,1",cat(substr(as.character(paste(daten[[i]][2])),1,5),as.character(100)
,substr(as.character(paste(daten[[i]][2])),6,12),sep=""),daten[[i]][2])}
lfdn,1001081Error in "[<-"(`*tmp*`, test & !nas, value = NULL) :
        incompatible types

many thanks, christian




More information about the R-help mailing list