rformassspectrometry / book

R for Mass Spectrometry documentation
https://rformassspectrometry.github.io/book
8 stars 7 forks source link

object 'sp' not found #7

Closed kozo2 closed 2 years ago

kozo2 commented 2 years ago

I am converting the Rmd files in this repo to md to translate this repo to multiple languages using GitHub + Crowdin.

library(rmarkdown)
render("20-id.Rmd", md_document())

And I the following error:

> render("20-id.Rmd", md_document())

processing file: 20-id.Rmd
  |.                                                                                                       |   1%
  ordinary text without R code

label: msgf (with options) 
List of 1
 $ eval: logi TRUE

  |..                                                                                                      |   2%
  ordinary text without R code

  |...                                                                                                     |   3%
label: mzrvsid (with options) 
List of 1
 $ eval: logi TRUE

  |....                                                                                                    |   4%
  ordinary text without R code

label: readid (with options) 
List of 1
 $ message: logi FALSE

  |.....                                                                                                   |   5%
  ordinary text without R code

  |......                                                                                                  |   6%
label: unnamed-chunk-1 (with options) 
List of 1
 $ echo: logi FALSE

  |.......                                                                                                 |   6%
   inline R code fragments

  |.......                                                                                                 |   7%
label: unnamed-chunk-2
  |........                                                                                                |   8%
   inline R code fragments

  |.........                                                                                               |   9%
label: unnamed-chunk-3
  |..........                                                                                              |   9%
  ordinary text without R code

  |..........                                                                                              |  10%
label: unnamed-chunk-4
  |...........                                                                                             |  11%
  ordinary text without R code

  |............                                                                                            |  11%
label: unnamed-chunk-5
  |.............                                                                                           |  12%
  ordinary text without R code

  |.............                                                                                           |  13%
label: unnamed-chunk-6 (with options) 
List of 1
 $ warning: logi FALSE

  |..............                                                                                          |  13%
  ordinary text without R code

  |...............                                                                                         |  14%
label: unnamed-chunk-7
  |...............                                                                                         |  15%
  ordinary text without R code

  |................                                                                                        |  16%
label: unnamed-chunk-8
  |.................                                                                                       |  16%
  ordinary text without R code

  |..................                                                                                      |  17%
label: unnamed-chunk-9 (with options) 
List of 1
 $ message: logi FALSE

Attaching package: 'dplyr'

The following object is masked from 'package:MsCoreUtils':

    between

The following object is masked from 'package:Biobase':

    combine

The following objects are masked from 'package:GenomicRanges':

    intersect, setdiff, union

The following object is masked from 'package:GenomeInfoDb':

    intersect

The following objects are masked from 'package:IRanges':

    collapse, desc, intersect, setdiff, slice, union

The following object is masked from 'package:matrixStats':

    count

The following objects are masked from 'package:S4Vectors':

    first, intersect, rename, setdiff, setequal, union

The following objects are masked from 'package:BiocGenerics':

    combine, intersect, setdiff, union

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

  |..................                                                                                      |  18%
   inline R code fragments

  |...................                                                                                     |  18%
label: unnamed-chunk-10 (with options) 
List of 1
 $ message: logi FALSE

  |....................                                                                                    |  19%
   inline R code fragments

  |.....................                                                                                   |  20%
label: unnamed-chunk-11
  |.....................                                                                                   |  21%
   inline R code fragments

  |......................                                                                                  |  21%
label: unnamed-chunk-12
  |.......................                                                                                 |  22%
label: unnamed-chunk-13
  |........................                                                                                |  23%
   inline R code fragments

label: unnamed-chunk-14
  |.........................                                                                               |  24%
  ordinary text without R code

  |..........................                                                                              |  25%
label: unnamed-chunk-15
  |...........................                                                                             |  26%
  ordinary text without R code

label: unnamed-chunk-16
  |............................                                                                            |  27%
   inline R code fragments

  |.............................                                                                           |  28%
label: unnamed-chunk-17
  |..............................                                                                          |  28%
   inline R code fragments

  |..............................                                                                          |  29%
label: answid1 (with options) 
List of 1
 $ fig.cap: chr "Identifcation data wrangling."

  |...............................                                                                         |  30%
   inline R code fragments

  |................................                                                                        |  30%
label: unnamed-chunk-18
Quitting from lines 321-323 (20-id.Rmd) 
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'object' in selecting a method for function 'spectraVariables': object 'sp' not found

> 

Can I ask you to assign something to the sp for this solution?

lgatto commented 2 years ago

Object sp is created in the previous file. Please use bookdown::render_book(".") to compile all chapters together in one environment to have access to all variables.

kozo2 commented 2 years ago

Unfortunately I don't think the solution works for

I need to convert Rmd to md instead of html in order to translate rformassspectrometry with the above translation system. So I'm using rmarkdown::md_document instead of bookdown::render_book.

kozo2 commented 2 years ago

Now I can't think of a plan to solve the above automatically by the program. I will try to solve this problem manually for the time being. I close this issue once.

kozo2 commented 2 years ago

I'm sorry @lgatto . I now understand that this is because I didn't render 05-intro.Rmd (that you pointed). It does't depend on rmarkdown::md_document or bookdown::render_book. It depends rendered or not. I didn't understand it, sorry...

I misunderstood that the value of the variable would be reset for each rendering. It didn't know that it actually stays in that R session without being reset. Anyway, I'm able to solve this issue now. I'm sorry for the trouble. 🙏

lgatto commented 2 years ago

Not sure if it helps, but bookdown::render_book(".") concatenates the chapters and creates one large md file. I think if you set delete_merged_file: false in the yml file, you will have it.

kozo2 commented 2 years ago

Thank you for the information. I didn't know that. However, I would like to proceed with the translation project with multiple divided files like https://github.com/bioconductor-translations/rformassspectrometry-translation .

By the way, the setting of Crowdin is almost finished. https://bioconductor.crowdin.com/rformassspectrometry

lgatto commented 2 years ago

It should be easy to fix this by adding code chunks at the beginning of the failing chapters that load the variables produced in the previous chapters they depend on. Feel free to send a PR if you want.