Dear List, I noticed that, when executing R without X11 (e.g. on a remote machine without X forwarding), when R needs to display a Tk dialog (e.g. when presenting the list of mirrors for install.packages,or of available packages containing help on a given keyword) it replaces it by a simple numbered text list. I would love this behaviour to be the default, even when I have X11, since I find it quicker and less intrusive[1]. Is that possible? man R, RSiteSearch and google were not helpful, it seems that everybody is trying to get Tk to work rather than trying to suppress it... Thanks in advance. [1] I am mainly using R in a simple terminal on OS X (X11 is usually not running, so each TK dialog has to start the whole X server) or via ssh to a remote machine (each Tk dialog has to start my local X server and needs to be sent through the network, twice as painful). This may give you the reason behind this seemingly strange question. JiHO --- http://jo.irisson.free.fr/
Without reproduction instructions we have to guess at what you are doing. But I think the answer is in the help for options(), and more obvious from ?chooseCRANmirror (which seems to be one of the functions you are using). On Tue, 5 Feb 2008, jiho wrote:> Dear List, > > I noticed that, when executing R without X11 (e.g. on a remote machine > without X forwarding), when R needs to display a Tk dialog (e.g. when > presenting the list of mirrors for install.packages,or of available > packages containing help on a given keyword) it replaces it by a > simple numbered text list. I would love this behaviour to be the > default, even when I have X11, since I find it quicker and less > intrusive[1]. Is that possible? > man R, RSiteSearch and google were not helpful, it seems that > everybody is trying to get Tk to work rather than trying to suppress > it... > > Thanks in advance. > > [1] I am mainly using R in a simple terminal on OS X (X11 is usually > not running, so each TK dialog has to start the whole X server) or via > ssh to a remote machine (each Tk dialog has to start my local X server > and needs to be sent through the network, twice as painful). This may > give you the reason behind this seemingly strange question. > > JiHO > --- > http://jo.irisson.free.fr/ > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
The problem is your data is in wide format and you want it in long format. See ?reshape and also see the reshape package. In your example, ?stack is sufficient: library(lattice) xyplot(values ~ seq_along(values) | ind, data = stack(people)) On Feb 5, 2008 11:05 AM, john seers (IFR) <john.seers at bbsrc.ac.uk> wrote:> > Hello All > > Using lapply and ending up with lists of lists I often end up in the > position of not having the names of the list passed by lapply. So, if I > am doing something like a plot, and I would like the title to reflect > which plot it is, I cannot easily do it. So I find myself doing some > unstructured variable passing and counting to be able to keep track of > my data. Then I think perhaps I should not use lapply and just use > simple loops. > > Is there a better way to do this? > > Here is a simple example to illustrate what I am talking about. The list > has the names of people and I need the names to use as the headings of > the plots. > > > > ######################################################################## > ######### > > # Make some test data > people<-list(Andrew=rnorm(10), Mary=rnorm(10), Jane=rnorm(10), > Richard=rnorm(10)) > > > # Function to plot each list entry with its title name > doplot<-function(individual, peoplenames) { > peoplecount<<-peoplecount + 1 > plot(individual, main=peoplenames[peoplecount]) > } > > # > peoplecount<-0 > jpeg(file="test.jpg") > par(mfrow=c(2,2)) > lapply(people, doplot, names(people)) > dev.off() > > ######################################################################## > ############# > > > Thank you for any suggestions. > > > John Seers > > --- > > ______________________________________________ > R-help at r-project.org mailing list > 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. >
hits=-2.5 tests=BAYES_00,FORGED_RCVD_HELO X-USF-Spam-Flag: NO maybe you could use mapply(), e.g., people <- list(Andrew = rnorm(10), Mary = rnorm(10), Jane = rnorm(10), Richard = rnorm(10)) doplot <- function (individual, main) { plot(individual, main = main) } par(mfrow = c(2,2)) jpeg(file="test.jpg") mapply(doplot, people, names(people)) dev.off() I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "john seers (IFR)" <john.seers at bbsrc.ac.uk> To: "R Help" <r-help at stat.math.ethz.ch> Sent: Tuesday, February 05, 2008 5:05 PM Subject: [R] Using lapply and list names not available> > Hello All > > Using lapply and ending up with lists of lists I often end up in the > position of not having the names of the list passed by lapply. So, > if I > am doing something like a plot, and I would like the title to > reflect > which plot it is, I cannot easily do it. So I find myself doing some > unstructured variable passing and counting to be able to keep track > of > my data. Then I think perhaps I should not use lapply and just use > simple loops. > > Is there a better way to do this? > > Here is a simple example to illustrate what I am talking about. The > list > has the names of people and I need the names to use as the headings > of > the plots. > > > > ######################################################################## > ######### > > # Make some test data > people<-list(Andrew=rnorm(10), Mary=rnorm(10), Jane=rnorm(10), > Richard=rnorm(10)) > > > # Function to plot each list entry with its title name > doplot<-function(individual, peoplenames) { > peoplecount<<-peoplecount + 1 > plot(individual, main=peoplenames[peoplecount]) > } > > # > peoplecount<-0 > jpeg(file="test.jpg") > par(mfrow=c(2,2)) > lapply(people, doplot, names(people)) > dev.off() > > ######################################################################## > ############# > > > Thank you for any suggestions. > > > John Seers > > --- > > ______________________________________________ > R-help at r-project.org mailing list > 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. >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
Hi Gabor Thanks for the suggestion but I am not sure it actually addresses my problem. I will ponder the idea of my data needing to be in a different form but I am not sure how to get there easily with what I have got. The example I gave was just a simplified example to demonstrate how you cannot access the names of the list once it has been passed by lapply. My real world problem is data coming from 4 spreadsheets for thirteen volunteers and 250 variables with various models being calculated and values extracted from the models. lapply seems to be the way to do these repetitive processes on the data, volunteers etc but then I end up with a load of lists of lists. I guess I could extract the data from the lists into a more suitable format for plotting but as lapply has already done all the work it seems a lot of extra effort. I would like to be able to do one more lapply to plot the data (or whatever) and be able to slap a label on it so I can keep track of what I am doing. Regards John Seers -----Original Message----- From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] Sent: 05 February 2008 16:17 To: john seers (IFR) Cc: R Help Subject: Re: [R] Using lapply and list names not available The problem is your data is in wide format and you want it in long format. See ?reshape and also see the reshape package. In your example, ?stack is sufficient: library(lattice) xyplot(values ~ seq_along(values) | ind, data = stack(people)) On Feb 5, 2008 11:05 AM, john seers (IFR) <john.seers at bbsrc.ac.uk> wrote:> > Hello All > > Using lapply and ending up with lists of lists I often end up in the > position of not having the names of the list passed by lapply. So, if > I am doing something like a plot, and I would like the title to > reflect which plot it is, I cannot easily do it. So I find myself > doing some unstructured variable passing and counting to be able to > keep track of my data. Then I think perhaps I should not use lapply > and just use simple loops. > > Is there a better way to do this? > > Here is a simple example to illustrate what I am talking about. The > list has the names of people and I need the names to use as the > headings of the plots. > > > > ###################################################################### > ## > ######### > > # Make some test data > people<-list(Andrew=rnorm(10), Mary=rnorm(10), Jane=rnorm(10), > Richard=rnorm(10)) > > > # Function to plot each list entry with its title name > doplot<-function(individual, peoplenames) { > peoplecount<<-peoplecount + 1 > plot(individual, main=peoplenames[peoplecount]) } > > # > peoplecount<-0 > jpeg(file="test.jpg") > par(mfrow=c(2,2)) > lapply(people, doplot, names(people)) > dev.off() > > ###################################################################### > ## > ############# > > > Thank you for any suggestions. > > > John Seers > > --- > > ______________________________________________ > R-help at r-project.org mailing list > 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. >
If you must use lapply then do it over the names rather than the data: lapply(names(people), function(nm) plot(1:10, people[[nm]], main = nm)) On Feb 5, 2008 11:47 AM, john seers (IFR) <john.seers at bbsrc.ac.uk> wrote:> > > Hi Gabor > > Thanks for the suggestion but I am not sure it actually addresses my > problem. I will ponder the idea of my data needing to be in a different > form but I am not sure how to get there easily with what I have got. > > The example I gave was just a simplified example to demonstrate how you > cannot access the names of the list once it has been passed by lapply. > My real world problem is data coming from 4 spreadsheets for thirteen > volunteers and 250 variables with various models being calculated and > values extracted from the models. > > lapply seems to be the way to do these repetitive processes on the data, > volunteers etc but then I end up with a load of lists of lists. I guess > I could extract the data from the lists into a more suitable format for > plotting but as lapply has already done all the work it seems a lot of > extra effort. I would like to be able to do one more lapply to plot the > data (or whatever) and be able to slap a label on it so I can keep track > of what I am doing. > > Regards > > John Seers > > > > > -----Original Message----- > From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] > Sent: 05 February 2008 16:17 > To: john seers (IFR) > Cc: R Help > Subject: Re: [R] Using lapply and list names not available > > The problem is your data is in wide format and you want it in long > format. > See ?reshape and also see the reshape package. In your example, ?stack > is sufficient: > > library(lattice) > xyplot(values ~ seq_along(values) | ind, data = stack(people)) > > > On Feb 5, 2008 11:05 AM, john seers (IFR) <john.seers at bbsrc.ac.uk> > wrote: > > > > Hello All > > > > Using lapply and ending up with lists of lists I often end up in the > > position of not having the names of the list passed by lapply. So, if > > I am doing something like a plot, and I would like the title to > > reflect which plot it is, I cannot easily do it. So I find myself > > doing some unstructured variable passing and counting to be able to > > keep track of my data. Then I think perhaps I should not use lapply > > and just use simple loops. > > > > Is there a better way to do this? > > > > Here is a simple example to illustrate what I am talking about. The > > list has the names of people and I need the names to use as the > > headings of the plots. > > > > > > > > ###################################################################### > > ## > > ######### > > > > # Make some test data > > people<-list(Andrew=rnorm(10), Mary=rnorm(10), Jane=rnorm(10), > > Richard=rnorm(10)) > > > > > > # Function to plot each list entry with its title name > > doplot<-function(individual, peoplenames) { > > peoplecount<<-peoplecount + 1 > > plot(individual, main=peoplenames[peoplecount]) } > > > > # > > peoplecount<-0 > > jpeg(file="test.jpg") > > par(mfrow=c(2,2)) > > lapply(people, doplot, names(people)) > > dev.off() > > > > ###################################################################### > > ## > > ############# > > > > > > Thank you for any suggestions. > > > > > > John Seers > > > > --- > > > > ______________________________________________ > > R-help at r-project.org mailing list > > 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. > > >
OK, that looks a good suggestion. Though it is a bit of a step towards loops and counting ... Thanks a lot. Regards JS -----Original Message----- From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] Sent: Tue 2/5/2008 4:51 PM To: john seers (IFR) Cc: R Help Subject: Re: [R] Using lapply and list names not available If you must use lapply then do it over the names rather than the data: lapply(names(people), function(nm) plot(1:10, people[[nm]], main = nm)) On Feb 5, 2008 11:47 AM, john seers (IFR) <john.seers at bbsrc.ac.uk> wrote:> > > Hi Gabor > > Thanks for the suggestion but I am not sure it actually addresses my > problem. I will ponder the idea of my data needing to be in a different > form but I am not sure how to get there easily with what I have got. > > The example I gave was just a simplified example to demonstrate how you > cannot access the names of the list once it has been passed by lapply. > My real world problem is data coming from 4 spreadsheets for thirteen > volunteers and 250 variables with various models being calculated and > values extracted from the models. > > lapply seems to be the way to do these repetitive processes on the data, > volunteers etc but then I end up with a load of lists of lists. I guess > I could extract the data from the lists into a more suitable format for > plotting but as lapply has already done all the work it seems a lot of > extra effort. I would like to be able to do one more lapply to plot the > data (or whatever) and be able to slap a label on it so I can keep track > of what I am doing. > > Regards > > John Seers > > > > > -----Original Message----- > From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] > Sent: 05 February 2008 16:17 > To: john seers (IFR) > Cc: R Help > Subject: Re: [R] Using lapply and list names not available > > The problem is your data is in wide format and you want it in long > format. > See ?reshape and also see the reshape package. In your example, ?stack > is sufficient: > > library(lattice) > xyplot(values ~ seq_along(values) | ind, data = stack(people)) > > > On Feb 5, 2008 11:05 AM, john seers (IFR) <john.seers at bbsrc.ac.uk> > wrote: > > > > Hello All > > > > Using lapply and ending up with lists of lists I often end up in the > > position of not having the names of the list passed by lapply. So, if > > I am doing something like a plot, and I would like the title to > > reflect which plot it is, I cannot easily do it. So I find myself > > doing some unstructured variable passing and counting to be able to > > keep track of my data. Then I think perhaps I should not use lapply > > and just use simple loops. > > > > Is there a better way to do this? > > > > Here is a simple example to illustrate what I am talking about. The > > list has the names of people and I need the names to use as the > > headings of the plots. > > > > > > > > ###################################################################### > > ## > > ######### > > > > # Make some test data > > people<-list(Andrew=rnorm(10), Mary=rnorm(10), Jane=rnorm(10), > > Richard=rnorm(10)) > > > > > > # Function to plot each list entry with its title name > > doplot<-function(individual, peoplenames) { > > peoplecount<<-peoplecount + 1 > > plot(individual, main=peoplenames[peoplecount]) } > > > > # > > peoplecount<-0 > > jpeg(file="test.jpg") > > par(mfrow=c(2,2)) > > lapply(people, doplot, names(people)) > > dev.off() > > > > ###################################################################### > > ## > > ############# > > > > > > Thank you for any suggestions. > > > > > > John Seers > > > > --- > > > > ______________________________________________ > > R-help at r-project.org mailing list > > 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. > > >