在R中安装knitr时出错

在R中安装knitr时出错,r,rstudio,knitr,R,Rstudio,Knitr,我又在为knitr安装而奋斗了一天,我无法提供新的解决方案。上次我删除了knitr,并尝试重新安装。下面是一个从整个控制台的过程,有什么不对????我每次启动R studio并安装新软件包时都会收到错误消息(见下文) R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: i386-w64-mi

我又在为
knitr
安装而奋斗了一天,我无法提供新的解决方案。上次我删除了knitr,并尝试重新安装。下面是一个从整个控制台的过程,有什么不对????我每次启动R studio并安装新软件包时都会收到错误消息(见下文)

 R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
    Copyright (C) 2014 The R Foundation for Statistical Computing
    Platform: i386-w64-mingw32/i386 (32-bit)

    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.

    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.

    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.

    [Workspace loaded from ~/2016/KNUTSTORP/.RData]

    > install.packages("knitr")
    Installing package into ‘\\xxxxx.xxxxx/users/Eke/mali/Documents/R/win-library/3.1’
    (as ‘lib’ is unspecified)
    also installing the dependencies ‘mime’, ‘stringi’, ‘magrittr’, ‘evaluate’, ‘digest’, ‘formatR’, ‘highr’, ‘markdown’, ‘stringr’, ‘yaml’

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/mime_0.4.zip'
    Content type 'application/zip' length 37255 bytes (36 Kb)
    opened URL
    downloaded 36 Kb

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/stringi_1.0-1.zip'
    Content type 'application/zip' length 14266706 bytes (13.6 Mb)
    opened URL
    downloaded 13.6 Mb

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/magrittr_1.5.zip'
    Content type 'application/zip' length 152098 bytes (148 Kb)
    opened URL
    downloaded 148 Kb

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/evaluate_0.9.zip'
    Content type 'application/zip' length 42030 bytes (41 Kb)
    opened URL
    downloaded 41 Kb

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/digest_0.6.9.zip'
    Content type 'application/zip' length 171597 bytes (167 Kb)
    opened URL
    downloaded 167 Kb

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/formatR_1.3.zip'
    Content type 'application/zip' length 52426 bytes (51 Kb)
    opened URL
    downloaded 51 Kb

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/highr_0.5.1.zip'
    Content type 'application/zip' length 35546 bytes (34 Kb)
    opened URL
    downloaded 34 Kb

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/markdown_0.7.7.zip'
    Content type 'application/zip' length 165447 bytes (161 Kb)
    opened URL
    downloaded 161 Kb

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/stringr_1.0.0.zip'
    Content type 'application/zip' length 83256 bytes (81 Kb)
    opened URL
    downloaded 81 Kb

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/yaml_2.1.13.zip'
    Content type 'application/zip' length 180080 bytes (175 Kb)
    opened URL
    downloaded 175 Kb

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.1/knitr_1.12.3.zip'
    Content type 'application/zip' length 811552 bytes (792 Kb)
    opened URL
    downloaded 792 Kb

    package ‘mime’ successfully unpacked and MD5 sums checked
    package ‘stringi’ successfully unpacked and MD5 sums checked
    package ‘magrittr’ successfully unpacked and MD5 sums checked
    package ‘evaluate’ successfully unpacked and MD5 sums checked
    package ‘digest’ successfully unpacked and MD5 sums checked
    package ‘formatR’ successfully unpacked and MD5 sums checked
    package ‘highr’ successfully unpacked and MD5 sums checked
    package ‘markdown’ successfully unpacked and MD5 sums checked
    package ‘stringr’ successfully unpacked and MD5 sums checked
    package ‘yaml’ successfully unpacked and MD5 sums checked
    package ‘knitr’ successfully unpacked and MD5 sums checked

    The downloaded binary packages are in
        C:\Users\mali\AppData\Local\Temp\RtmpwHvHGn\downloaded_packages
    Error: invalid version specification ‘NA’
    In addition: Warning message:
    In utils:::packageDescription(packageName, fields = "Version") :
      no package 'knitr' was found
版本的输出

> version

platform       i386-w64-mingw32            
arch           i386                        
os             mingw32                     
system         i386, mingw32               
status                                     
major          3                           
minor          1.2                         
year           2014                        
month          10                          
day            31                          
svn rev        66913                       
language       R                           
version.string R version 3.1.2 (2014-10-31)
nickname       Pumpkin Helmet 
按照建议,我开始了新的课程。但是错误仍然是一样的。我测试了其他几个软件包,它们工作正常(即nlme、lme4)

更奇怪的是,
knitr
是以某种方式安装的

Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
  no package 'knitr' was found
[Workspace loaded from ~/R/TESTER/.RData]

> library(knitr)
加载时,不会出现错误

