C'è un comportamento strano su dygraph
.Per il ciclo su dygraph non funziona in R
Quando si utilizza un ciclo for
per dygraph
non ottengo alcun risultato.
library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
for(i in 1:2){
dygraph(lungDeaths[, i])
}
D'altra parte quando uso lapply
ottengo il risultato atteso
lapply(1:2, function(i) dygraph(lungDeaths[, i]))
Io in realtà voglio usare il loop for
in R Markdown
sui miei set di dati e iterare le diverse colonne, ma anche quando uso la "soluzione" lapply
, non tracciare la R codice Markdown dygraphs
---
title: "Untitled"
author: "dimitris_ps"
date: "28 May 2015"
output: html_document
---
```{r}
library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
lapply(1:2, function(i) dygraph(lungDeaths[, i]))
```
considerando quando faccio funzionare colonna per colonna così
---
title: "Untitled"
author: "dimitris_ps"
date: "28 May 2015"
output: html_document
---
```{r echo=FALSE}
library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
```
```{r}
dygraph(lungDeaths[, 1])
dygraph(lungDeaths[, 2])
```
Qualsiasi aiuto sarà molto apprezzato.
informazioni Sessione
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dygraphs_0.4.3 devtools_1.7.0
loaded via a namespace (and not attached):
[1] htmltools_0.2.6 tools_3.2.0 yaml_2.1.13 rmarkdown_0.6.1 digest_0.6.8
'lapply' funziona in' markdown' per me. Per quanto riguarda 'for loop', puoi risolvere il problema (in modo inefficiente) usando' show (dygraph (lungDeaths [, i])) ' – user227710
Grazie per aver esaminato questo. Sfortunatamente per me non funziona. Aggiornerò la mia domanda con il mio 'sessionInfo()' –
Sto usando la stessa versione di R più la versione di '0.4.3' di dygraphs. – user227710