[R] how to produce 2-d color plots in R

Liaw, Andy andy_liaw at merck.com
Fri Jan 14 19:00:03 CET 2005


Cut and paste the following function (to be in next release of R, I believe)
and type:

RSiteSearch("election maps")

This, of course, assumes that you have Internet connection.

Andy

RSiteSearch <- function(string,
                        restrict=c("Rhelp02a","Rhelp01","functions","docs"),
                        format="normal", sortby="score", matchesPerPage=20)
{
    string <-
paste("http://finzi.psych.upenn.edu/cgi-bin/namazu.cgi?query=",
                    gsub(" ", "+", string), sep="")
    mpp <- paste("max=", matchesPerPage, sep="")

    format <- charmatch(format, c("normal", "short"))
    if (format == 0) stop("format must be either normal or short")
    format <- paste("result=", switch(format, "normal", "short"), sep="")

    sortby <- charmatch(sortby, c("score", "date:late", "date:early",
                                  "field:subject:ascending",
"field:subject:decending",
                                  "field:from:ascending",
"field:from:decending",
                                  "field:size:ascending",
"field:size:decending",
                                  "field:uri:ascending",
"field:uri:decending",))
    if (sortby == 0) stop("wrong sortby specified")
    sortby <- paste("sort=",
                    switch(sortby, "score", "date:late", "date:early",
                                  "field:subject:ascending",
"field:subject:decending",
                                  "field:from:ascending",
"field:from:decending",
                                  "field:size:ascending",
"field:size:decending",
                                  "field:uri:ascending",
"field:uri:decending"),
                    sep="")

    res <- ""
    if ("Rhelp02a" %in% restrict) res <- "idxname=Rhelp02a"
    if ("Rhelp01" %in% restrict) res <- paste(res,"idxname=Rhelp01",sep="&")
    if ("docs" %in% restrict) res <- paste(res,"idxname=docs",sep="&")
    if ("functions" %in% restrict) res <-
paste(res,"idxname=functions",sep="&")
    if (res=="") {print("Using defaults: Rhelp 2002-; functions; docs.")
      res <-
paste("idxname=Rhelp02a&idxname=functions&idxname=docs",sep="")}
    res <- sub("^&+","",res)

    qstring <- paste(string, mpp, format, sortby, res, sep="&")
    browseURL(qstring)
    invisible(qstring)
}





> From: Yogesh K. Tiwari
> 
> Hello 'R' Users,
> 
> I am very new on 'R', so excuse me if I ask something wrong.
> 
> I have ASCII data and the colums of the data are looks like :-
> 
> 
> !-------------------------
> time,yr,mo,dy,hr,min,sec,lat,lon,ht,co2obs,sigma,co2model
> --
> -
> --
> 
> !----------------------------
> 
> Each column has data value. Now I want to produce 2-d color maps,
> for example the plot should look like :-
> 
> on x-axis =lon    ,   on y-axis=lat
> 
> and on these two axis I want to shade  or fill co2model values.
> 
> Also, after ploting how I can draw the continent line, for
> example the data belongs North America, so how the plot
> recognise the continent line.
> 
> Can this type of color plot is possible in R.
> 
> Pls help !!!
> 
> 
> Many thanks in advance,
> 
> Regarda,
> Yogesh
> 
> -
> 
> ===========================================
> Yogesh K. Tiwari,
> Max-Planck Institute for Biogeochemistry,
> Beutenberg Campus, Hans-Knoell-Strasse 10,
> D-07745 Jena,
> Germany
> 
> Office   : 0049 3641 576376
> Home     : 0049 3641 223163
> Fax      : 0049 3641 577300
> Handy    : 0049 173 698 8789
> e-mail   : yogesh.tiwari at bgc-jena.mpg.de
> 
> ______________________________________________
> R-help at 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
> 
>




More information about the R-help mailing list