当我在Rstudio中安装
knitr
时,我收到了这样的评论

Installing packages into '\\xxx.xx/users/Eke/mali/Documents/R/win-library/3.3'
(as 'lib' is unspecified)
also installing the dependencies 'mime', 'stringi', 'magrittr', 'Rcpp'

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/mime_0.4.zip'
Content type 'application/zip' length 37402 bytes (36 KB)
==================================================
downloaded 36 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/stringi_1.0-1.zip'
Content type 'application/zip' length 14302873 bytes (13.6 MB)
==================================================
downloaded 13.6 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/magrittr_1.5.zip'
Content type 'application/zip' length 149726 bytes (146 KB)
==================================================
downloaded 146 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/Rcpp_0.12.4.zip'
Content type 'application/zip' length 3249212 bytes (3.1 MB)==================================================
downloaded 3.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/evaluate_0.9.zip'
Content type 'application/zip' length 41981 bytes (40 KB)
==================================================
downloaded 40 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/digest_0.6.9.zip'
Content type 'application/zip' length 169286 bytes (165 KB)
==================================================
downloaded 165 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/formatR_1.3.zip'
Content type 'application/zip' length 52656 bytes (51 KB)
==================================================
downloaded 51 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/highr_0.5.1.zip'
Content type 'application/zip' length 35637 bytes (34 KB)
==================================================
downloaded 34 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/markdown_0.7.7.zip'
Content type 'application/zip' length 167151 bytes (163 KB)==================================================
downloaded 163 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/stringr_1.0.0.zip'
Content type 'application/zip' length 83315 bytes (81 KB)
==================================================
downloaded 81 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/yaml_2.1.13.zip'
Content type 'application/zip' length 175748 bytes (171 KB)
==================================================
downloaded 171 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/htmltools_0.3.5.zip'
Content type 'application/zip' length 571964 bytes (558 KB)==================================================
downloaded 558 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/caTools_1.17.1.zip'
Content type 'application/zip' length 287027 bytes (280 KB)==================================================
downloaded 280 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/bitops_1.0-6.zip'
Content type 'application/zip' length 36372 bytes (35 KB)
==================================================
downloaded 35 KB

package 'mime' successfully unpacked and MD5 sums checked
package 'stringi' successfully unpacked and MD5 sums checked
package 'magrittr' successfully unpacked and MD5 sums checked
package 'Rcpp' successfully unpacked and MD5 sums checked
package 'evaluate' successfully unpacked and MD5 sums checked
package 'digest' successfully unpacked and MD5 sums checked
package 'formatR' successfully unpacked and MD5 sums checked
package 'highr' successfully unpacked and MD5 sums checked
package 'markdown' successfully unpacked and MD5 sums checked
package 'stringr' successfully unpacked and MD5 sums checked
package 'yaml' successfully unpacked and MD5 sums checked
package 'htmltools' successfully unpacked and MD5 sums checked
package 'caTools' successfully unpacked and MD5 sums checked
package 'bitops' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\mali\AppData\Local\Temp\RtmpeK2q5y\downloaded_packages
Installing packages into '\\xxxxx.xxxx/users/Eke/mali/Documents/R/win-library/3.3'
(as 'lib' is unspecified)
also installing the dependencies 'mime', 'stringi', 'magrittr', 'Rcpp', 'bitops', 'evaluate', 'digest', 'formatR', 'highr', 'markdown', 'stringr', 'yaml', 'htmltools', 'caTools'

trying URL 'https://cran.rstudio.com/src/contrib/mime_0.4.tar.gz'
Content type 'application/x-gzip' length 12545 bytes (12 KB)
==================================================
downloaded 12 KB

trying URL 'https://cran.rstudio.com/src/contrib/stringi_1.0-1.tar.gz'
Content type 'application/x-gzip' length 3643002 bytes (3.5 MB)==================================================
downloaded 3.5 MB

trying URL 'https://cran.rstudio.com/src/contrib/magrittr_1.5.tar.gz'
Content type 'application/x-gzip' length 200504 bytes (195 KB)==================================================
downloaded 195 KB

trying URL 'https://cran.rstudio.com/src/contrib/Rcpp_0.12.4.tar.gz'
Content type 'application/x-gzip' length 2402065 bytes (2.3 MB)==================================================
downloaded 2.3 MB

trying URL 'https://cran.rstudio.com/src/contrib/bitops_1.0-6.tar.gz'
Content type 'application/x-gzip' length 8734 bytes
==================================================
downloaded 8734 bytes

trying URL 'https://cran.rstudio.com/src/contrib/evaluate_0.9.tar.gz'
Content type 'application/x-gzip' length 19165 bytes (18 KB)
==================================================
downloaded 18 KB

