Closed tford9 closed 5 years ago
How about running it via terminal or R?
Could you share your Rmarkdown file or provide a minimal example file?
I can confirm this issue on Windows, my entire error reads:
Error in regexpr("\\.([[:alnum:]]+)$", x) : object 'teste.Rmd' not found
Calls: <Anonymous> -> %in% -> tolower -> <Anonymous> -> regexpr
Execution halted
[Finished in 0.8s with exit code 1]
[cmd: ['C:\\Users\\luis.araujo\\Documents\\R\\R-3.5.1\\bin\\x64\\R.exe', '--slave', '-e', 'rmarkdown::render("teste.Rmd", encoding = "UTF-8")']]
[dir: C:\Users\luis.araujo\Downloads]
[path: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\luis.araujo\AppData\Local\Microsoft\WindowsApps;C:\Users\luis.araujo\AppData\Local\Programs\Git\cmd;C:\Users\luis.araujo\AppData\Local\Pandoc\;C:\Users\luis.araujo\Documents\R\R-3.5.1\bin\x64]
I can´t figure out what is going on here. As per your question to @tford9 it works as expected on Terminus:
> rmarkdown::render("teste.Rmd", encoding = "UTF-8")
processing file: teste.Rmd
|.................................................................| 100%
ordinary text without R code
output file: teste.knit.md
"C:/Users/LUIS~1.ARA/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS teste.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output teste.html --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\luis.araujo\Documents\R\R-3.5.1\library\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\LUIS~1.ARA\AppData\Local\Temp\Rtmp8swhBi\rmarkdown-str126867b33c9c.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --metadata pagetitle=teste.utf8.md
Output created: teste.html
For contents:
# Title
Contents.
@tford9 were you able to find a solution to this?
@lf-araujo
is file located at C:\Users\luis.araujo\Downloads\teste.Rmd
?
I just recreated it at that folder, error persists as previous post. The folder it is saved in does not matter, as it will fail on Windows. R-ide works perfectly on Ubuntu, so it seems to be system specific.
I think this is the class responsible for running render, it seems ok, I can´t identify the problem:
class RideRenderRmarkdownCommand(sublime_plugin.WindowCommand):
def is_enabled(self):
view = self.window.active_view()
return view.settings().get("syntax").endswith("R Markdown.sublime-syntax")
def run(self, kill=False):
cmd = "rmarkdown::render(\"$file_name\", encoding = \"UTF-8\")"
cmd = sublime.expand_variables(cmd, self.window.extract_variables())
kwargs = {}
kwargs["cmd"] = [ride_settings.r_binary(), "--slave", "-e", cmd]
kwargs["working_dir"] = os.path.dirname(self.window.active_view().file_name())
kwargs["env"] = {
"PATH": ride_settings.custom_env("PATH"),
"LANG": ride_settings.get("lang", "en_US.UTF-8")
}
kwargs["kill"] = kill
self.window.run_command("exec", kwargs)
It seems to me that Sublime Text is treating the command as
rmarkdown::render(teste.Rmd, encoding = UTF-8)
without the quotations, that's why the object teste.Rmd
was not found.
Yep, this is what it looks like.
I tried to use $file
or wrap that section in single quotes to no avail.
I am beginning to think the problem is in Sublime.
It seems that single quotes would work.
I think this is related to how sublime text expands file paths in windows, is there some property that I can pass to the python library to signal that the command should be run in a windows environment?
The error I get when I run it with single quotes is:
Error: '\P' is an unrecognized escape in character string starting "'Y:\P"
Execution halted
[Finished in 2.6s]
Because the path is something like Y:\Projects\data
But '$file_name'
should be just the file name without the folder.
It solves the problem, I must have it set to $file
at some point. It is now working normally under Windows.
Can I ask you randy, how you inspect the objects in memory while working with R?
I use a small function I found on SO, which lists the objects and their size in memory:
# improved list of objects
.ls.objects <- function (pos = 1, pattern, order.by,
decreasing=FALSE, head=FALSE, n=5) {
napply <- function(names, fn) sapply(names, function(x)
fn(get(x, pos = pos)))
names <- ls(pos = pos, pattern = pattern)
obj.class <- napply(names, function(x) as.character(class(x))[1])
obj.mode <- napply(names, mode)
obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class)
obj.prettysize <- napply(names, function(x) {
format(utils::object.size(x), units = "auto") })
obj.size <- napply(names, object.size)
obj.dim <- t(napply(names, function(x)
as.numeric(dim(x))[1:2]))
vec <- is.na(obj.dim)[, 1] & (obj.type != "function")
obj.dim[vec, 1] <- napply(names, length)[vec]
out <- data.frame(obj.type, obj.size, obj.prettysize, obj.dim)
names(out) <- c("Type", "Size", "PrettySize", "Length/Rows", "Columns")
if (!missing(order.by))
out <- out[order(out[[order.by]], decreasing=decreasing), ]
if (head)
out <- head(out, n)
out
}
# shorthand
lsos <- function(..., n=10) {
.ls.objects(..., order.by="Size", decreasing=TRUE, head=TRUE, n=n)
}
Which looks like:
> lsos()
Type Size PrettySize Length/Rows Columns
elders data.table 729451712 695.7 Mb 2893779 47
in.f data.frame 473696 462.6 Kb 1833 45
a character 4888 4.8 Kb 1 NA
project.info list 3008 2.9 Kb 1 NA
config list 2728 2.7 Kb 16 NA
schedule character 888 888 bytes 1 NA
I am not sure what you want to achieve, but there is https://www.rdocumentation.org/packages/pryr/versions/0.1.4/topics/object_size
which is not more robust.
What I want is a simple way of reproducing an Environment panel from RStudio, using r-ide:
I see. It's going to be a difficult task.
[...] single quotes would work
and
[...] '$file_name' should be just the file name without the folder.
solved this problem for me as well, also when not using REditorSupport, but Git Bash and (a) make(file) on Windows:
README=README.Rmd
README.md: ${README}
Rscript -e "rmarkdown::render('$<')"
Thank you so much for sharing this error and its solution, @randy3k & @tford9 :-)
Hello,
I know this ticket id closed.
But I got the same issus.
I found this:
rmarkdown::render('teste.Rmd', encoding = 'UTF-8')
Rscript -e "rmarkdown::render('teste.Rmd', encoding = 'UTF-8')"
While attempting to Knit a markdown file I'm receiving this error: