Re: [R] Error "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
Fascinating and, as ever, extremely helpful Ivan. Duncan Murdoch nudged me in the right direction and for now the solution for me is that if I don't have the lines: description: | CE's pages "blog posts" about using R in _site.yaml that have been there for ages, then everything works. If I put _anything_ in there, including two lines copied and pasted from a brand new distill site instead of those two lines then the error returns so I think something else is awry in my main distill site that has rendered the knitting of the site allergic to having a description in _site.yaml. I should probably go further to try to debug this but across this and the trouble I was having with the mirror.infomaniak.ch ubuntu mirror (R-sig-Debian thread, another you helped with, has details of that!) I have lost too much time debugging in the last week and desperately need to get back to my main work (and work I'm more competent to do!) Many thanks again, Chris On 25/08/2023 15:48, Ivan Krylov wrote: В Fri, 25 Aug 2023 11:49:03 +0200 Chris Evans via R-help пишет: Hm. I tried that butI really don't know what to make of what it's telling me. It seemed to me that I was just stepping through the same bits of code (with the warning that the debugger didn't have the source so I'm not really sure what it was showing me!) write_feed_xml is an internal function in the "distill" package. It's supposed to create the RSS feed for a whole set of web pages. Somehow it ends up trying to assign a list to xml2::xml_text(some_xml_node), where only assigning a character string would make sense. The function contains quite a lot of assignments like this. Some of them come from site_config (which comes from _site.yml?), others are taken from the article contents and metadata. If you run options(error = recover) in a fresh R session before knitting your website, you should get a debugger menu right at the point where the code crashes. Try to find out what is the XML node where the text is being assigned and what is the list that ends up being assigned into it. You will also get the option to see the variables in the callers of the failing function, which may shed some light on the situation too. -- Chris Evans (he/him) Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor, University of Roehampton, London, UK. Work web site: https://www.psyctc.org/psyctc/ CORE site: http://www.coresystemtrust.org.uk/ Personal site: https://www.psyctc.org/pelerinage2016/ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
В Fri, 25 Aug 2023 11:49:03 +0200 Chris Evans via R-help пишет: > Hm. I tried that butI really don't know what to make of what it's > telling me. It seemed to me that I was just stepping through the > same bits of code (with the warning that the debugger didn't > have the source so I'm not really sure what it was showing me!) write_feed_xml is an internal function in the "distill" package. It's supposed to create the RSS feed for a whole set of web pages. Somehow it ends up trying to assign a list to xml2::xml_text(some_xml_node), where only assigning a character string would make sense. The function contains quite a lot of assignments like this. Some of them come from site_config (which comes from _site.yml?), others are taken from the article contents and metadata. If you run options(error = recover) in a fresh R session before knitting your website, you should get a debugger menu right at the point where the code crashes. Try to find out what is the XML node where the text is being assigned and what is the list that ends up being assigned into it. You will also get the option to see the variables in the callers of the failing function, which may shed some light on the situation too. -- Best regards, Ivan __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
On 24/08/2023 21:05, Duncan Murdoch wrote: On 24/08/2023 1:58 p.m., Chris Evans via R-help wrote: I have an Rmarkdown file which is part of my distill "Rblog" (https://www.psyctc.org/Rblog/). It was knitting fine until last week, now knitting terminates with this: Rscript -e 'rmarkdown::render("creating-a-shiny-server.Rmd")' processing file: creating-a-shiny-server.Rmd output file: creating-a-shiny-server.knit.md /usr/bin/pandoc +RTS -K512m -RTS creating-a-shiny-server.knit.md --to html5 --from markdown+autolink_bare_uris+tex_math_single_backslash --output creating-a-shiny-server.html --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/chris/R/x86_64-pc-linux-gnu-library/4.3/rmarkdown/rmarkdown/lua/latex-div.lua --wrap preserve --standalone --table-of-contents --toc-depth 4 --variable toc-float=1 --highlight-style /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/arrow.theme --template /home/chris/R/x86_64-pc-linux-gnu-library/4.3/distill/rmarkdown/templates/distill_article/resources/default.html '--metadata=link-citations:true' --include-in-header /tmp/Rtmp7WHAIE/fileb39b179ffd801html --include-in-header /tmp/Rtmp7WHAIE/fileb39b15b1e3532html --include-in-header /tmp/Rtmp7WHAIE/fileb39b13239652chtml --include-in-header /tmp/Rtmp7WHAIE/fileb39b1581627e8html --include-in-header /tmp/Rtmp7WHAIE/fileb39b12850a405html --include-before-body /tmp/Rtmp7WHAIE/fileb39b16f8d72a6html --include-before-body /tmp/Rtmp7WHAIE/fileb39b16ce17d77html --include-before-body /tmp/Rtmp7WHAIE/fileb39b12f851f86html --include-after-body /tmp/Rtmp7WHAIE/fileb39b14447b7b1html --include-after-body /tmp/Rtmp7WHAIE/fileb39b143ff6632html --include-after-body /tmp/Rtmp7WHAIE/fileb39b1345b1dddhtml --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/Rtmp7WHAIE/rmarkdown-strb39b160f391de.html --include-in-header /tmp/Rtmp7WHAIE/fileb39b164361476html Error in `xml_text<-.xml_node`(`*tmp*`, value = text) : STRING_ELT() can only be applied to a 'character vector', not a 'list' Calls: ... write_feed_xml -> add_child -> -> xml_text<-.xml_node In addition: There were 20 warnings (use warnings() to see them) Execution halted That function `xml_text<-.xml_node` is in the xml2 package, which was updated in early July. Do you think the error has been happening since you updated your copy, or did something else trigger it? I wish I had good clues from that. Everything with the "blog" was working fine until the 21st. Since then (yesterday) I have fixed an issue (down to the mirror.infomaniak.ch server I was using) that had meant a lot of my Ubuntu packages were out of date but this problem started before I fixed that, by the 23rd. I update the OS daily (but that wasn't working for deb packages until yesterday because of the mirror problem) and I also R packages daily but I don't watch what updates and what doesn't. I guess I could put that on a cron job with an Email to self to keep track of it in future. One way to debug this is as follows. With the file in the directory where the error occurs, start R (or RStudio, it shouldn't matter), and run debug(xml2:::`xml_text<-.xml_node`) rmarkdown::render("creating-a-shiny-server.Rmd") If you're lucky, the error will happen on the first call to that function, and you can trace into it to see what's so weird. If you're unlucky, it will happen after many calls. Then you'll probably have to use trace() to identify which call causes problems (increment and print a counter on each call), then break just before the bad call and try to see what went wrong. Hm. I tried that butI really don't know what to make of what it's telling me. It seemed to me that I was just stepping through the same bits of code (with the warning that the debugger didn't have the source so I'm not really sure what it was showing me!) Sorry, showing my ignorance of that level of R debugging. Can you give me any more advice about that? Or perhaps _if_ the code does give the same error for you, you'd be able to see quickly what I can't? Deeply grateful for the help and sorry I'm not up to scratch on my side. I'd really appreciate any other thoughts as I'm stuck with the blog for now! Chris Duncan Murdoch [rest snipped] -- Chris Evans (he/him) Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor, University of Roehampton, London, UK. Work web site: https://www.psyctc.org/psyctc/ CORE site: http://www.coresystemtrust.org.uk/ Personal site: https://www.psyctc.org/pelerinage2016/ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal,
Re: [R] Error "STRING_ELT() can only be applied to a 'character vector', not a 'list'" from rmarkdown
Thanks Duncan. I've pushed the whole collection to: https://github.com/cpsyctc/Rblog On 24/08/2023 20:54, Duncan Murdoch wrote: Could you post a link to the source for that Rmd file? Duncan Murdoch [rest snipped] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.