Hello,

I am learning how to use functions, but I'm running into a roadblock.

I would like my function to do two things: 1) convert an object to a
dataframe, 2) and then subset the dataframe. Both of these commands work
fine outside the function, but I would like to wrap them in a function so I
can apply the code iteratively to many such objects.

Here's what I wrote, but it doesn't work:

convert<-function(d) {
 d<-data.frame(d); #convert object to dataframe
 d<-subset(d,select=c(time,coords.x1,coords.x2)) #select some columns
}
convert(data) #the problem is that "data" is the same as it was before
running the function

The objects being processed through my function are SpatialPointsDataFrames
but I'm quite sure that's not my problem, as I can process these outside of
the function (using the above code) ... it's when I try to wrap the code in
a function that it doesn't work.

Thanks, Mark

	[[alternative HTML version deleted]]


