Website with R Markdown

Asked

Viewed 369 times

3

I’m trying to create a website to post descriptive analysis in R, using the theme Hugo. However, after creating a post . Rmd where I read a . csv file and do a series of analyses. I get this error when using the serve_site() or build_site command()

Warning message:
In readLines(if (is.character(input2)) { :
  entrada inválida na conexão de entrada '2018-09-12-hello-world.Rmd'
Building sites … ERROR 2018/09/12 22:23:23 Failed to read data from 
__h__project\alex_turner.csv\alex_turner.csv: Data not supported for 
extension 'csv'
Total in 262 ms
Error: Error building site: logged 1 error(s)
Building sites … ERROR 2018/09/12 22:23:24 Failed to read data from 
__h__project\alex_turner.csv\alex_turner.csv: Data not supported for 
extension 'csv'
Total in 103 ms
Error: Error building site: logged 1 error(s)
O sistema nÆo pode encontrar o caminho especificado.
Error in shell(cmd, mustWork = TRUE, intern = intern) : 
  '"C:\Users\erick\AppData\Roaming\Hugo\hugo.exe" -d 
"../erickrdgs.github.io" -t hugo-tranquilpeak-theme' execution failed with 
error code 1
In addition: Warning messages:
1: In read_utf8(f) :
  The file content/post/2018-09-12-hello-world.Rmd is not encoded in UTF-8. 
These lines contain invalid UTF-8 characters: 33, 35, 37, 48, 50, 73, ...
2: running command '"C:\Users\erick\AppData\Roaming\Hugo\hugo.exe" -d 
"../erickrdgs.github.io" -t hugo-tranquilpeak-theme' had status 65535 
3: running command '"C:\Users\erick\AppData\Roaming\Hugo\hugo.exe" -d 
"../erickrdgs.github.io" -t hugo-tranquilpeak-theme' had status 65535 
4: running command 'C:\WINDOWS\system32\cmd.exe /c 
"C:\Users\erick\AppData\Roaming\Hugo\hugo.exe" -d "../erickrdgs.github.io" - 
t hugo-tranquilpeak-theme' had status 1

The alex_turner.csv file exists and is inside a 'date' folder at the root of the project. Does anyone know what might cause this error and how to resolve it?

The repository for the project in question is https://github.com/erickrdgs/blogdown-source

1 answer

5


Apparently your code is correct. I ran it on my PC (it’s a Mac, actually) and, unless of the special characters (as in music, for example), everything went well:

inserir a descrição da imagem aqui

This caught my attention about a possible Character encoding problem. Note the following line in the error message that is in your post:

The file content/post/2018-09-12-hello-world.Rmd is not encoded in UTF-8

Bingo. Here’s the problem. What I did to solve it was the following:

  1. I opened the file content/2018-09-12-hello-world.Rmd in Rstudio

  2. I went on the menu File > Save with Encoding... and chose option UTF-8

  3. I closed Rstudio and opened again

  4. I turned the remote blogdown::build_site(); blogdown::serve_site() and the result was as follows:

inserir a descrição da imagem aqui

Notice that now the special characters appear all (music turned into songs, as it should be).

As you use Windows, my solution is that every file you create in Rstudio from now on is saved through the option Save with Encoding... with option UTF-8. For some unknown reason, Windows still does not use UTF-8 as encoding of characters, which generates a lot of bizarre problems when other programs, such as Hugo, for example, try to access text files made in a Windows editor.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.