Re: [R] Please help with a basic function

2009-12-11 Thread Don MacQueen
At 8:19 AM -0600 12/11/09, Mark Na wrote: 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 w

Re: [R] Please help with a basic function

2009-12-11 Thread Mark Na
Many thanks for the replies to my call for help this morning. I didn't know about return() and that helped quite a bit. Best, Mark On Fri, Dec 11, 2009 at 10:00 AM, Paul Hiemstra wrote: > Hi Mark, > > This question would probably be better suited for the r-sig-geo mailing > list. In addition, pl

Re: [R] Please help with a basic function

2009-12-11 Thread Paul Hiemstra
Hi Mark, This question would probably be better suited for the r-sig-geo mailing list. In addition, please read the posting guide and provide a piece of code that reproduces the problem. library(sp) convert<-function(d) { d<-data.frame(d); #convert object to dataframe d<-subset(d,select=c(zi

Re: [R] Please help with a basic function

2009-12-11 Thread Ista Zahn
Hi Mark, You're on the right track. You just need your function to return dataframe. Try convert<-function(d) { d<-data.frame(d); #convert object to dataframe d<-subset(d,select=c(time,coords.x1,coords.x2)) #select some columns return(d) } -Ista On Fri, Dec 11, 2009 at 9:19 AM, Mark Na wrote: