[R] unable to carry through object in a nested function

Chen, George George.Chen at roswellpark.org
Thu Jan 23 04:36:24 CET 2014

Hi There,
I am having trouble carrying through an object listed in the outer function into the inner function of a nested pair.
This is my code:

FindGreaterThanProportion<- function (y, SSThreshold) {
    return (PropCells)

GetPropPlot<- function (PrePropData, direction, SSThreshold, cell, stim) {
    # Split up the dataframe with ddply and apply the function
    print (SSThreshold)

    if (direction==">") {
        PropData<-ddply(PrePropData,.(SUBJECT, STIM, CELL, SIGNAL, DAY), summarise,
            PROP=FindGreaterThanProportion(SIMSCORE, SSThreshold))

    PlotSubset <- subset(PropData, PropData$STIM==stim & PropData$CELL == cell)
    PropPlot<-ggplot(data=PlotSubset, aes(x=DAY, y=PROP)) +
        geom_line() +
        geom_point() +

When I run the code, I get this error:
[1] ">"
[1] 2
Error in subset.default(y, y > SSThreshold) :
  object 'SSThreshold' not found

It seems as if SSThreshold is not being passed into FindGreaterThanProportion.

Any help would be appreciated to determine what I am doing incorrectly.
Thanks in advance.

George Chen

This email message may contain legally privileged and/or confidential information.  If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited.  If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you.

More information about the R-help mailing list