Maybe OT: Forking in R scripts?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Maybe OT: Forking in R scripts?

K. Elo-2
Dear all,

I am currently working a research project on social media interaction.
As a part of this project, mostly for teaching purposes, I should
develop a R-based approach for real-time visualisation of streamed data
(from Twitter).

My idea is simple (and working :) ): A Python-script stream Twitter for
selected keywords/hashtags/users and redirects the output as JSON in a
text file. My R-script reads the new entries from this text file every
5-10 minutes, process the input and updates network and other graphical
presentations.

Thus far everything is working fine. However, I would like to have the
possibility to work with my data when my script is sleeping. I just
wonder whether a simple 'mcparallel({ Sys.sleep(300); TRUE})' (from
'parallel') would solve my problem? Or is there something I have to take
into account when using 'parallel'?

My R environment runs on Linux, so forking should work...

Best regrads and thanks in advance,
Kimmo

--
Åbo Akademi University, Finland
Dep. for German studies

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Maybe OT: Forking in R scripts?

glsnow
I don't know if the parallel approach would work or not, but a
possibly simpler approach would be to use the tclTaskSchedule function
from the tcltk package.  You could use this to schedule your update
code to run on a regular basis, then you have access to the command
line between times that it runs.

You just need to be careful, if you are accessing a data object at the
same time that the update code runs on that same object, then there
could be problems.



On Thu, Oct 13, 2016 at 12:02 AM, K. Elo <[hidden email]> wrote:

> Dear all,
>
> I am currently working a research project on social media interaction. As a
> part of this project, mostly for teaching purposes, I should develop a
> R-based approach for real-time visualisation of streamed data (from
> Twitter).
>
> My idea is simple (and working :) ): A Python-script stream Twitter for
> selected keywords/hashtags/users and redirects the output as JSON in a text
> file. My R-script reads the new entries from this text file every 5-10
> minutes, process the input and updates network and other graphical
> presentations.
>
> Thus far everything is working fine. However, I would like to have the
> possibility to work with my data when my script is sleeping. I just wonder
> whether a simple 'mcparallel({ Sys.sleep(300); TRUE})' (from 'parallel')
> would solve my problem? Or is there something I have to take into account
> when using 'parallel'?
>
> My R environment runs on Linux, so forking should work...
>
> Best regrads and thanks in advance,
> Kimmo
>
> --
> Åbo Akademi University, Finland
> Dep. for German studies
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.