Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instead of [[document-header]] "1" in document #17

Closed
mamuerie opened this issue Aug 12, 2021 · 14 comments
Closed

Instead of [[document-header]] "1" in document #17

mamuerie opened this issue Aug 12, 2021 · 14 comments

Comments

@mamuerie
Copy link

Hi Team-Trackdown,
first of all thank you for this great tool! It is exactly what I was looking for and what I need to collaborate with my co-authors who don't want to work with RMarkdown!
Unfortunatelly, I have a bug with the document header. After uploading the file, there is a 1 in the google drive document instead of the flac [[document-header]] and accordingly the header could not be restored in RStudio. It works perfectly fine for the code chunks, though.
Does anyone have any idea what is going wrong here and how to fix it? Thanks a lot in advance!

@ClaudioZandonella
Copy link
Owner

Hi @mamuerie,

We are really happy that you find trackdown useful for your work.

Unfortunately, the bug you have reported is really strange.
Do you mind sharing the header and the first few lines of your .Rmd document? This will allows us to evaluate what caused the problem.
And also, which operative system do you use? Different character encoding between OS sometimes triggers some problems.

For a quick solution to the problem:

  • When downloading the file from google drive with the download_file() function, if trackdown fails to retrieve the [[document-header]] tag, the code is automatically restored at the first line of the document. Was the code not restored at the first line in your case? The following message is printed in the console:
Warning message:
Failed retrieving [[document-header]] placeholder, code added at first line 
  • Alternatively (a little bit raw 😅), you could simply add "[[document-header]]" in the document on google drive, on a new line right after the instructions. This should be enough for trackdown to correctly retrieve the tag when downloading.

@mamuerie
Copy link
Author

Hi @ClaudioZandonella,
thanks for your fast response! I tried it today on my private computer (both are windows machines) with the latest RStudie and R Version and there it worked perfectly fine. So it seems that it is somehow related to that. Sorry that I did not try this before I asked here!

@weiyangtham
Copy link

weiyangtham commented Aug 24, 2021

Hi, really excited about this package but just wanted to add that I'm having this problem too. This is the header I have in my .rmd document. I'm using Mac OS (Big Sur). Adding "[[document-header]] at the top of the Google Doc doesn't seem to help either.

title: "Untitled"
author: "Wei Yang Tham"
date: "8/24/2021"
output: html_document

@ClaudioZandonella
Copy link
Owner

Hi @weiyangtham,

We are really happy to know that you are excited about the package! And thank you for reporting this issue...unfortunately, I can not reproduce the issue and it is really strange to understand why this happens.

Do you find the same issue on different documents as well?

To find out where is the problem, could you please follow these instructions?
I have created a small report that will execute all the steps done by trackdown to find and substitute the header code. This will help us to understand at which point the issue emerges. Could you please compile the report and share the results?

I attach a zip folder with the Debugging-issue-17.Rmd file. Could you:

  1. download and unzip the file
  2. move it in the same folder as your Rmd document that presents the issue
  3. open Debugging-issue-17.Rmd
  4. at line 24 you have to indicate the name of your Rmd document (with extension)
  5. compile Debugging-issue-17.Rmd

If everything goes smoothly in the output you can find several checks to evaluate where the problem is. If you upload the output I can try to fix the issue.

Note that I have truncated the output of several chunks in order to print only relevant information and not your entire document, feel free to adjust if required.

Debugging-issue-17.Rmd.zip

@weiyangtham
Copy link

Done! Let me know if you need anything else
document-to-upload.txt

@ClaudioZandonella
Copy link
Owner

ClaudioZandonella commented Aug 27, 2021

Hi @weiyangtham,

Could you please upload the html output you obtain when compiling Debugging-issue-17.Rmd, so I will be able to understand at which step the error occurs.

Note that to upload a html file in GitHub you have to zip the file

Thanks for your help!

@ClaudioZandonella
Copy link
Owner

Hi @dfranquesa,

The problem you referred to in issue #20 is caused by the same problem discussed here. For unknown reasons the [[document-header]] tag is missing and 1 is placed instead. This is really strange also because when downloading, instead of restoring the header code, again another 1 is placed.

