After executing R code in a note, attempting to select or manipulate data frames results in the could not find function '_tam_restoreRObjectOnSession' error

Symptoms

After executing R code in a note, attempting to select or manipulate dataframes results in the following error:

Error: could not find function "_tam_restoreRObjectOnSession"

Root Cause

This error occurs when using the global object removal command within R code:

rm(list = ls())

This command inadvertently deletes critical functions and objects that the note environment uses internally for session management, causing the session restoration functionality to break down.

Solutions

Permanent Solution

  • Avoid using rm(list = ls()) in R code within notebooks
  • If you need to remove specific objects, target them individually:
    # Good practice: Remove specific objects only
    rm(object1, object2)
    
    # Bad practice: Remove all objects (causes the error)
    rm(list = ls())
    
  • After making the above change, re-open the project to start a new session.