Knit a R Markdown to a HTML

Everything work fine in the RMarkdown file. However when I want to generate an HTML doc, I have an error message. I cannot export my work to HTML. I work with MAC OS Ventura 13.1.

Thank you for your help.
|............ | 22% (setup)

processing file: Cronbach_attitudes.Rmd

Quitting from lines 29-31 (Cronbach_attitudes.Rmd)
Error in eval(expr, envir, enclos) : object 'Invscore230223' not found
Calls: ... withVisible -> eval_with_user_handlers -> eval -> eval
Execution halted

Without more details it is hard to say but it looks like Quarto is executing an R routine and it cannot find a variable Invscore230223.

Does that routine run in a regular R environment.?

I work in R studio Version 2022.12.0+353 (2022.12.0+353).
If I delete the chunks with the object name (i.e. Inyscore230223). I have an HTML output with the following code :
processing file: Cronbach-attitudes.Rmd output file: Cronbach-attitudes.knit.md /Volumes/RStudio-2022.12.0-353/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc +RTS -K512m -RTS Cronbach-attitudes.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output Cronbach-attitudes.html --lua-filter /Library/Frameworks/R.framework/Versions/4.2/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.2/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --variable bs3=TRUE --section-divs --table-of-contents --toc-depth 3 --template /Library/Frameworks/R.framework/Versions/4.2/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /var/folders/5m/qtnn3x_x0pj_yvdbfl65rldw0000gp/T//Rtmp2V3bYn/rmarkdown-str599f3c1e0b1d.html Output created: Cronbach-attitudes.html

However, I have lost all the output of results (i.e. data.frame results). I am sure I miss something when I generate the HTML document to keep the results inside .

Many thanks again for your help.

I think we need to see the actual Quarto file and a sample of your data. You can cut out most of the verbiage but we need the YAMAL and all the coding.

Have a look at this FAQ for some suggestions on setting up a question on the forum. Oh, and I forgot; wercome to the forum.

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.

I have reproduced the same error with other data .frame of a smaller size
[image]

Reliability analysis Call: alpha(x = ALienselect8) 95% confidence boundaries Reliability if an item is dropped: Item statistics Non missing response frequency for each item 1 2 3 4 5 miss sp12.1_catcar 0.01 0.10 0.31 0.46 0.12 0 sp12.2_poscar 0.03 0.12 0.29 0.48 0.08 0 sp13.1_blank 0.15 0.21 0.32 0.14 0.18 0 sp13.2_high 0.04 0.10 0.10 0.24 0.53 0 sp13.3_hide 0.10 0.13 0.21 0.28 0.28 0 sp14.1_door 0.00 0.01 0.10 0.37 0.52 0 sp14.2_comf 0.03 0.10 0.23 0.42 0.22 0 sp14.3_posit 0.00 0.02 0.14 0.58 0.26 0

R Console

Description:df [1 × 9]

raw_alpha

std.alpha

G6(smc)

average_r

S/N

0.7396943 0.739979 0.7584662 0.2623902 2.845843

1 row | 1-6 of 9 columns

data.frame

1 x 9

Description:df [2 × 3]

lower

alpha

upper

Feldt 0.68 0.74 0.79 Duhachek 0.69 0.74 0.79

2 rows

data.frame

2 x 3

Description:df [8 × 8]

raw_alpha

std.alpha

G6(smc)

average_r

sp12.1_catcar 0.7180825 0.7155844 0.7167961 0.2643954 sp12.2_poscar 0.7154898 0.7112740 0.7137970 0.2603152 sp13.1_blank 0.7121261 0.7179291 0.7197110 0.2666478 sp13.2_high 0.7169390 0.7189509 0.7414520 0.2676366 sp13.3_hide 0.6665296 0.6813416 0.6863384 0.2339812 sp14.1_door 0.7432156 0.7475503 0.7626963 0.2972724 sp14.2_comf 0.7022847 0.6992253 0.7178810 0.2493095 sp14.3_posit 0.7173272 0.7104707 0.7265446 0.2595634