trying URL 'https://cran.rstudio.com/src/contrib/digest_0.6.9.tar.gz'
Content type 'application/x-gzip' length 116746 bytes (114 KB)
==================================================
downloaded 114 KB

trying URL 'https://cran.rstudio.com/src/contrib/formatR_1.3.tar.gz'
Content type 'application/x-gzip' length 28139 bytes (27 KB)==================================================
downloaded 27 KB

trying URL 'https://cran.rstudio.com/src/contrib/highr_0.5.1.tar.gz'
Content type 'application/x-gzip' length 16744 bytes (16 KB)
==================================================
downloaded 16 KB

trying URL 'https://cran.rstudio.com/src/contrib/markdown_0.7.7.tar.gz'
Content type 'application/x-gzip' length 79427 bytes (77 KB)==================================================
downloaded 77 KB

trying URL 'https://cran.rstudio.com/src/contrib/stringr_1.0.0.tar.gz'
Content type 'application/x-gzip' length 34880 bytes (34 KB)
==================================================
downloaded 34 KB

trying URL 'https://cran.rstudio.com/src/contrib/yaml_2.1.13.tar.gz'
Content type 'application/x-gzip' length 81045 bytes (79 KB)
==================================================
downloaded 79 KB

trying URL 'https://cran.rstudio.com/src/contrib/htmltools_0.3.5.tar.gz'
Content type 'application/x-gzip' length 44048 bytes (43 KB)
==================================================
downloaded 43 KB

trying URL 'https://cran.rstudio.com/src/contrib/caTools_1.17.1.tar.gz'
Content type 'application/x-gzip' length 63358 bytes (61 KB)
==================================================
downloaded 61 KB

trying URL 'https://cran.rstudio.com/src/contrib/knitr_1.12.3.tar.gz'
Content type 'application/x-gzip' length 830827 bytes (811 KB)==================================================
downloaded 811 KB

trying URL 'https://cran.rstudio.com/src/contrib/rmarkdown_0.9.6.tar.gz'
Content type 'application/x-gzip' length 2013956 bytes (1.9 MB)==================================================
downloaded 1.9 MB

'\\xxxx.xxx\users\Eke\mali\Documents\R\TESTER'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
* installing *source* package 'mime' ...
** package 'mime' successfully unpacked and MD5 sums checked
** libs

*** arch - i386
Warning: running command 'make -f "C:/PROGRA~1/R/R-33~1.0/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-33~1.0/share/make/winshlib.mk" SHLIB="mime.dll" OBJECTS="rawmatch.o"' had status 127
ERROR: compilation failed for package 'mime'
* removing '\\xxxx-xxx/users/Eke/mali/Documents/R/win-library/3.3/mime'
* restoring previous '\\xxxx.xxxx/users/Eke/mali/Documents/R/win-library/3.3/mime'
'\\xxxxx.xxxx\users\Eke\mali\Documents\R\TESTER'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
* installing *source* package 'stringi' ...
** package 'stringi' successfully unpacked and MD5 sums checked
Warning: running command 'sh ./configure.win' had status 127
ERROR: configuration failed for package 'stringi'
* removing '\\xxxxxxx.xxxx/users/Eke/mali/Documents/R/win-library/3.3/stringi'
* restoring previous '\\xxxxx.xxxx/users/Eke/mali/Documents/R/win-library/3.3/stringi'
'\\xxxxx.xxxxxxx\users\Eke\mali\Documents\R\TESTER'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
* installing *source* package 'magrittr' ...
** package 'magrittr' successfully unpacked and MD5 sums checked
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
Warning in file(con, "w") :
  cannot open file '\\xxxxx.xxxxxx/users/Eke/mali/Documents/R/win-library/3.3/magrittr/doc/index.html': No such file or directory
Error in file(con, "w") : cannot open the connection
ERROR: installing vignettes failed
* removing '\\xxxxx.xxxxx/users/Eke/mali/Documents/R/win-library/3.3/magrittr'
* restoring previous '\\xxxxx.xxxxxx/users/Eke/mali/Documents/R/win-library/3.3/magrittr'
'\\xxxxxx.xxxxxx\users\Eke\mali\Documents\R\TESTER'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
* installing *source* package 'Rcpp' ...
** package 'Rcpp' successfully unpacked and MD5 sums checked
我遵循了@Richie_Cotton的建议,但没有成功

> .libPaths()
[1] "\\\\xxxxx.xxx/users/Eke/mali/Documents/R/win-library/3.3" "C:/Program Files/R/R-3.3.0/library"                         
> .libPaths("\\\\xxxxxx.xxx/users/Eke/mali/Documents/R/win-library/new")
> .libPaths()
[1] "\\\\xxxxxx.xxx/users/Eke/mali/Documents/R/win-library/new" "C:/Program Files/R/R-3.3.0/library"                         
> install.packages("knitr", dependencies = F)
Installing package into ‘\\xxxxxx.xxx/users/Eke/mali/Documents/R/win-library/new’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/knitr_1.12.3.zip'
Content type 'application/zip' length 812072 bytes (793 KB)
downloaded 793 KB

