[R] non-interactive error in .First function

Brian Chalfant bchalfant at yahoo.com
Tue Jun 24 18:16:08 CEST 2014


(a) Sorry, that was my first post.  I'll be sure to plain text from here on.

(b) Hmm.  "It is not intended that there be interaction with the user during startup code.  Attempting to do so can crash the R process, especially so prior to R 3.0.2."  I had been using this with <3.0.1. with no problems or error messages at all.  What changed?  If I want to risk crashing, is there a workaround?

Thanks much -
Brian


Brian Alexander Chalfant
Research Assistant & PhD student
University of Pittsburgh
www.pitt.edu/~bac84
bac84 at pitt.edu
724.984.7758


________________________________
From: Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
To: Brian Chalfant <bchalfant at yahoo.com> 
Cc: "r-help at r-project.org" <r-help at r-project.org> 
Sent: Tuesday, June 24, 2014 11:00 AM
Subject: Re: [R] non-interactive error in .First function


Suggestions:
a) Don't post in HTML format... your code appears corrupt.
b) Don't do this. Read the Note in ?.First




On Tue, 24 Jun 2014, Brian Chalfant wrote:

> Hi all -
>
> Long-time user, first-time poster.
>
> I added a .First function to my Rprofile.site file to check for updates, clean the console, and put some fun quotes on startup.? This used to work without error.? I hadn't used R (which I usually play with in RStudio) in a few weeks, but when I started up recently and updated (R 3.1.0+ RStudio v 0.98.945),I got a couple error messages.? For context, here is my .First function:
>
> .First <- function(){
> ??? suppressPackageStartupMessages(library(installr))
> ??? library(installr)
> ??? library(stats)
> ??? old.packages = installed.packages()[,1]
> ??? save(old.packages, file="C:/Users/Owner/Documents/R/installedPackages.Rdata")
> ??? # load("C:/Users/Owner/Documents/R/installedPackages.Rdata")
> ??? # pull.packages = installed.packages()[,1]
> ??? # for (i in setdiff(old.packages, pull.packages))
> ??? # install.packages(i)
> ??? updateR()
> ??? cat("\014")
> ??? if (runif(1,0,1)>0.5) {
> ????? cat("Stately, plump Buck Mulligan...")
> ??? } else cat("as though\nyou were creating\na mathematical sandwich")
> ? }
>
>
> I was getting an error message about installr, but I added the suppress... function as suggested in that error message, which worked like a gem.? However, I can't quite figure out how to address the other error message.? Here it is:
>
> Error installing package: Error in winDialog(type = "ok", message = message_text) :  winDialog() cannot be used non-interactively
> Calls: .First -> updateR -> check.for.updates.R -> winDialog
> Execution halted
> I'm not sure what's going on here, but I'm guessing R runs .First functions in non-interactive mode.? I ham-handedly tried adding an > interactive=T line to the .First function, but this didn't work.
>
> Any suggestions would be much appreciated.
>
> =)? Brian
> ?
> Brian Alexander Chalfant
> Research Assistant & PhD student
> University of Pittsburgh
> www.pitt.edu/~bac84
> bac84 at pitt.edu
> 724.984.7758
>     [[alternative HTML version deleted]]
>
>

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k

--------------------------------------------------------------------------- 



More information about the R-help mailing list