创建空数据帧时出错

时间:2016-06-08 09:47:56

标签: r dataframe

我正在尝试创建一个空数据框:

predict_data <- data.frame("predict_class" = as.numeric(),
                            "predict_score" = as.numeric(),
                            "actual_class" = as.numeric())
  

as.numeric()中的错误:参数&#34; x&#34;缺少,没有默认

我做错了什么?

2 个答案:

答案 0 :(得分:0)

你试过

吗?
table {
  border-collapse: collapse;
}
th,
td {
  text-align: center;
  border: 1px solid #000;
  min-width: 4em;
  min-height: 2em;
  padding: 0.2em 0.5em;
}
th {
  vertical-align: top;
}

因为它是

<table>
  <thead>
    <tr>
      <!-- rowspan="2" forces the following <th> element
           to span two rows in its containing element: -->
      <th rowspan="2">SUBJECT</th>
      <th colspan="3">CA</th>
      <!-- as it does here also: -->
      <th rowspan="2">CA TOTAL (40)</th>
    </tr>
    <tr>
      <!-- this <tr> contains only three <th> elements,
           unlike the previous <tr> which contains five,
           because two <th> elements of the previous row
           will occupy space in this <tr> also -->
      <th>T1</th>
      <th>T2</th>
      <th>T3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>English Language</td>
      <td>3</td>
      <td>6</td>
      <td>10</td>
      <td></td>
    </tr>
    <tr>
      <td>Mathematics</td>
      <td>3</td>
      <td>5</td>
      <td>7</td>
      <td></td>
    </tr>
  </tbody>
</table>

默认情况下:)

答案 1 :(得分:0)

使用

predict_data <- data.frame(predict_class = as.numeric(0),
  predict_score = as.numeric(0),
  actual_class = as.numeric(0))

如果你知道尺码,你可以加快尺码而不是0。