[R] creating a function

jiho.han jiho.han at yahoo.com
Tue Apr 17 02:19:01 CEST 2007

Dear R-experts,

This should be a simple question, but I couldn't find a way yet. 
I would like to create a function that accepts a vector, creates a
data.frame whose colname is that vector. For example, I want a function
temp.func() such that:

>name = c( "mike", "john", "steve")
>result = temp.func(name)
> result
1       mike
2       john
3      steve

Right now I have the following code:

temp.func = function (x) {
    x = as.data.frame(x)

The problem is, the above function returns the colname, "factor(x)," which
is not "name." Anyone has Any idea? 

Lastly, I would like to thank everyone in this forum who helped me on
anything I asked abour R. I really appreciate your help. Thank you. 

View this message in context: http://www.nabble.com/creating-a-function-tf3588133.html#a10027287
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list