knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
The dqmagic package provides an R interface for the libmagic file type identification library similar to the Unix file command. This allows for file type identification based on a file's content instead of it's extension.
In order to install and use dqmagic you will need the libmagic
library and headers:
sudo apt-get install libmagic-dev
sudo yum install file-devel
brew install libmagic
At the moment dqmagic is not on CRAN, but you can install the current version via drat:
if (!requireNamespace("drat", quietly = TRUE)) install.packages("drat") drat::addRepo("daqana") install.packages("dqmagic")
This is a basic example which shows you how to determine the type of a file:
library(dqmagic) file_type("DESCRIPTION") file_type("src/file.cpp")
And the same for the MIME type and encoding:
library(dqmagic) file_type("DESCRIPTION", mime_type = TRUE, mime_encoding = TRUE) file_type("src/file.cpp", mime_type = TRUE, mime_encoding = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.