8 rows | 1-5 of 8 columns

data.frame

8 x 8

Description:df [8 × 7]

n

raw.r

std.r

r.cor

r.drop

sp12.1_catcar 200 0.5539647 0.5866364 0.5238638 0.4086515 sp12.2_poscar 200 0.5684598 0.6046226 0.5448943 0.4234212 sp13.1_blank 200 0.6523850 0.5767074 0.5157300 0.4539616 sp13.2_high 200 0.6070177 0.5723482 0.4620953 0.4202450 sp13.3_hide 200 0.7767512 0.7207093 0.7040112 0.6288032 sp14.1_door 200 0.3729868 0.4417068 0.2906518 0.2354531 sp14.2_comf 200 0.6384159 0.6531387 0.5836499 0.4886319 sp14.3_posit 200 0.5502944 0.6079368 0.5239009 0.4349025

8 rows | 1-6 of 7 columns

data.frame

8 x 7

Description:df [8 × 7]

n

raw.r

std.r

r.cor

r.drop

mean

sd

sp12.1_catcar 200 0.5539647 0.5866364 0.5238638 0.4086515 3.565 0.8829911 sp12.2_poscar 200 0.5684598 0.6046226 0.5448943 0.4234212 3.475 0.8963213 sp13.1_blank 200 0.6523850 0.5767074 0.5157300 0.4539616 2.995 1.2974560 sp13.2_high 200 0.6070177 0.5723482 0.4620953 0.4202450 4.125 1.1645410 sp13.3_hide 200 0.7767512 0.7207093 0.7040112 0.6288032 3.490 1.3032237 sp14.1_door 200 0.3729868 0.4417068 0.2906518 0.2354531 4.395 0.7222070 sp14.2_comf 200 0.6384159 0.6531387 0.5836499 0.4886319 3.710 1.0104479 sp14.3_posit 200 0.5502944 0.6079368 0.5239009 0.4349025 4.065 0.7164787

8 rows

[image][image][image]

[image]

