last.call
पैकेज Cran पर नहीं रह गया है, लेकिन आप अभी भी कोड प्राप्त कर सकते हैं:
# -----------------------------------------------------------------------
# FUNCTION: last.call
# Retrieves a CALL from the history and returns an unevaluated
# call.
#
# There are two uses for such abilities.
# - To be able to recall the previous commands, like pressing the up key
# on the terminal.
# - The ability to get the line that called the function.
#
# TODO:
# - does not handle commands seperated by ';'
#
# -----------------------------------------------------------------------
last.call <-
function(n=1) {
f1 <- tempfile()
try(savehistory(f1), silent=TRUE)
try(rawhist <- readLines(f1), silent=TRUE)
unlink(f1)
if(exists('rawhist')) {
# LOOK BACK max(n)+ LINES UNTIL YOU HAVE n COMMANDS
cmds <- expression()
n.lines <- max(abs(n))
while(length(cmds) < max(abs(n))) {
lines <- tail(rawhist, n=n.lines)
try(cmds <- parse(text=lines), silent=TRUE)
n.lines <- n.lines + 1
if(n.lines > length(rawhist)) break
}
ret <- rev(cmds)[n]
if(length(ret) == 1) return(ret[[1]]) else return(ret)
}
return(NULL)
}
अब, यह उपयोग करने के लिए:
sum(1, 2)
# [1] 3
last.call(2)
# sum(1, 2)
[सचमुच गूगल पर पहले हिट जब मैं टाइप किया "आर अंतिम कॉल"] (http://www.inside-r.org/packages/cran/last.call/docs/last.call) – shadowtalker
तो इसे उत्तर के रूप में पोस्ट करें –
@ माइकवाइज मुझे लगता है कि उनका मुद्दा यह है कि ओपी को पहले स्टॉप होने के बजाय उत्तर स्रोत करने का प्रयास करना चाहिए था। –