Почему я не могу распечатать правильный вывод, полученный с помощью функции kable из пакета knitr? - PullRequest
0 голосов
/ 04 мая 2018

Я пытался напечатать словарь данных, используя функцию kable. Вот мой код:

dict<-build_dict(my.data = tweets_train,linker=linker,option_description = NULL, prompt_varopts = T)
kable(dict,format="latex",caption="Data dictionary for the Training dataset") %>%
  kable_styling(position = "center")

И это вывод:

> kable(dict,format="latex",caption="Data dictionary for the Training dataset") %>%
+   kable_styling(position = "center")

\begin{table}

\caption{\label{tab:}Data dictionary for the Training dataset}
\centering
\begin{tabular}[t]{l|l|l|l}
\hline
variable name & variable description & variable options & notes\\
\hline
sentiment & Sentiment Score 0 for Negative sentences and 4 for Positive sentences & 0 to 4 & The polarity of the tweet (0 = negative, 2 = neutral, 4 = positive)\\
\hline
text & The tweets collected & ''  oh u can take me to the game with u  mor  to zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz so tired   good night hokies & The dataset Sentiment 140 that originated from Stanford University for the purpose of Training\\
\hline
\end{tabular}
\end{table}

Как мне исправить это. Используя knitr впервые, так как мне пришлось создать словарь данных. Любые предложения будут высоко оценены. Заранее спасибо.

1 Ответ

0 голосов
/ 04 мая 2018

Это как сдвинуть ваш код, как упомянуто @ Marius

Вы должны поместить его в файл уценки, как показано ниже:

Open markdown file

вставьте этот фрагмент в r

dict<-build_dict(my.data = tweets_train,linker=linker,
                 option_description = NULL, prompt_varopts = T)
knitr::kable(dict,format="latex",caption="Data dictionary for the Training dataset") %>%
knitr::kable_styling(position = "center")  

вот так и поставьте knitr перед kable, чтобы вызвать саму библиотеку (или вызвать ее до library(knitr)):

enter image description here

Тогда сохрани и вяжи :) Надеюсь, это поможет

...