pacomet pacomet - 2 years ago 65
R Question

Format r output in knitr

I'm trying to build an html page showing some output (max values, time recorded,...) inside a table. I'm using knitr for the first time in this type of reports

I have tried this code

<table>
<td class="celda1">
```{r results='asis', echo=FALSE}
print(output$Temperatura)
```
</td><td class="celda2">
```{r results='asis', echo=FALSE}
output$Hora1
```
</td>
</table>


with these results

enter image description here

Now I would like to remove the prefix number
[1]
just before the value. I am not familiar with knitr but have read some options for code chunks to remove warnings or ## comments but can't find how to remove the prefix.

Thanks in advance for your help

SOLUTION

Finally the solution came from the combination of
cat
and
paste
commands, following suggestion from @drmariod. Just
cat
for numeric values and
cat-paste
to preserve date format.

<table>
<td class="celda1">
```{r results='asis', echo=FALSE}
cat(output$Temperatura)
```
</td><td class="celda2">
```{r results='asis', echo=FALSE}
cat(paste(output$Hora1))
```
</td>
</table>


enter image description here

Answer Source

use cat instead! like cat(output$Hora1)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download