What was the line of code?
If you're editing a text file, like an .Rmd or .R script, undoing typing is the same as with any text editor, just ctrl+z.
The R console works a bit differently. The console is the place where R is waiting for you to tell it what to do, and where it will show the results of a command. So to undo a command giving to the console you have to provide a command that undoes it. For example, below I assign 1 to a, and then undo that.
a <- 1
a
#> [1] 1
rm(a)
a
#> Error in eval(expr, envir, enclos): object 'a' not found
Created on 2022-02-09 by the reprex package (v2.0.0)
For more information about the console, check out RStudio's docs.