Gráfico dinámico en R

Is it possible to update a plot every 2 seconds, for example ?

Or, even better, to just call a function that will update the plot given the new x, y values ?

Información Adicional -

I am developing a neural network, and would like to update a line chart showing the output vs the targets after each iteration.

Muchas gracias

preguntado el 31 de julio de 12 a las 11:07

Yes, anything is posible in R. But to give a sensible answer, you should consider adding some more background information, e.g. what changes between plots, how does this fit into the rest of your project, are you calling R interactively or not, etc... -

Hi Andrie, I updated the question, hopefully this helps. -

You can write a loop with a 2 second sleep in it (Sys.sleep) and then redo the plot or use 'points' or 'lines' to add marks to it. Is that what you want to do? -

Es posible que desee echar un vistazo a animación paquete. -

@Spacedman - this is an option, however sys.sleep will stop running the entire program right ? In which case i would need to write some kind of multi threaded solution ? -

1 Respuestas

How are you creating the neural network? It may be possible to insert code into what you are already doing that would update your plot.

There are functions in the tcltk2 package that will run code after specified waiting times and will allow other functions to run while waiting, but these can be very dangerous in creating race conditions, or changing objects that other code depends on. You will still need a way to acces the network information as it is being created (and this is very dificult if it is inside of another function), this will probably also slow the fitting code down a bit as it needs to keep checking the time and doing the other calculations.

It is probably best to insert the update code into the fitting code rather that depending on timing. If you show us more about how you are fitting the network (reproducible example) then we may be able to give a more detailed answer.

Respondido 31 Jul 12, 16:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.