dear members,
I have some functions which are read only in Rstudio environment. I tried to edit them with fix() but fix() is not working properly. It is working fine with small functions but for larger ones it is truncating certain lines, especially the topmost ones. Any help will be greatly appreciated. I am using RStudio 2021.09.2 BUILD 382
THanking you,
Yours sincerely,
AKSHAY M KULKARNI
how long is your long function? I tested my setup and can see all lines of a 10000 line long function...
make_a_func <- function(this_long){
paste0("function(){",paste0(rep("print('another line')",this_long),collapse = "\n"),"}")
}
my_long_func <- eval(parse(text=make_a_func(10000)))
my_long_func()
fix(my_long_func)
dear nirgrahamuk,
I am uploading fix(my_long_func). The top lines are not showing. Please help.....Also how to edit when in fix()? I am not able to edit in the editor...
Thanking you,
Yours sincerely,
AKSHAY M KULKARNI
what do you get when you run
.Options$editor
I get:
.Options$editor
function (name, file = "", title = file, ...)
{
if (missing(name) || is.null(name))
return(.Call("rs_editFile", file, PACKAGE = "(embedding)"))
if (is.null(file) || !nzchar(file)) {
file <- tempfile("rstudio-scratch-", fileext = ".R")
on.exit(unlink(file), add = TRUE)
}
deparsed <- if (is.function(name))
.rs.deparseFunction(name, useSource = TRUE, asString = FALSE)
else deparse(name)
writeLines(deparsed, con = file)
.Call("rs_editFile", file, PACKAGE = "(embedding)")
eval(parse(file), envir = globalenv())
}
<environment: 0x000001fded09c4e0>
Dear nirgrahamuk,
I am getting the following:
.Options$editor
function (name, file = "", title = file, ...)
{
if (missing(name) || is.null(name))
return(.Call("rs_editFile", file, PACKAGE = "(embedding)"))
if (is.null(file) || !nzchar(file)) {
file <- tempfile("rstudio-scratch-", fileext = ".R")
on.exit(unlink(file), add = TRUE)
}
deparsed <- if (is.function(name))
.rs.deparseFunction(name, useSource = TRUE, asString = FALSE)
else deparse(name)
writeLines(deparsed, con = file)
.Call("rs_editFile", file, PACKAGE = "(embedding)")
eval(parse(file), envir = globalenv())
}
<environment: 0x000001e8b065a210>
looks the same; sorry I'm out of ideas.
system
Closed
February 17, 2023, 3:06pm
7
This topic was automatically closed 42 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.