Dear I used to use R under windows. I always save my code in a txt file. When I want to run something, I just copy and paste to the windows. I recently need to do a big simulation work which will cost 5 or 6 days. I am afraid the memory of windows can not cope with this situation. I now want to run the code under unix. However, I do not know how to run this code in txt file under unix. I just log in to the unix and enter the R, what should I do next? One more question is: if I log off my computer when R is running under unix (i.e., disconnect my computer from server), will I get the result when I log in my computer next time? Thanks! _________________________________________________________________ Get 10mb of inbox space with MSN Hotmail Extra Storage
Zhen Pang wrote: ...> I now want to run the code under unix. However, I do not know how to run > this code in txt file under unix. I just log in to the unix and enter > the R, what should I do next? > > One more question is: if I log off my computer when R is running under > unix (i.e., disconnect my computer from server), will I get the result > when I log in my computer next time?... You'll lose it if you run R in the normal, interactive way. Running it in the background will allow you to log out and still have it running, but! 1) If you're not the only person using this machine, you learn the command "nice" before you begin. 2) I'm not certain you'll be able to produce jpeg or png graphics when backgrounded; your backgrounded task needs access to the windowing system for graphics rendering, and local security policy might prohibit this. 3) Save early, save often. You probably already know that, but it bears repeating. Here are some suggested steps to run your simulation in background mode. Unfortunately, the exact commands will depend on which version of Unix you're using, and what command shells are available. Consult your local expert. 1) transfer the text file of commands to the unix machine. FTP, using ASCII mode is safest. 2) log onto the Unix machine. 3) run sh, ksh, or bash. (the syntax for what follows is different for the C shell, and I don't know it). 4) using a stripped-down version of your script which will complete in a short time (say, a minute or two), just to check that things work, type nohup nice 15 R < my.small.script >my.output 2>&1 & (again, learn what "nice" means before you use it. This may not be suitable, and it's impossible for me to tell from here if it is). I know that's not the full answer, but only someone who knows the local setup can give you that answer. Cheers Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz 64-21-343-545 jasont at indigoindustrial.co.nz
Your Unix computer may also have "screen" installed. This is a multiplexing terminal that allows you to place tasks in the background, log out of them, log back into them on different machines, maintain multiple command prompts, etc., all with minimal overhead - ideal for modems. E.g. the following steps: login screen R source("mycode.R") <start simulation> Ctrl-a d (screen is now detached; process is running in background) exit Then on a different machine login screen -r (process is now running in foreground) Ctrl-a d (screen is now detached; process is running in background) exit You can create new screens, label them, obtain a menu, and use it to juggle numerous tasks - such as editing a source file and executing it efficiently. Refinements: use source("mycode.R", echo=T) for information about the status of your simulation. You can also easily write snippets of code to have the process email you when it's done, and run them via the "system" command. Locate "cat" commands judiciously through your code to update you on its progress. Andrew -- Andrew Robinson Ph: 208 885 7115 Department of Forest Resources Fa: 208 885 6226 University of Idaho E : andrewr at uidaho.edu PO Box 441133 W : http://www.uidaho.edu/~andrewr Moscow ID 83843 Or: http://www.biometrics.uidaho.edu No statement above necessarily represents my employer's opinion.