19

I am attempting to follow this easy 2-minute video tutorial on importing an Excel spreadsheet into R as a data frame: http://www.screenr.com/QiN8

I followed each step, including downloading and installing Strawberry Perl (32-bit) on my Win 7 PC, pointing R to my working directory, and entering the following command in R:

Spreadsheet <- read.xls("targetspreadsheet.xls")

I receive this error:

Error in findPerl(verbose = verbose) : perl executable not found. Use perl= argument to specify the correct path. Error in file.exists(tfn) : invalid 'file' argument

Update:

I reset my machine and set the path to Perl:

perl <- "C:/strawberry/perl/bin/perl.exe"

Then I entered this command:

DF <- read.xls("spreadsheet.xls", perl = perl)

The command line returned this error:

Error in xls2sep(xls, sheet, verbose = verbose, ..., method = method, : Intermediate file 'C:\Users\AEID\AppData\Local\Temp\RtmpoXMywa\file18e45ed513c.csv' missing! In addition: Warning message: running command '"C:\STRAWB~1\perl\bin\perl.exe" "C:/Users/AEID/Documents/R/win-library/2.15/gdata/perl/xls2csv.pl" "GFT_show_wip_report(42).xls" "C:\Users\AEID\AppData\Local\Temp\RtmpoXMywa\file18e45ed513c.csv" "1"' had status 2 Error in file.exists(tfn) : invalid 'file' argument

What am I doing wrong?

Thanks in advance for your help!

AME

4

10 に答える 10

9

それを使用して gdata パッケージをロードすると、次のlibrary(gdata)ように明確に表示されます。

gdata: read.xls() は Excel XLS および XLSX ファイルを読み取ることができません

したがって、有効な perl インタープリターへの PATH が必要です。この場合のように、ウィンドウを使用して、必要な perl インタープリターを見つけるためにプロパティを確認する必要があります。

#set the PATH to perl interpreter
perl <- "C:/strawberry/perl/bin/perl5.18.2.exe"

try1file <- read.xls("my.one.filename.xls", perl = perl)

複数の xls ファイルの場合:

> length(list.files())
[1] 65

try65files <- lapply(list.files(), ..., perl = perl) 

の場合verbose = TRUE、各ファイルの最後に次のように表示されます。

Loading 'F65.xls'...
Done.
Orignal Filename: F65.xls
Number of Sheets: 1
Writing sheet number 1 ('Sheet1') to file 'C:\Users\FRANKL~1.JOH\AppData\Local\Temp\RtmpeKs3fi\file13dc750950e4.csv'
Minrow=0 Maxrow=32 Mincol=0 Maxcol=16
  (Ignored 0 blank lines.)
0 
Done.
Reading csv file  “C:\Users\FRANKL~1.JOH\AppData\Local\Temp\RtmpeKs3fi\file13dc750950e4.csv” ...
Done.
于 2014-08-27T17:18:22.523 に答える
7

他のいくつかの回答がすでに言っているように、問題は perl.exe が見つからないことです。私の場合、http: //www.activestate.com/activeperl/downloadsからインストールしてから 、それをポイントした後に機能しました。

    read.xls("bla.xlsx", perl = "C:\\Perl64\\bin\\perl.exe")
于 2015-02-09T10:07:27.450 に答える
0

R は xls または xlsx ファイルを検索していますが、見つかりません。そのため、Excel ファイルが置かれている作業ディレクトリ (例: setwd("C:\....")) を設定し、次のスクリプト形式のいずれかを実行します。

read.xls("Potato.xls", perl = "C:\\Strawberry\\perl\\bin\\perl.exe")
read.xls("Tomato.xls", perl = "C:\\Strawberry\\perl\\bin\\perl.exe")
read.xls("Potato.xlsx", perl = "C:/Strawberry/perl/bin/perl.exe")
read.xls("Tomato.xlsx", perl = "C:/Strawberry/perl/bin/perl.exe")
于 2015-03-02T21:56:11.107 に答える
0

この構文を試すことができます:

T<-read.xls("Template.xlsx", perl = "C:\\Perl\\bin\\perl.exe")

私はここでこの解決策を見つけました

http://cran.r-project.org/web/packages/gdata/INSTALL

于 2014-12-10T06:39:55.100 に答える