Hi all,

I've been having trouble with something that seems like it should be
fairly straight forward. Any help at all from more experienced users is
appreciated!

 

I'd like to write a function that uses a column name as an argument.
However, I run into problems when I try to reference this column within
the function.

For example,

 

findCutoff <- function(tableName, columnName) {

 

                temporaryTable <- subset(tableName, select = c(V1, V4,
columnName))

 

                x <- length(tableName$columnName [tableName$columnName >
6] )

 

                ...etc.

}

 

I know a couple of ways to reference a column: 

1.       tableName$columnName

2.       tableName[["columnName"]]

I tried turning the function arguments into a string like
"tableName$columnName" to use within my function, but unfortunately that
didn't work. With the second method I run into problems if I want to
compute something like x in the example function above.

 

Any ideas, suggestions to try?

 

Thanks in advance for any responses!

 

YunHui Lisa Lin
Intern, Customer Intelligence & Web Analytics

Moody's Corporation
yunhui.lin@moodys.com <mailto:heather.andrews@moodys.com>  

 


-----------------------------------------
The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission. If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited. If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments. Thank you. Every effort is made to keep our network free from viruses. You should, however, review this e-mail message, as well as any attachment thereto, for viruses. We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.

	[[alternative HTML version deleted]]

