因此,我已经使用R Markdown已有一段时间了,但是现在当我尝试编织文档时,它失败了。出现以下错误消息:
LaTeX错误:孤独的\ item-也许缺少列表环境。
我不确定为什么会发生这种情况,因为它以前对我有用。我的文档序言中有两个快捷方式:
\newcommand{\benum}{\begin{enumerate}}
\newcommand{\eenum}{\end{enumerate}}
我感觉这可能是造成我问题的原因,但是令人沮丧的是,在此之前我花了很长时间使用它们,没有遇到任何麻烦。
任何帮助,将不胜感激!
编辑:
这是我制作的最小文件。此小文档将不会编织,并且出现与上述相同的错误消息。
---
title: "Minimal Document"
author: Aiden Kenny
date: Friday, 09/21/2018
header-includes:
- #\usepackage{setspace}\doublespacing
- \newcommand{\benum}{\begin{enumerate}}
- \newcommand{\eenum}{\end{enumerate}}
- \usepackage{xcolor}
fontsize: 12pt
geometry: margin=1in
output: pdf_document
---
\newpage
```{r setup, include = FALSE}
knitr::opts_chunk$set(fig.width = 10, fig.height = 5, echo = TRUE)
library(mosaic)
library(knitr)
library(scatterplot3d)
```
1. Here is a sample of some code I found online. The code chunk by
itself will run fine, so that is not the …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 R 中构建一个涉及该Rcpp包的包。当我使用命令生成包时Rcpp.package.skeleton("pck338")。
默认情况下,文件rcpp_hello_world.cpp被包含在内,RcppExports.cpp文件也被包含在内。
据我了解,每次向目录中添加新函数时都compileAttributes()需要运行该函数。.cppsrc
为此,我在rcpp_dance.cpp文件中编写了一个简单的函数,如下所示:
# include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp:export]]
int rcpp_dance(int x) {
int val = x + 5;
return val;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行 时compileAttributes(),RcppExports.cpp保持不变,因此舞蹈函数不会转换为 R 函数。为什么会这样?任何具体和一般的反馈将不胜感激。
我正在尝试使用 Rcpp 制作一个包。我的所有C++功能都在一个.cpp文件中,如下所示:
double meanvec(NumericVector x) {
int n = x.size();
double tot = 0;
for (int i = 0; i < n; i++) {
tot += x[i];
}
tot /= n;
return tot;
}
double inprod(NumericVector u, NumericVector v) {
int m = u.size();
double val = 0;
for (int i = 0; i < m; i++) {
val += u[i] * v[i];
}
return val;
}
NumericVector lincoef(NumericVector x, NumericVector y) {
int n …Run Code Online (Sandbox Code Playgroud)