structure(list(region = c("Northland", "Eastland", "Northland", "Northland", "Northland", "Northland"), subject = c(1, 2, 3, 4, 5, 6), name = c("Monita", "Lahoma", "Jalise", "Malon", "Marryn", "Anila"), colour = c("purple", "purple", "green", "purple", "purple", "red"), sex = c("male", "male", "male", "female", "female", "female" ), drives = c("Jetta", "Mustang", "Malibu", "C1500 Suburban 2Wd", "Toyota Tacoma 4Wd", "Passat"), age = c(13.71, 7.29, 7.41, 18.47, 7.73, 11.82), health = c("slightly spotty", "slightly spotty", "healthy", "healthy", "slightly spotty", "slightly spotty"), glucose = c(16.72, 14.94, 15.51, 12.38, 11.41, 13.38), iron = c(NA, 32.9, 23.2, 20.9, 22.4, NA), IQ = c(497, 518, 403, 454, 403, 503), weight = c(102.92, 93.73, 94.14, 106.66, 78.96, 86.19 ), sp12.1_catcar = c(3, 4, 3, 3, 3, 2), sp12.2_poscar = c(2, 4, 3, 1, 2, 3), sp13.1_blank = c(3, 3, 5, 3, 2, 1), sp13.2_high = c(5, 5, 5, 4, 2, 2), sp13.3_hide = c(1, 2, 5, 1, 2, 2), sp14.1_door = c(4, 5, 4, 3, 3, 3), sp14.2_comf = c(4, 4, 4, 4, 3, 3), sp14.3_posit = c(3, 4, 4, 4, 4, 4), sp14.4_reward = c(3, 5, 4, 2, 2, 1), sp14.5_freely = c(3, 4, 5, 2, 3, 5), sp14.6_feliway = c(2, 1, 5, 1, 3, 1), sp15.2_wrap = c(3, 3, 4, 2, 4, 3), sp15.3_chemuse = c(3, 3, 3, 1, 1, 2), sp16.1_abort = c(4, 3, 4, 4, 3, 3), sp16.2_gaba = c(4, 4, 4, 3, 3, 3), sp17.1_air = c(3, 1, 4, 1, 4, 1), sp14.7_invstart = c(5, 5, 5, 4, 3, 5)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

We really need to see what you are doing. For example here is a very simple .qmd file. I don't have a .rmd one handy .

---
title: "Authoring"
author: "Anon."
date: 2020-02-22
date-format: iso
number-sections: true
format: pdf
header-includes:
  - \usepackage{lipsum}
editor: visual
---

```{r}
#| label: setup
#| include: false
library(tidyverse); library(kableExtra); library(lubridate); library(janitor);
library(readODS)
x <- 1:5
dat1  <- data.frame(xx = 1:5, yy = 5:1)

Introduction {#sec-introduction}

Roses are \textcolor{red}{red}, violets are \textcolor{blue}{blue}.

#| echo: false
#| label: fig-silly.plot
#| fig-cap: Amazingly Useless Plot.
ggplot(dat1, aes(xx, yy)) + geom_line(aes(colour = "red"), show.legend = FALSE)

However if r x[5] roses and 1 violet are enough, we should be fine.

\lipsum[6]

I am sorry to be so incompetent in R but I am a beginner. Here is the YAML code of what I have done in RMarkdown :slight_smile: ---
title: "Alien_data_test"
author: "AnneClaude Griesser"
date: "2023-02-25"
output: html_document

knitr::opts_chunk$set(echo = TRUE)

Create a subset of data

Alienselect<- c("sp12.1_catcar","sp12.2_poscar", "sp13.1_blank", "sp13.2_high", "sp13.3_hide", "sp14.1_door", "sp14.2_comf", "sp14.3_posit")
ALienselect8 <- aliendata_20230225[Alienselect]
alpha(ALienselect8)
dput(head(aliendata_20230225))

Some things are user-friendly. R is beginner-hostile.

The problem is here

ALienselect8 <- aliendata_20230225[Alienselect]

should read

ALienselect8 <- aliendata_20230225[  , Alienselect]

In the format dat[ , xx] you are telling R that you want to select all rows of the columns in xx. dat[ 1, xx ] says you want the first row.

For dput() you want to copy the output and paste it here. See example below.

dput(dat2)
structure(list(A = c(0L, 0L, 0L, 0L, 1L), B = c(0L, 1L, 1L, 93L, 
42L), C = c(965L, 3L, 313L, 15L, 2L), D = c(0L, 0L, 0L, 21L, 
34L), E = c(0L, 0L, 0L, 46L, 109L)), row.names = c(NA, 5L), class = "data.frame")

Many thanks for having found out my error and for me giving an example. However, I don't understand what this has to do with the problem when I generate an R markdown that aborts indicating that it doesn't know an object data.frame

  • what this has to do with the problem *
    Well the .rmd file will not compile with that error.

Without a (semi) working example of your Rmarkdown file and some sample data we really cannot do much.

If you take my .qmd example above and drop it into an empty .qmd file you should be able to compile it. We need a copy your equivalent file.

Thank you very much for your help. I am conscious that I am lost and what is very obvious and simple for you seems insurmontable to me. I am convinced that a copy of my file would be of great help. Unfortunately, I did not succeed in reproducing your example. I am sorry and I propose that we leave at that. Many thanks again for your help and support.

Okay, sorry not to be of more help.

Usually this error comes from when a R variable is not available to R Markdown process. Where is Invscore230223 loaded or defined in your Rmd file ?

I can't see it your example in the posts after ...

Same question: Where is the data loaded or created ? Is this correctly done inside your Rmd file ?

When you click Knit / Render on a document in R Studio IDE, it will open a new clean R session and render the document. This means that all your data and any variable needs to be defined inside the Rmd file. You can't rely on variable already available in your R session that would have been loaded otherwise - this could work when working interactively but it won't if you render in a clean session your Rmd file.

Best practice is to have a Rmd file that can be run on its own - this means all the variables used need to be defined (with value / data created or loaded in the Rmd file itself)

Hope it helps

This topic was automatically closed 45 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.