Unfortunately, I can not reproduce this error on my computer. Could you please help us to understand the reason behind this error?

To find out where is the problem, please follow these instructions. I have created a short report that will execute all the steps done by trackdown to find and substitute the header code. This will help us to understand at which point the issue emerges. Could you please compile the report and share the resulting output (an HTML file)?

I attach a zip folder with the Debugging-issue-17.Rmd file. Could you:

  1. download and unzip the file
  2. move it in the same folder as your Rmd document that presents the issue
  3. open Debugging-issue-17.Rmd
  4. at line 23 you have to indicate the name of your Rmd document (with extension)
  5. compile Debugging-issue-17.Rmd

If everything goes smoothly in the output you will find several checks to evaluate where the problem is. If you upload the output (the HTML file) I can try to fix the issue.

Note that I have truncated the output of several chunks in order to print only relevant information and not your entire document, feel free to adjust if required.

Thanks for your help!

Debugging-issue-17.Rmd.zip

@weiyangtham
Copy link

Hi @ClaudioZandonella , here's the html file!
Debugging-issue-17.html.zip

ClaudioZandonella added a commit that referenced this issue Aug 27, 2021
Problem caused by character vector considered as factor in data.frame

Now explicit stringsAsFactors = FALSE options
ClaudioZandonella added a commit that referenced this issue Aug 27, 2021
@ClaudioZandonella
Copy link
Owner

Hi @weiyangtham!

Thank you very much for your help!

The problem was caused by character vectors considered as factors in dataframe. Shame on me that I did not consider the stringsAsFactors issue for R versions before 4.0.0😅

Now I fixed the problem by specifying stringsAsFactors = FALSE

Now changes are available on GitHub with the new version of trackdown 1.0.1

@weiyangtham and @dfranquesa could you please try the new version of the package and confirm if the problem is now solved?

You can install the GitHub version of the package with

# install.packages("remotes")
remotes::install_github("claudiozandonella/trackdown",
                         build_vignettes = TRUE)

Thank you so much for your help debugging this issue❤️

@weiyangtham
Copy link

weiyangtham commented Aug 27, 2021

Works for me now! Thanks for the fix!

@dfranquesa
Copy link

dfranquesa commented Aug 28, 2021

@ClaudioZandonella I can not say the same as @weiyangtham
Still not works for me.
I've update to Version: 1.0.1, 2021-08-28 15:04:24
Please find attached a zip file with all the info I think you are asking for debugging.
I'm using Ubuntu, I've add also the session_info.html.
Thanks!
David
Debugging-issue-17-DFG.zip

@ClaudioZandonella
Copy link
Owner

Hi @dfranquesa,

thanks for your help!

Looking at your session_info.html I see
## V trackdown * 1.0.0 2021-08-28 [1] Github (claudiozandonella/trackdown@9445154)
with
## V ── Loaded and on-disk version mismatch.

Probably you installed the new version of the package but tho old one was still loaded. Maybe restarting the rstudio session will solve the issue. You need the version 1.0.1 to be loaded.

To be sure that the new version is loaded you can run the following commands

name_your_file <- "bug_trackdown_header.Rmd"   # path to your file
original_text <- readLines(name_your_file)
info_patterns <- trackdown:::get_extension_patterns("rmd")
head_info <- trackdown:::extract_header(original_text, info_patterns)
str(head_info)

the result should be

'data.frame':	1 obs. of  4 variables:
 $ starts     : int 1
 $ ends       : int 6
 $ header_text: chr "---\ntitle: \"Analysis Script\"\nauthor: \"David Franquesa, Mireia Roura, Leandro Navarro\"\ndate: \"`r format("| __truncated__
 $ name_tag   : chr "[[document-header]]"

If header_text and name_tag are type chr the new version is working. Instead, if they are still type factor, the old version is working.

Again, thanks for your help!
Claudio

@dfranquesa
Copy link

You are right! uauuu! it works now, thanks!

@ClaudioZandonella
Copy link
Owner

Thank you all for your help!

Anyone who finds the same issue, please, install the package version v.1.0.1 from GitHub with

# install.packages("remotes")
remotes::install_github("claudiozandonella/trackdown",
                         build_vignettes = TRUE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants