[R] time series plots: labels language & tickmarks
Hi all; My native language is spanish and I would need to do two changes in the default xlabels in timeseries plots: a) For timeseries that span more than one year, there are just xlabs and tickmarks for the beginning of each year. Could I add extra tick marks for each month easily? b) The xlabs appear in my language for months and days (spanish) but I need them in English, how can I change this setting? 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
[R] R - C programm. calling load() from within C code
Hi! This is the first time I'm trying to write a C program to be linked with R by my own and I've got one (main) problem 1) I've got a stack of big matrixes, so to manage them I' using save() in the preparation process to save workspace (they are about 1000 matrixes and each one occupies 4.2 MB in my hard disk): > for ( i in 1:1000) { ... save(temp, file=paste("temp_matrix",i,"R.sav",sep="")) } Later on, I would need to be able to use something like load(paste("temp_matrix",i,"R.sav",sep="")) to reload the corresponding matrix in each of the loops running within the C code, and to be able to load this matrix, (called temp) into the C code. I've tried to load the vector into the R workspace using load(a[i]) where a is a vector with names of the maps, and also passing a list a in the call to the C code, where each element of the list a[[i]] is the name of each map, and tried to extract this names in the list to be used along with the expresion, but nothing works. With the html R-extensions help I've been able to load existing R objects in run time into C, but I'm not able to use load() to put saved R object into the R workspace and load them in C afterwards. Please, have anyone tried to use this succesfully? Or you have any clue? Thanks a lot for your help 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
[R] Best device for printing quality
Hi all; Just to ask you for your advise about what is the best way to get the best quality for graphics to be incorporated into a printed article (I'm mainly a Linux useR, but also use the windows R version) Thanks and best regards, Javier Garcia __ [EMAIL PROTECTED] 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] changing default labels of axis in ts plots
Hi; I'm in Spain and my locale and tz are the spanish one, and I'm using plot() with irregular time series. And I would like to change the default labels in x and y axis: 1) The labels of months in the x axis of the plots appear in Spanish - c("Enero,"Febrero",...) - and I would like them to appear in English - c("January","February",...) - without changing the locale settings of my computer. 2) Also, the labels refers to local time and I would like them to appear in UTC ("GMT") time. I've tried, in several ways, to pass the format and timezone "GMT" to the plot, with no result. Could these defaults be changed without a big effort? Thanks and best regards Javier G. __ [EMAIL PROTECTED] 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] Fwd: strptime() problem? - Resolved
Hi Gabor and everybody; Thanks Gabor, with the alternative step you've told me the problem is resolved. Comparing the two procedures: Extract from the source 'character' data: > rain$ts[2039:2046] [1] "25/03/2000 22:00:00 UTC" "25/03/2000 23:00:00 UTC" [3] "26/03/2000 00:00:00 UTC" "26/03/2000 01:00:00 UTC" [5] "26/03/2000 02:00:00 UTC" "26/03/2000 03:00:00 UTC" [7] "26/03/2000 04:00:00 UTC" "26/03/2000 05:00:00 UTC" Proc 1. The 5th el. of the obtained POSIXct serie goes out of itself - > rain.strptime <- strptime(rain$ts, format="%d/%m/%Y %H:%M:%S") > rain.strptime.ct <- as.POSIXct(rain.strptime,tz="GMT") > rain.strptime.ct[2039:2046] [1] "2000-03-25 23:00:00 CET" "2000-03-26 00:00:00 CET" [3] "2000-03-26 01:00:00 CET" "2000-03-26 03:00:00 CEST" [5] "2000-03-26 05:00:00 CEST" "2000-03-26 05:00:00 CEST" [7] "2000-03-26 06:00:00 CEST" "2000-03-26 07:00:00 CEST" > format(rain.strptime.ct[2039:2046],tz="GMT",usetz=TRUE) [1] "2000-03-25 22:00:00 GMT" "2000-03-25 23:00:00 GMT" [3] "2000-03-26 00:00:00 GMT" "2000-03-26 01:00:00 GMT" [5] "2000-03-26 03:00:00 GMT" "2000-03-26 03:00:00 GMT" [7] "2000-03-26 04:00:00 GMT" "2000-03-26 05:00:00 GMT" > as.numeric(rain.strptime.ct[2039:2046]) [1] 954021600 954025200 954028800 954032400 954039600 954039600 954043200 [8] 954046800 Proc 2. The obtained POSIXct serie is continuous, and it seems OK for me. - rain.chron <- chron(substring(rain$ts,1,10),substring(rain$ts,12,19),format=c("d/m/y","h:m:s")) rain.chron.ct <- as.POSIXct(rain.chron,tz="GMT") > rain.chron.ct[2039:2046] [1] "2000-03-25 23:00:00 CET" "2000-03-26 00:00:00 CET" [3] "2000-03-26 01:00:00 CET" "2000-03-26 03:00:00 CEST" [5] "2000-03-26 04:00:00 CEST" "2000-03-26 05:00:00 CEST" [7] "2000-03-26 06:00:00 CEST" "2000-03-26 07:00:00 CEST" > format(lluvia.chron.ct[2039:2046],tz="GMT",usetz=TRUE) [1] "2000-03-25 22:00:00 GMT" "2000-03-25 23:00:00 GMT" [3] "2000-03-26 00:00:00 GMT" "2000-03-26 01:00:00 GMT" [5] "2000-03-26 02:00:00 GMT" "2000-03-26 03:00:00 GMT" [7] "2000-03-26 04:00:00 GMT" "2000-03-26 05:00:00 GMT" > as.numeric(rain.chron.ct[2039:2046]) [1] 954021600 954025200 954028800 954032400 954036000 954039600 954043200 [8] 954046800 For me the problem is resolved by mean of package 'chron'. And it's as direct as the use of the first procedure. Just as a comment, I think that for a proper behaviour, the first procedure should give the same result. Shouldn't it? Thanks all and best regards. --- --- El Mar 17 Ago 2004 20:02, javier garcia - CEBAS escribió: > -- Mensaje reenviado -- > > Subject: RE: [R] Fwd: strptime() problem? > Date: Tue, 17 Aug 2004 11:57:46 -0400 (EDT) > From: "Gabor Grothendieck" <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] > > I am in a different time zone, EDT, on Windows XP and can't > replicate this but you might try reading the latest R News > article on dates and times for some ideas, viz. page 32 of: > >http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pd > > In particular, try converting them to chron and then doing > your manipulations in chron or else convert them from chron to > POSIXct: > >require(chron) >r.asc <- raincida$ts >r.chron <- chron(substring(r.asc, 1, 10), > substring(r.asc, 12, 19), format = c("d/m/y", "h:m:s")) > >r.ct <- as.POSIXct(r.chron) >format(r.ct, tz="GMT") # display POSIXct in GMT > > Date: Tue, 17 Aug 2004 16:25:12 +0200 > From: javier garcia - CEBAS <[EMAIL PROTECTED]> > To: Prof Brian Ripley <[EMAIL PROTECTED]>, > <[EMAIL PROTECTED]> Subject: [R] Fwd: strptime() problem? > > Hi all; > I've already send a similar e-mail to the list and Prof. Brian Ripley > answered me but my doubts remain unresolved. Thanks for the clarification, > but perhaps I wasn't clear enough in posting my questions. > > I've got a postgres database which I read into R. The first column is > Timestamp with timezone, and my data are already in UTC format. An > 'printed' extract of R character column, resulting from the times
[R] Fwd: strptime() problem?
Hi all; I've already send a similar e-mail to the list and Prof. Brian Ripley answered me but my doubts remain unresolved. Thanks for the clarification, but perhaps I wasn't clear enough in posting my questions. I've got a postgres database which I read into R. The first column is Timestamp with timezone, and my data are already in UTC format. An 'printed' extract of R character column, resulting from the timestamptz field is: raincida$ts: [2039] "25/03/2000 22:00:00 UTC" "25/03/2000 23:00:00 UTC" [2041] "26/03/2000 00:00:00 UTC" "26/03/2000 01:00:00 UTC" [2043] "26/03/2000 02:00:00 UTC" "26/03/2000 03:00:00 UTC" [2045] "26/03/2000 04:00:00 UTC" "26/03/2000 05:00:00 UTC" #And I need to convert this character column into POSIXct, for eventual work. #As I can see in the documentation, the process is to use strptime(), what #creates an object POSIXlt and doesn't allow to specify that the time zone of #the data is already UTC; followed by as.POSIXct() > lluvia.strptime <- strptime(raincida$ts, format="%d/%m/%Y %H:%M:%S") > lluvia.strptime.POSIXct <- as.POSIXct(lluvia.strptime,tz="GMT") A "printed" extract is: [2039] "2000-03-25 22:00:00 GMT" "2000-03-25 23:00:00 GMT" [2041] "2000-03-26 00:00:00 GMT" "2000-03-26 01:00:00 GMT" [2043] "2000-03-26 03:00:00 GMT" "2000-03-26 03:00:00 GMT" [2045] "2000-03-26 04:00:00 GMT" "2000-03-26 05:00:00 GMT" As we can see, elements [2043] differ. Shouldn't they be similar as the rest of the other shown elements? I thought this was a bug, but it seems that I've got and conceptual error.(?). This happens several times in my data, and produces eventual errors. Please, how could I resolved this? Thanks all, and best regards, Javier G. __ [EMAIL PROTECTED] 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] strptime() bug? And additional problem in package "tseries"
Hi all, I've got some problems with irts objects, one of which could be a bug: 1) Read a table with several columns from Postgres and the first column is Timestamp with timezone (this is OK). An extract is: raincida$ts: [2039] "25/03/2000 22:00:00 UTC" "25/03/2000 23:00:00 UTC" [2041] "26/03/2000 00:00:00 UTC" "26/03/2000 01:00:00 UTC" [2043] "26/03/2000 02:00:00 UTC" "26/03/2000 03:00:00 UTC" [2045] "26/03/2000 04:00:00 UTC" "26/03/2000 05:00:00 UTC" 2) Try to extract time from this column of the dataframe (bug?) > lluvia.strptime <- strptime(raincida$ts, format="%d/%m/%Y %H:%M:%S") # An extract is: [2038] "2000-03-25 21:00:00" "2000-03-25 22:00:00" "2000-03-25 23:00:00" [2041] "2000-03-26 00:00:00" "2000-03-26 01:00:00" "2000-03-26 03:00:00" [2044] "2000-03-26 03:00:00" "2000-03-26 04:00:00" "2000-03-26 05:00:00" # note that element [2043] is wrong. This happens several times in # the dataset. This will produce an eventual error because of omitted # and duplicated values 3) The additional problem is related with function time() for irts objects. I try to make an irts from several columns of the table read: > rain.irts <- irts(as.POSIXct(lluvia.strptime,tz="GMT"),cbind(raincida[[8]],raincida[[9]],raincida[[10]],raincida[[11]],raincida[[12]],raincida[[13]],raincida[[14]])) # this step doesn't seem to have any further problem. An extract is: 2000-03-25 22:00:00 GMT 0.275 0 0.07875 0.2 0 0.025 23.65 2000-03-25 23:00:00 GMT 0.275 0 0.07875 0.2 0 0.025 23.65 2000-03-26 00:00:00 GMT 0 0 0.001667 0.008333 0 0 0.5322 2000-03-26 01:00:00 GMT 0 0 0.001667 0.008333 0 0 0.5322 2000-03-26 03:00:00 GMT 0 0 0.001667 0.008333 0 0 0.5322 2000-03-26 03:00:00 GMT 0 0 0.001667 0.008333 0 0 0.5322 2000-03-26 04:00:00 GMT 0 0 0.001667 0.008333 0 0 0.5322 # But I try to extract the time part: >time(rain.irts, tz='GMT') # An extract is: [2039] "2000-03-25 23:00:00 CET" "2000-03-26 00:00:00 CET" [2041] "2000-03-26 01:00:00 CET" "2000-03-26 03:00:00 CEST" [2043] "2000-03-26 05:00:00 CEST" "2000-03-26 05:00:00 CEST" # There isn't a way for this time to be shown as 'GMT'? I guess sometimes it is shown as 'CET' and other times as 'CEST' depending of the lag between the locale and gmt (utc) times. But for me this is an additional problem as the output shows one or two hours more that UTC time. Thanks all, and best regards, Javier G. __ [EMAIL PROTECTED] 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] error using daisy() in library(cluster). Bug?
Hi, I'm using the cluster library to examine multivariate data. The data come from a connection to a postgres database, and I did a short R script to do the analisys. With the cluster version included in R1.8.0, daisy worked well for my data, but now, when I call daisy, I obtain the following messages: - Error in if (any(sx == 0)) { : missing value where TRUE/FALSE needed In addition: Warning message: binary variable(s) 116 treated as interval scaled in: daisy(concentracion.data.frame, stand = TRUE) - Al the variables in my dataframe are numeric. Although I've got NA values, and I've seen that if a do the analisys for a subset of the dataframe, selecting just columns with no NA, the result is good. Could this be a bug? Thanks, and best regards Javier __ [EMAIL PROTECTED] 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] Fwd: plot - labels in axis doubt, Resolved
Hi; Sorry for my last question, disregrad it. Sometimes this happens. I've just realized that with axTicks() I extract the values of the first axis and I can these with the ratio to label the second axis. Thanks Javier -- Mensaje reenviado -- Subject: plot - labels in axis doubt Date: Tue, 22 Jun 2004 11:08:17 +0200 From: javier garcia - CEBAS <[EMAIL PROTECTED]> To: R-Help <[EMAIL PROTECTED]> Hi all; I need to add lines to a plot and an additional axis in the right side with a specific scale for this second serie of data. I've seen once this but I can't find it now nor can manage to do it. The tickmarks can ve the same that the default left axis, but how could I indicate the labels? Let's say the left scale ranges from 0 to 100, and I need to say that the second scale is a specific ratio to this one (because I've choose that ratio between the max value of both series to multiply the second, and so be adapted to the plotting space of the first plotted serie) Can someone tell me about any example? Thanks and best regards, Javier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] plot - labels in axis doubt
Hi all; I need to add lines to a plot and an additional axis in the right side with a specific scale for this second serie of data. I've seen once this but I can't find it now nor can manage to do it. The tickmarks can ve the same that the default left axis, but how could I indicate the labels? Let's say the left scale ranges from 0 to 100, and I need to say that the second scale is a specific ratio to this one (because I've choose that ratio between the max value of both series to multiply the second, and so be adapted to the plotting space of the first plotted serie) Can someone tell me about any example? Thanks and best regards, Javier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] identify() - image()
Thanks Barry (and Thomas), I wanted it to extract information from imported maps from the GIS GRASS, with a few modifications the functions works also very well for this. Best regards, Javier --- El Mié 26 May 2004 19:40, Barry Rowlingson escribió: > javier garcia - CEBAS wrote: > > Hi all; > > Just to ask if you know about any available function in R to identify > > points in a image plotted in X11. Something like the function identify(), > > but able to extract (x,y,value) groups from the image. > > this is what I use: > > image.identify <- function(xyz, mark=T, digits=3){ > >nx <- length(xyz$x) - 1 >ny <- length(xyz$y) - 1 >if(!all(dim(xyz$z)==c(nx,ny))){ > stop("Really need image specified by cell edges") >} >res <- data.frame() >xy <- locator(1) >while(!is.null(xy)){ > xbin <- as.numeric(cut(xy$x,xyz$x)) > ybin <- as.numeric(cut(xy$y,xyz$y)) > if(mark){ >points(xy$x,xy$y,pch=19,cex=.5,col="blue") > > text(xy$x,xy$y,format(xyz$z[xbin,ybin],digits=digits),adj=-.2,col="blue") > } > cat("[",xbin,",",ybin,"] = ",xyz$z[xbin,ybin],"\n",sep='') > res <- > rbind(res,data.frame(i=xbin,j=ybin,x=xy$x,y=xy$y,z=xyz$z[xbin,ybin])) > xy <- locator(1) >} >res > } > > Try: > > m=list(x=1:11,y=1:11,z=matrix(runif(100),10,10)) > > image(m) > > identify.image(m) > > then click some things. Button 2 to finish. > > The returned data frame gives row and column in the 'z' matrix, x and > y coordinates, and value of the z matrix at that point. > > Baz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] identify() - image()
Hi all; Just to ask if you know about any available function in R to identify points in a image plotted in X11. Something like the function identify(), but able to extract (x,y,value) groups from the image. Thanks and best regards, Javier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] integrate over a serie
Hi all; I've got temporal series of data. And I'm plotting it with the type 'l', and with a interpolating slipe. Could you advise me about the best way to calculate the area under any of these curves. I know it is very easy to calculate the first one, although have no idea of the second one. But, perhaps there is a function that I can't find to do directly these integration? Thanks and best regards, Javier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] formated output
Hi all; I need to create ASCII files as output from R and I'm using sink(), cat(), and paste() for this. My problem is that the ASCII files hace several columns, and I would like to know if intermediate columns (the second one for example) could be alineated to the right. My values are integer ranging from 1 to 1000. Thanks a lot. Best regards, Javier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] precision in operations
Hi all; could you remind me what is the function to change the precision of the operations done in R? I can't remember nor find it. Best regards Javier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] output in a list
Hello. I've got a very short question. I've got a vector with about 800 numbers; and I would like to put them in a file, but I need them to be written just one value in each row. Is this possible? Best regards Javier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] three short questions
Hi all; This is my first message to the list, and I've got three "basic" questions: How could I insert comments in a file with commands to be used as source in R? Is it possible to quickly display a window with all the colors available in colors()? How? I'm displaying points, but they overlap, wether points() uses triangles, bullets or whatever. Is it possible to change (diminish) the size of the symbols? Thanks all, Javier __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help