[R] warning in library(GRASS)
Hi, With your help I've found out that library(GRASS) is the responsible for several warnings I'm obtaining. I've got a loop (~100 runs) and for every loop, I'm carrying out several operations over a sequence of raster maps (12) read from the GRASS GIS. But for every map and loop I always use RGRASS.temp as the R-workspace name for the imported raster files, no matter the name of the source GRASS raster map, e.g; RGRASS.temp - rast.get(G,rlist=paste(A2.grassname,it,.Bmaxind.,ib,sep=),catlabels=FALSE) As I always overwrite the same R object, I should hope that the number of calls to rast.get would have no influence on a warning like Too many open raster files, which I'm getting after the fourth loop. Am I missinterpreting something about the way R objects are stored, and every call to rast.get generates a new internal copy of RGRASS.temp? If so, is there a way to solve this problem? Thanks again and best wishes, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
[R] warnings()
Hi, Is there a way to know which library is giving a warning? Specifically, I'm getting a set of warnings: Too many open raster files Thanks and best wishes, -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
[R] chron() question
Hi all, I'm using chron and it seems to me that there is a strange behaviour when constructing chronological objects. An extract of my source data is: tdr.hhmm[4860:4870] [1] 22:22:00 22:42:00 23:02:00 23:22:00 23:42:00 00:02:00 [7] 00:22:00 00:42:00 01:02:00 01:22:00 01:42:00 tdr.dat$year[4860:4870] [1] 2005 2005 2005 2005 2005 2006 2006 2006 2006 2006 2006 tdr.dat$day[4860:4870] [1] 365 365 365 365 365 1 1 1 1 1 1 And if I use: tdr.chron - chron(dates.=tdr.dat$day,times.=tdr.hhmm,origin.=c(month=1,day=0,year=tdr.dat$year),format=c(dates=d/m/y,times=h:m:s)) The result is: tdr.chron[4860:4870] [1] (31/12/05 22:22:00) (31/12/05 22:42:00) (31/12/05 23:02:00) [4] (31/12/05 23:22:00) (31/12/05 23:42:00) (01/01/05 00:02:00) [7] (01/01/05 00:22:00) (01/01/05 00:42:00) (01/01/05 01:02:00) [10] (01/01/05 01:22:00) (01/01/05 01:42:00) While it seems to me that, through the R recycling rule, it should consider the year 2006 in the corresponding results. Isn't it so? Wishes, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
[R] help with this indexing
Hi all, Let's say I have a long data frame and a short one, both with three colums: $east, $north, $value And I need to fill in the short$value, extracting the corresponding value from long$value, for coinciding $east and $north in both tables. I know the possibility: for (i in 1:length(short$value)){ short$value[i] - long$value[long$east==short$east long$north==short$north] } How could I avoid this loop? Thanks and regards, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
Re: [R] indexing
Thanks a lot match() function does the task (of course this a a simple example of my long datasets) Just for the record, merge() function does not seem to work properly for this (even with the sort=FALSE argument) as the order of the results does not match the corresponding order of classes in the x vector. Wishes, Javier --- Tony Plate wrote: a - data.frame(value=c(6.5,7.5,8.5,12.0),class=c(1,3,5,2)) x - c(1,1,2,7,6,5,4,3,2,2,2) match(x, a$class) [1] 1 1 4 NA NA 3 NA 2 4 4 4 a[match(x, a$class), value] [1] 6.5 6.5 12.0 NA NA 8.5 NA 7.5 12.0 12.0 12.0 -- Tony Plate javier garcia-pintado wrote: Hello, In a nutshell, I've got a data.frame like this: assignation - data.frame(value=c(6.5,7.5,8.5,12.0),class=c(1,3,5,2)) assignation value class 1 6.5 1 2 7.5 3 3 8.5 5 4 12.0 2 and a long vector of classes like this: x - c(1,1,2,7,6,5,4,3,2,2,2...) And would like to obtain a vector of length = length(x), with the corresponding values extracted from assignation table. Like this: x.value [1] 6.5 6.5 12.0 NA NA 8.5 NA 7.5 12.0 12.0 12.0 Could you help me with an elegant way to do this ? (I just can do it with looping for each class in the assignation table, what a think is not perfect in R's sense) Wishes, Javier __ R-help@stat.math.ethz.ch 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. -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
[R] indexing
Hello, In a nutshell, I've got a data.frame like this: assignation - data.frame(value=c(6.5,7.5,8.5,12.0),class=c(1,3,5,2)) assignation value class 1 6.5 1 2 7.5 3 3 8.5 5 4 12.0 2 and a long vector of classes like this: x - c(1,1,2,7,6,5,4,3,2,2,2...) And would like to obtain a vector of length = length(x), with the corresponding values extracted from assignation table. Like this: x.value [1] 6.5 6.5 12.0 NA NA 8.5 NA 7.5 12.0 12.0 12.0 Could you help me with an elegant way to do this ? (I just can do it with looping for each class in the assignation table, what a think is not perfect in R's sense) Wishes, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
[R] indexing without looping
Hello, I've got a data.frame like this: assignation - data.frame(value=c(6.5,7.5,8.5,12.0),class=c(1,3,5,2)) assignation value class 1 6.5 1 2 7.5 3 3 8.5 5 4 12.0 2 and a long vector of classes like this: x - c(1,1,2,7,6,5,4,3,2,2,2...) And would like to obtain a vector of length = length(x), with the corresponding values extracted from assignation table. Like this: x.value [1] 6.5 6.5 12.0 NA NA 8.5 NA 7.5 12.0 12.0 12.0 Could you help me with an elegant way to do this ? (I just can do it with looping for each class in the assignation table, what a think is not perfect in R's sense) Wishes, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
[R] gstat package. singular attibute
Hello, I'm using the gstat package within R for an automated procedure that uses ordinary kriging. I can see that there is a logical (singular) atrtibute of some adjusted model semivariograms: .- attr(*, singular)= logi TRUE I cannot find documentation about the exact meaning and the implications of this attribute, and I dont know anything about the inner calculations of model semivariograms. I guess that the inverse of some matrix need to be calculated , and this matrix is singular, but I also see that the model semivariogram is calculated anyway. Could you briefly tell me something about the significance of this attribute and if I should not use these model semivariograms when the singular attibute is true? Thank you very much and best regards, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
[R] xaxt=n for image()
Hi, The argument xaxt=n for removing the x axis from a image plot does not work for me. I'm really using a function called plot.grassmeta() in library GRASS that is a wrapper for image(), but it seems to me that the problem is not in plot.grassmeta() but in image(). If I'm right could you tell me if there is a way to remove one axis from a call to image()? Thanks and wishes, Javier - -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
Re: [R] expression()
Thanks you, this works right. I just would like to note one thing: although I've found italic() in the help for plotmath and I can see that the italic function: mtext(expression(italic(beta)[max]),side=1,line=2) does not work on the greek beta character. Though not strictly necessary, this would be perfect for my plots, as I use them for papers to be published. Wishes, Javier -- Benilton Carvalho wrote: mtext(expression(beta[max]), side=1, line=2) is it what you want? b On Dec 12, 2006, at 10:59 AM, javier garcia-pintado wrote: Hi, I'm trying to use expression() to write a text to a graphic in the margin. Using: mtext(expression(beta),side=1,line=2) writes a perfect beta greek character, but I need to add a subindex max, and I'm trying: mtext(paste(expression(beta),max),side=1,line=2) simply writes beta max in the plot. Please, Could you tell me what I'm doing wrong? By the way, is there a way to add Latex expressions to graphics? Then I could use the Latex expression: $\beta_{\mathrm{max}}$. This also would be very useful for me for more complex expressions in plots. Best regards, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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. -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
[R] expression()
Hi, I'm trying to use expression() to write a text to a graphic in the margin. Using: mtext(expression(beta),side=1,line=2) writes a perfect beta greek character, but I need to add a subindex max, and I'm trying: mtext(paste(expression(beta),max),side=1,line=2) simply writes beta max in the plot. Please, Could you tell me what I'm doing wrong? By the way, is there a way to add Latex expressions to graphics? Then I could use the Latex expression: $\beta_{\mathrm{max}}$. This also would be very useful for me for more complex expressions in plots. Best regards, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
[R] which() over a matrix
Hello, A brief question that I am not able to resolve by my own, but I presume it's easy for you: I've used apply to find the values closer to 0 in each row of a matrix: closer.to.0 - apply(abs(myarray),MARGIN=1,min) My question is how could I use which (or another way) to obtain a vector that indicates which columns contains these closer to 0 values? (I know I can loop, but I mean a faster and elegant way) Thanks and best regards Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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.
[R] tcltk: help pop-up
Hi all; Please, does anyone have a piece of R-tcltk code that includes a help pop-up for any item and could send it as an example? thanks and best regards, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] interacting with X11() device
Hello; I'm preparing a simple function that plots sequentially a number of time series for visual inspection, after some previous transformations. To allow the user to have time to see the series I'm using Sys.sleep(1.5) between calls to line(). But is it possible to add some mechanism that would allow the user, for example with one click on the plotting device, to pause the sequential plotting for a more detailed inspection of a specific series and with another click to go on with the sequential display? Without the details, it is something like this: results.plot - function(i){ plot(...) for (j in i){ lines(j) Sys.time(1.5) } } And I'm calling the function for all series in a matrix: results.plot(1:100) Thanks and best regards, Javier -- Javier García-Pintado Institute of Earth Sciences Jaume Almera (CSIC) Lluis Sole Sabaris s/n, 08028 Barcelona Phone: +34 934095410 Fax: +34 934110012 e-mail:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] tcltk error when calling a dialog
Hello; I've got several radiobuttons in tcltk with the following sintaxis: tk2.rd - /tkradiobutton(/frame4,command=plotDialog1,text=New Q plot, value=2, variable=OUTPLOTtclVar/)/ All the buttons call the same function plotDialog1. With the objective of call a dialog to select some plotting options. When I select one of the radiobuttons and the windows with the plotting options appears. It appears blank, and I obtain this message of error in R: Error in structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class = tclObj) : [tcl] grab failed: window not viewable. All radio buttons are within a frame in a window named dlg. I've removed nearly everything in this function and I still obtain the same error when clicking on a radiobutton. Even with this very simple remaining code: plotDialog1 - function/()/ { mddlg2 - /tktoplevel()/ tkwm./deiconify(/mddlg2/)/ tkgrab./set(/mddlg2/)/ tkwm./title(/mddlg2,Plot options/)/ onNO - function/()/ { tkgrab./release(/mddlg2/)/ /tkdestroy(/mddlg2/)/ /tkfocus(/dlg/)/ } // NO.but - /tkbutton(/mddlg2,text= Cancel ,command=onNO/)/ /tkgrid(/NO.but,pady=2/)/ /tkfocus(/mddlg2/)/ tkwait./window(/mddlg2/)/ } Please for those who are used to utilize the tcltk library: ¿Can you see a clear error in this? I'm new to this library and tcltk and I'm unable to find out the error. Thanks and best regards, Javier [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R script autoload at startup
Thank you very much Prof Brian R, I also wonder how I missed that. Anyway, In my .Rprofile file: .First - function() cat (\n Welcome to R!\n) works perfectly, while: .First - function() winMenuAdd(Newmenu) give me the answer: Error in .First(): couldn't find function winMenuAdd I just can add the new menu, and create the menu entries later, calling a source() that adds the menus. Perhaps the functions to add menus to the RGUI are called after the .RProfile is red? To add it via the .Rprofile would be perfect, but anywat, to be able to create the menu calling manually a source after the GUI is completely started is good enough for me. Best regards, Javier El Viernes, 24 de Febrero de 2006 21:12, escribió: See ?Startup for how to do this via .Rprofile or etc/Rprofile.site. The answer to your second question is that RGui is not written in tcltk (can't you tell from the speed with which it works?), but there are documented R functions for you to add menu items, such as winMenuAdd. (I do wonder how you missed these in the searches for help, as all the terms I tried found the answers.) On Fri, 24 Feb 2006, javier garcia-pintado wrote: Yes. It would be nice and useful to save the users the task of loading the source R-TcltK code everytime they start up R. Because, in principle they are going to use R just for this. But the R GUI must remains open Javier --- El Viernes, 24 de Febrero de 2006 16:39, Frank Samuelson escribió: Do you need the user to interact with the Rgui after the code has run? -Frank Javier Garcia-Pintado wrote: Hello; I'm now using mainly R for windows, mainly because I'm writing a tcl/Tk interface for some people, and I've got two questions. I'm an absolute beginner with tctk or tcktk use under the R GUI. 1) Is it posible to create a shorcut that launchs the R GUI and automatically reads the source code of the tcl/tk script to also launch the tcltk interface? 2) Is the RGUI programmed with tcltk? In this case, is it possible for an user like me to create a menu entry at the R GUI to call the source code in this R/tcl/Tk script? Any of the two options would be very good for us. Thanks and best regards, Javier -- javier garcía-pintado __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] TclTk library loading (whole version) Linux
Hello; Well, I'm afraid this is the second related problem I report in two days (I'm sorry for this) I've programmed a tcltk interface for a model and it includes a comboBox. The comboBox widget comes with the BWidgets library of Tcl/Tk. It works all perfectly with the windows R GUI (with the help of Prof. B. Ripley), following the advices in ?Startup, but I would like that it also could work under Linux. I've got a complete TclTk8.4 installed and also BWidgets, and I could swear that the complete Tcl libraries could be loaded at least once, because I saw a message like Tcl 1.7 or similar under R. Now I don't receive the message anymore and it cannot find BWidgets under R. So I'm not even sure that I'm loading the whole tclTk Library anymore(instead of the subset that comes along with R) I've got libtcl8.4.so and libtk8.4.so in /usr/lib My .Renviron file contains: MY_TCLTK=yes TCL_LIBRARY=/usr/lib/tcl8.4 an in my R session: -- Sys.getenv(MY_TCLTK) MY_TCLTK yes Sys.getenv(TCL_LIBRARY) TCL_LIBRARY /usr/lib/tcl8.4 tclRequire(BWidgets) [1] FALSE Warning message: Tcl package 'BWidgets' not found in: tclRequire(BWidgets) - Please, some how uses BWidgets could tell if I'm doing something wrong in these steps? I've just installed ESS (Emacs Speaks Statistics), could this be a source of problem? Thanks to all, and best regards Javier - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R script autoload at startup
Hello; I'm now using mainly R for windows, mainly because I'm writing a tcl/Tk interface for some people, and I've got two questions. I'm an absolute beginner with tctk or tcktk use under the R GUI. 1) Is it posible to create a shorcut that launchs the R GUI and automatically reads the source code of the tcl/tk script to also launch the tcltk interface? 2) Is the RGUI programmed with tcltk? In this case, is it possible for an user like me to create a menu entry at the R GUI to call the source code in this R/tcl/Tk script? Any of the two options would be very good for us. Thanks and best regards, Javier __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R script autoload at startup
Yes. It would be nice and useful to save the users the task of loading the source R-TcltK code everytime they start up R. Because, in principle they are going to use R just for this. But the R GUI must remains open Javier --- El Viernes, 24 de Febrero de 2006 16:39, Frank Samuelson escribió: Do you need the user to interact with the Rgui after the code has run? -Frank Javier Garcia-Pintado wrote: Hello; I'm now using mainly R for windows, mainly because I'm writing a tcl/Tk interface for some people, and I've got two questions. I'm an absolute beginner with tctk or tcktk use under the R GUI. 1) Is it posible to create a shorcut that launchs the R GUI and automatically reads the source code of the tcl/tk script to also launch the tcltk interface? 2) Is the RGUI programmed with tcltk? In this case, is it possible for an user like me to create a menu entry at the R GUI to call the source code in this R/tcl/Tk script? Any of the two options would be very good for us. Thanks and best regards, Javier -- javier garcía-pintado __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html