[R] looping with paste

Juta Kawalerowicz juta.kawalerowicz at stx.ox.ac.uk
Mon Aug 22 22:29:22 CEST 2011


Dear list, 

I have a spacialPolygonDataFrame where variables were unnecessarily imported as factors. So I am trying to unfactor variables from spatialPolygonDataFrame at data with a loop

 
for (i in (1:length(names( spatialPolygonDataFrame)))){
	
	
command<-paste("spatialPolygonDataFrame$names(spatialPolygonDataFrame at data[",i,"])<-as.character( spatialPolygonDataFrame$names( spatialPolygonDataFrame at data[",i,"])")
command<-noquote(command)
command
	
}


But I keep getting just a printout

spatialPolygonDataFrame$names(spatialPolygonDataFrame at data[ 1 ])<-as.character(spatialPolygonDataFrame$names(spatialPolygonDataFrame at data[ 1 ])
spatialPolygonDataFrame$names(spatialPolygonDataFrame at data[ 2 ])<-as.character(spatialPolygonDataFrame$names(spatialPolygonDataFrame at data[ 2 ])
spatialPolygonDataFrame$names(spatialPolygonDataFrame at data[ 3 ])<-as.character(spatialPolygonDataFrame$names(spatialPolygonDataFrame at data[ 3 ])

and so on

Could somebody suggest why it's not working?
Thanks, 
Juta


More information about the R-help mailing list