Re: [R] Grid lines
Maybe this helps par(mar = c(5,4,6,1)) plot(1:10, type = "n", axes = F) xticks = axis(1, at = c(1,5,9), labels = c("1-1-2009","1-5-2009","1-9-2009")) #set axis manually yticks = axis(2, at = 1:10) #set axis manually abline(v = xticks, col = "gray") #verticall lines abline(h = yticks, col = "gray", lty = 3) #horizontal lines legend(8,12, legend = c("test", "test"), col = 1:2, pch = 1:2, xpd = TRUE) points(1:10) Thomas Roth Chris Li schrieb: Hi everyone. I am new to R. It will be greatly appreciated if someone can help me with the following questions. Here's the graph I have just produced. http://www.nabble.com/file/p24732839/calibration.jpeg (1) How can I put the legend on top of the grid lines? (2) How can I match the grid lines with the x-axis ticks? (3) How can I change the x-axis format from e.g. Mar, Apr...etc to 1-3-2009,1-4-2009...etc? Many thanks! :-) Chris __ R-help@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.
Re: [R] Grid lines
Maybe this helps par(mar = c(5,4,6,1)) plot(1:10, type = "n", axes = F) xticks = axis(1, at = c(1,5,9), labels = c("1-1-2009","1-5-2009","1-9-2009")) #set axis manually yticks = axis(2, at = 1:10) #set axis manually abline(v = xticks, col = "gray") #verticall lines abline(h = yticks, col = "gray", lty = 3) #horizontal lines legend(8,12, legend = c("test", "test"), col = 1:2, pch = 1:2, xpd = TRUE) points(1:10) Thomas Roth Chris Li schrieb: Hi everyone. I am new to R. It will be greatly appreciated if someone can help me with the following questions. Here's the graph I have just produced. http://www.nabble.com/file/p24732839/calibration.jpeg (1) How can I put the legend on top of the grid lines? (2) How can I match the grid lines with the x-axis ticks? (3) How can I change the x-axis format from e.g. Mar, Apr...etc to 1-3-2009,1-4-2009...etc? Many thanks! :-) Chris __ R-help@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.
Re: [R] Adding picture to graph?
Have a look at http://www.stat.auckland.ac.nz/~paul/RGraphics/chapter3.html Picture 3.26 Thomas Roth Rainer M Krug schrieb: Hi while teaching R, the question came up if it would be possible to add a picture (saved on the HDD) to a graph (generated by plot()), which we could not answer. It might easily kill a clean graph, but: is there a way of doing this, even one should not do it? On a similar line of thought: is it possibe to define own symbols so that they can be used in the plot function with pch=? Rainer __ R-help@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.
Re: [R] SOLVED: how to evaluate character vector within pnorm()
That what i was looking for :-) bill.venab...@csiro.au schrieb: Here is one way: x <- c(2,3) names(x) <- c("mean", "sd") do.call(pnorm, c(list(0), as.list(x))) Bill Venables http://www.cmis.csiro.au/bill.venables/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas Roth (geb. Kaliwe) Sent: Friday, 17 July 2009 6:03 PM To: 'r-help@r-project.org' Subject: [R] how to evaluate character vector within pnorm() Hi, I'm trying to evaluate a character vector within pnorm. I have a vector with values and names x = c(2,3) names(x) = c("mean", "sd") so that i tried the following temp = paste(names(x), x, sep = "=") #gives #> temp #[1] "mean=2" "sd=3" #Problem is that both values 2 and 3 are taken as values for the mean argument in pnorm pnorm(0, eval(parse(text = temp)) ) #but not as pnorm(0, mean = 2, sd = 3 ) #How can i get pnorm(0, eval(parse(text = temp)) ) #to do pnorm(0, mean = 2, sd = 3 ) Thank you for your time Thomas Roth __ R-help@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. __ R-help@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.
[R] how to evaluate character vector within pnorm()
Hi, I'm trying to evaluate a character vector within pnorm. I have a vector with values and names x = c(2,3) names(x) = c("mean", "sd") so that i tried the following temp = paste(names(x), x, sep = "=") #gives #> temp #[1] "mean=2" "sd=3" #Problem is that both values 2 and 3 are taken as values for the mean argument in pnorm pnorm(0, eval(parse(text = temp)) ) #but not as pnorm(0, mean = 2, sd = 3 ) #How can i get pnorm(0, eval(parse(text = temp)) ) #to do pnorm(0, mean = 2, sd = 3 ) Thank you for your time Thomas Roth __ R-help@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.
Re: [R] SOLVED: how to check if ... is empty
Thank you both. Thomas Dimitris Rizopoulos schrieb: one way is: test <- function(x, y, ...) { dots <- list(...) if (length(dots)) cat("\nnon-empty\n") else cat("\nempty\n") } test(1, 1) test(1, 1, 1) I hope it helps. Best, Dimitris Thomas Roth (geb. Kaliwe) wrote: Hi, I was wondering what would be the best way to check if the three dots argument contains any arguments (i.e. does ... contain any arguments or not? ) #Example test = function(x,y, ...) { #Wanted R-Code # if(empty(...)) #do some calculation plot(x,y,...) } Thanks Thomas Roth __ R-help@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. __ R-help@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.
[R] how to check if ... is empty
Hi, I was wondering what would be the best way to check if the three dots argument contains any arguments (i.e. does ... contain any arguments or not? ) #Example test = function(x,y, ...) { #Wanted R-Code # if(empty(...)) #do some calculation plot(x,y,...) } Thanks Thomas Roth __ R-help@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.
Re: [R] paste (" " x " ")
maybe this helps x = "\"test\"" plot(1:10, main = x) #heading contains " " #or cat("\"test\"") Thomas Roth Paulo E. Cardoso schrieb: maybe a very basic question but I need to parse an SQL code into a GIS from a ODBC conn. The code includes a specific sentence OPTIONS COORDSYS("Latitude / Longitude"); and I need the " " pasted into the string. They cannot disappear. how to do this? Paulo E. Cardoso [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] more than one mathematical annotation into a legend
in the legend there's x but not the value of x which actually should be shown... #does not work x = 2 plot(1:10) legend(4,4, expression(t[m] == x, t[n] == x)) #legend contains x but not the value of x So this won't work Zhiliang Ma schrieb: On Thu, Jul 9, 2009 at 9:39 AM, Thomas Roth (geb. Kaliwe) wrote: try this: legend(4,4, expression(t[m] == x, t[n] == x)) cheers, Zhiliang Dear members, Is there a way to put more than one mathematical annotation into a legend together with a calculated value? x = 2 plot(1:10) #Works legend(8, 8, substitute(t[m] == x)) #does not work legend(4,4, c(substitute(t[m] == x), substitute(t[n] == x))) Thanks Thomas Roth __ R-help@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. __ R-help@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.
[R] more than one mathematical annotation into a legend
Dear members, Is there a way to put more than one mathematical annotation into a legend together with a calculated value? x = 2 plot(1:10) #Works legend(8, 8, substitute(t[m] == x)) #does not work legend(4,4, c(substitute(t[m] == x), substitute(t[n] == x))) Thanks Thomas Roth __ R-help@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.
Re: [R] lattice wireframe within a loop ??? - solved
Thank you. ONKELINX, Thierry schrieb: You need to print() lattice plots inside a loop or a function. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Thomas Roth (geb. Kaliwe) Verzonden: woensdag 24 juni 2009 13:08 Aan: 'r-help@r-project.org' Onderwerp: [R] lattice wireframe within a loop ??? Hi, I have the following problem. Calling wireframe within a loop results into an empty window(s) #generate some data temp = expand.grid(A = 1:3,B = 1:3) temp = cbind(temp, y1 = rnorm(9)) temp = cbind(temp, y2 = runif(9)) #plot y1 and y2 in two different windows for(i in 1:2) { wireframe(y1 ~ A*B, temp, shade =T) windows() wireframe(y2 ~ A*B, temp, shade =T) } #However, calling it twice outside a loop works? wireframe(y1 ~ A*B, temp, shade =T) windows() wireframe(y2 ~ A*B, temp, shade =T) Obviously i'm missing something. How can i call wireframe more than one time in a loop and get a wireframe? Greetings Thomas Roth __ R-help@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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@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.
[R] lattice wireframe within a loop ???
Hi, I have the following problem. Calling wireframe within a loop results into an empty window(s) #generate some data temp = expand.grid(A = 1:3,B = 1:3) temp = cbind(temp, y1 = rnorm(9)) temp = cbind(temp, y2 = runif(9)) #plot y1 and y2 in two different windows for(i in 1:2) { wireframe(y1 ~ A*B, temp, shade =T) windows() wireframe(y2 ~ A*B, temp, shade =T) } #However, calling it twice outside a loop works? wireframe(y1 ~ A*B, temp, shade =T) windows() wireframe(y2 ~ A*B, temp, shade =T) Obviously i'm missing something. How can i call wireframe more than one time in a loop and get a wireframe? Greetings Thomas Roth __ R-help@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.
[R] S4 Package with definition of method 'names'
Dear List, Is it possible to build a package with 'names' method for a S4-Class? The following works if directly pasted into R: (a simple test class with 1 attribute that is returned by invoking 'names') #class definition setClass("test", representation = representation(name = "character"), prototype = prototype(name = "thisIsMyName")) #definition of names for class test setMethod("names", "test", function(x) { x...@name } ) #definition of names<- for class test setReplaceMethod("names", "test", function(x, value) { x...@name <- value x } ) test = new("test") names(test) #returns "thisIsMyName" However 'R CMD check ' for building a package fails with Error in setMethod(f, signature, NULL, where = where) : the method for function "names" and signature ="" is sealed and cannot be re-defined Calls: ... sys.source -> eval -> eval -> removeMethod -> setMethod Execution halted make[2]: *** [lazyload] Error 1 make[1]: *** [all] Error 2 make: *** [pkg-DAP] Error 2 This is somewhat confusing since it works nicely if pasted into R. Any Ideas Thank you for your time Thomas Roth __ R-help@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.
[R] possible overloading of interaction.plot ???
Dear Members, i have defined a S4-class and a function for that class wich is to be called interaction.plot. Problem: interaction.plot already exists so setMethod(f = "interaction.plot", signature = "myClass", definition = function(x){ invisible() }) Fehler in conformMethod(signature, mnames, fnames, f, fdef, definition) : In method for function "interaction.plot": formale Argumente, die in der Methodendefinition ausgelassen wurden, können nicht in der Signatur (x.factor = "myClass") sein won't work because it is already defined. Is there a solution that keeps the original interaction.plot and lets me define a interaction.plot for objects of my S4-Class? Thank you for your time Thomas Roth __ R-help@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.
Re: [R] Create Pie chart from .csv file
Sorry for mailing to you personally... for types read.csv(file.choose()) freqTable = table(types) pie(freqTable) ##example for some data temp = data.frame(types = 1:10) pie(table(temp)) Thomas Roth PS: use barplot instead of pie DonkeyRhubarb schrieb: Hi all, I am looking to create a pie chart from a given column in a .csv file. My class variables are as follows: entry_type, uniquekey, types, title,url, abstract, journal, author, month, year, howpublished So say I want to export a pie chart that groups together all entries under 'types' e.g. 3 x statistics 2x education etc. Im looking to have a piechart represent this graphically that shows which type of entry is in most frequently. Preferably I'd like to export to a PDF chart and while I can do this by typing variables directly into the R console, I cannot manage it from a .csv file. If you cannot help me with this specific problem, just knowing how to create a generic pie chart would be a great help. This is part of my final software project which is due in one week. I would very much appreciate any help. Many thanks in advance __ R-help@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.
Re: [R] Import R-output into Java
#I used sink ?sink #Thomas Maxl18 schrieb: Hello, I want to import R-output via Rserve to Java, especially for the function ctree from the package party. Rserve is working properly. Yet, I only get the predictions with the Java code try{ RConnection c = new RConnection(); ... c.voidEval("modell <- ctree(...)"); REXP y = c.eval("nodes(modell,1)[[1]]$prediction"); ... }catch(Exception e){} When I try to get the whole text with REXP z = c.eval("nodes(modell,1)[[1]]"); System.out.println(z); I get something like org.rosuda.rengine.rexpgenericvec...@119c082+[10]named But I want the text which is printed in R. What can I do? Thanks, Max Once again: It`s clear to get the result in R but I don`t know hoe to get the R-output into Java (or into a file, i.e. .txt) __ R-help@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.
[R] S4 coerce as.data.frame for lm
#Hi, # #For a given class test, an object of class test cannot be used as data in the lm method although as.data.frame was implemented... where's my mistake? # #Suppose i have defined a S4 class test #S4 Class test containting a slot data #which is of type data.frame setClass(Class = "test", representation = representation(name = "character", data = "data.frame") temp = new("test") #temp is of class test t...@data = faithful #assign some data to it #now define as.data.frame for class test setMethod("as.data.frame", "test", function(x, row.names = NULL, optional = FALSE) { return(x...@data) } ) as.data.frame(temp) #works lm(eruptions ~ waiting, data = temp) #doesn't work #Thank you for any hints #Thomas Roth #from the lm help page |#data| - an optional data frame, list or environment (or object coercible by |as.data.frame| to a data frame) containing the variables in the model. If not found in |data|, the variables are taken from |environment(formula)|, typically the #environment from which |lm| is called. __ R-help@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.
Re: [R] lattice: remove box around a wireframe
:-) works! Sundar Dorai-Raj schrieb: (Sorry for the repeat. Forgot to copy R-help) Try, test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c("x", "y", "z") require(lattice) wireframe(z ~ x*y, data = test, par.settings = list(axis.line = list(col = "transparent")), par.box = c(col = "transparent") ) --sundar On Wed, Mar 4, 2009 at 8:17 AM, Thomas Roth (geb. Kaliwe) wrote: #Hi, # #somebody knows how to remove the outer box around a wireframe and reduce the height # # test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c("x", "y", "z") require(lattice) wireframe(z ~ x*y, data = test, par.box = c(col = "transparent") ) #not this one but the remaining outer box. Thanks in advance Thomas Roth __ R-help@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. __ R-help@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.
[R] lattice: remove box around a wireframe
#Hi, # #somebody knows how to remove the outer box around a wireframe and reduce the height # # test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) = c("x", "y", "z") require(lattice) wireframe(z ~ x*y, data = test, par.box = c(col = "transparent") ) #not this one but the remaining outer box. Thanks in advance Thomas Roth __ R-help@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.
Re: [R] Help on BarPlot
Hi, #There are a lot of examples for barplot if you just type example(barplot) # i altered one slightly to put the values on top of each bar mp <- barplot(VADeaths) # default #tot <- colMeans(VADeaths) #changed this line tot = colSums(VADeaths)#wether you need max, min, mean , colSums will depend on your data text(mp, tot + 4, format(tot), xpd = TRUE, col = "blue") #you should be able to get it from here Thomas Steve Sidney schrieb: Dear all As a new user of R, can someone please help me with the following I have created a programme to analyse laboratory data and one of the graphs is a bar plot of 'Z' scores. On the bar plot I am using the following line to plot some results barplot (zb[,c("ZBW")], ylim = c(-6,6), names.arg=zb[,c("LabNo")],xlab="Lab Code Number", cex.names = .5 , axis.lty=1 , main = " Total Coliform ") What I would like to do is move the xlab parameter to sit on top or on each bar and not on the x-axis at y=0. Any help would be appreciated. Thanks Steve [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] plot Ticks
you could set them manually, if thats what you're looking for plot(1:10, axes = F) axis(1, at = seq(1,10 , length = 3)) mau...@alice.it schrieb: Is there a way to force the number of ticks along an axis ? I read the on-line documentation and tried many combinations of all available parameters from functions par(), axTicks(), axis(), plot() ... but no luck ! Thank you very much, Maura tutti i telefonini TIM! [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] Tinn-R
First thing you need to do is, save the file with an .r ending. Tinn-R will then come up with syntax highlighting (as far as i remember). Options->Main->Application leads you to the r-configuration... HTH Thomas Tibert, Brock schrieb: Tibert, Brock schrieb: Hi Everyone, I was hoping someone could help me with the settings for Tinn-R. I see in the screen shots that it has syntax help, or something similar (tips on what functions, etc). I can not seem to get this to turn on in the program, and I am wondering if I have to set up a few options. I quickly read through the help and could not figure it out. Many thanks! - Brock P.S. It appears as if Tinn-R is widely used, but would you recommend something different? I am new to R and programming, but have learned (somewhat) using VBA editors I have grown to love to the intelligent typing that goes along with it. [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.