What I'm trying is import (copy&paste) some data from Excel with comma as decimal points by using scan(dec=",") command, but I have a problem with knitr when compiling this chunk:<<>>=conc<-scan(dec=",")9,56244574937,6611951672,9103195@我收到此错误:第22行:意外的','I get this error: Line 22: Unexpected ',' 感谢您的帮助推荐答案在这种情况下,scan()要求您以 interactive 方式运行它(例如,它等待空白行以终止输入) ),而knitr/Sweave以非交互方式运行R代码.通常,您应该避免需要交互的代码.换句话说,您应确保无需人工干预即可执行代码.例如,无论环境如何,它都可以自行运行:In this case scan() requires your to run it in an interactive fashion (e.g. it waits for a blank line to terminate input), whereas knitr/Sweave runs R code in a non-interactive fashion. In general you should avoid code that requires interaction; in other words, you should guarantee the code can be executed without human interaction. For example, this runs on itself regardless of the environment:conc <- scan(dec=",", text='9,56244574937,6611951672,9103195')为了可重复的研究,避免涉及人工干预的代码尤为重要,因为干预意味着结果不能由代码本身确定(取决于每次运行的人工输入).It is especially important to avoid code which involves with human intervention for the sake of reproducible research, because intervention means the results can not be determined by code itself (depending on human input for each run). 这篇关于Knitr无法使用scan(dec =“,")编译块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-25 08:18