编写Rmarkdown doc时出错:bzfile出错(文件名," rb"):无法打开连接

时间:2014-08-24 16:33:54

标签: r csv knitr r-markdown bzip2

所以我正在尝试编写我的代码来编写Coursera上的作业,但我遇到了一个奇怪的错误,我无法弄清楚这个问题。这是我认为是问题的代码

setInternet2(use = TRUE)


fileUrl<- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"

download.file(fileUrl, destfile = "c:/Users/musto101/Dropbox/DataScience/ReproducibleResearch/Assignment2/data/stormData.csv.bz2")



dateDownloaded<- date()

library(R.utils)



stormData<-bunzip2( filename = "stormData.csv", destname = "stormData3.csv")



head(stormData)

和错误:

Quitting from lines 13-35 (PA2.Rmd) 
Error in bzfile(filename, "rb") : cannot open the connection
Calls: <Anonymous> ... eval -> eval -> bunzip2 -> bunzip2.default -> bzfile
In addition: Warning messages:
1: package 'R.utils' was built under R version 3.1.1 
2: package 'R.oo' was built under R version 3.1.1 
3: package 'R.methodsS3' was built under R version 3.1.1 
4: In bzfile(filename, "rb") :
  cannot open bzip2-ed file 'stormData.csv', probable reason 'No such file or directory'
Execution halted

那么有谁知道这里发生了什么?我们将非常感激地收到任何建议。

由于

2 个答案:

答案 0 :(得分:0)

看起来您忘记了输入文件名的.BZ2后缀。下面的代码应该解决这个问题。

stormData<-bunzip2( filename = "stormData.csv.bz2", destname = "stormData3.csv")

答案 1 :(得分:0)

刚刚放一个

    <?php
$sql="SELECT * FROM clinic.appoint";
$result = mysqli_query($con, $sql) or die($sql."<br/><br/>".mysql_error());
$rows=mysqli_fetch_array($result)
?>
<div class="container">
<table>
          <thead>
            <tr>
                            Schedule               

              <th scope="row">
                    <form action="" method="submit">
                    <select name="Date" required class="form-control" id="Date">
    <option value="">Please Select Date</option>
    <?php $sql2="SELECT * FROM clinic.appoint";
    $result2 = mysqli_query($con, $sql2) or die($sql2."<br/><br/>".mysql_error());
    while($rows2=mysqli_fetch_array($result2)){?>
    <option value="<?php echo $rows2['date'] ?>"><?php echo $rows2['date'] ?></option>
    <?php } ?>
</select>
<input type="submit" name="submit" value="Select Date" />
</form>
              </th>
              <td class="schedule-offset" colspan="2">
              </td>
            </tr>
          </thead>
          <tbody>
          <?php if(isset($_POST['submit'])){ ?>
          <?php if(isset($_POST['Date'])){ ?>

          <?php
          $selectOpt = $_POST['Date'];
$sql="SELECT * FROM clinic.appoint WHERE date=".$rows2['date'];
$result = mysqli_query($con, $sql) or die($sql."<br/><br/>".mysql_error());
$rows=mysqli_fetch_array($result)
?>
            <tr>
              <th scope="row">
                          <?php while($rows=mysqli_fetch_array($result)){?>

                <?php echo $rows['time'] ?>
              </th>
              <td scope="row" id="scheduleDate">
                <?php echo $rows['name'] ?>
              </td>
              <td scope="row">
                <?php echo $rows['date'] ?>
              </td>
            </tr>
            <tr>
            <?php } ?>
            <?php }?>
            <?php }?>
              <th scope="row">
                <time datetime="14:00">2:00 PM</time>
              </th>
              <td>
                <a href="speakers.html#tessa-harmon">
                  <h4>Tessa Harmon</h4>
                  Crafty Coding: Generating Knitting Patterns
                </a>
              </td>
            </tr>
          </tbody>
        </table>
</div>
</body>
</html>

位于该块的顶部,它将正常工作。我遇到过同样的问题。我有一些像dplyr这样的其他软件包。相同的分辨率或放入require(R.utils)