package ‘knitr’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\mali\AppData\Local\Temp\RtmpmwdUSv\downloaded_packages
Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
  no package 'knitr' was found
> 
我的用户
tackeback
,但我不知道如何翻译结果

5: stop(gettextf("invalid version specification %s", paste(sQuote(unique(x[!ok])), 
       collapse = ", ")), call. = FALSE, domain = NA)
4: .make_numeric_version(x, strict, .standard_regexps()$valid_package_version, 
       "package_version")
3: package_version(utils:::packageDescription(packageName, fields = "Version"))
2: .rs.getPackageVersion("knitr")
1: (function (markdownVersion, stitchVersion) 
   {
       caps <- list()
       caps$r_markdown_supported = .rs.scalar(FALSE)
       caps$stitch_supported = .rs.scalar(FALSE)
       if (.rs.isPackageInstalled("knitr")) {
           knitrVersion <- .rs.getPackageVersion("knitr")
           caps$r_markdown_supported = .rs.scalar(knitrVersion >= 
               markdownVersion)
           caps$stitch_supported = .rs.scalar(knitrVersion >= stitchVersion)
       }
       return(caps)
   })("1.2", "1.2")
> 
5:停止(gettextf(“无效版本规范%s”),粘贴(sQuote(唯一的(x[!确定)),
collapse=“,”),call.=FALSE,domain=NA)
4:。生成数字版本(x,严格,.standard_regexps()$valid_package_version,
“软件包(U版”)
3:package_版本(utils:::packageDescription(packageName,fields=“version”))
2.rs.getPackageVersion(“knitr”)
1:(功能(标记版本、缝合版本)
{
大写=缝合版本)
}
返回(上限)
})("1.2", "1.2")
> 

问题不清楚哪里出了问题,因此您需要一个策略来定位问题。如果可能,请为此使用最新版本的R

安装软件包时,请使用新会话。另外,安装到一个新的库位置,这样您就可以准确地看到正在发生的事情。之后,您始终可以将此库的内容复制到现有库中。要做到这一点,请创建一个您有写权限的新目录(可能在您的主文件夹内)。然后,在调用
install.packages
时,使用
lib.loc
arguemnt安装到该位置

不要调用
install.packages(“knitr”)
,而是逐个安装每个依赖项,看看是哪一个导致了问题。也就是说,
install.packages(“mime”)
,然后
install.packages(“stringi”)
,依此类推。您可以在问题中查看所需的所有软件包的列表(或使用
packageDescription(“knitr”)


如果您收到错误,请使用
traceback()
查看错误发生的位置,并在“您需要进一步帮助”中的问题中包含这些详细信息。

面对同样的问题,在Windows环境变量中创建R\u LIBS\u USER帮了我的忙


请参阅Eric Krantz的评论。该方法适用于Windows 7和10。

错误消息
错误:无效的版本规范'NA'
很奇怪。如果在控制台中键入
版本
,它的输出是什么?从工作区加载的数据可能有问题
~/2016/KNUTSTORP/.RData
which可能包含屏蔽
版本
输出的条目。也许您可以启动一个新会话(可能在不同的目录中)并删除开始时可能加载到工作区中的所有对象。当然,您的R版本很旧,但应该可以在其上安装
knitr
。不久前,我在windows PC上遇到过此问题-当我在大学网络上时,它可以工作,但不在家。请尝试获取新版本的R(3.2.5)R的当前版本是3.3.0。我也在OrganizationR 3.3.0的网络PC中工作,同样的问题
5: stop(gettextf("invalid version specification %s", paste(sQuote(unique(x[!ok])), 
       collapse = ", ")), call. = FALSE, domain = NA)
4: .make_numeric_version(x, strict, .standard_regexps()$valid_package_version, 
       "package_version")
3: package_version(utils:::packageDescription(packageName, fields = "Version"))
2: .rs.getPackageVersion("knitr")
1: (function (markdownVersion, stitchVersion) 
   {
       caps <- list()
       caps$r_markdown_supported = .rs.scalar(FALSE)
       caps$stitch_supported = .rs.scalar(FALSE)
       if (.rs.isPackageInstalled("knitr")) {
           knitrVersion <- .rs.getPackageVersion("knitr")
           caps$r_markdown_supported = .rs.scalar(knitrVersion >= 
               markdownVersion)
           caps$stitch_supported = .rs.scalar(knitrVersion >= stitchVersion)
       }
       return(caps)
   })("1.2", "1.2")
>