[R] Equate two (or more) functions

2012-04-25 Thread pannigh
Dear List, I was wondering if there is a simple way to solve (equate) two functions in R. For example: (1) 5x + 3y = 30 (2) 12x - 2y = 26 I would like R to finde x = 3 and y = 5 Is there an implemented function in R or would I have to write an own function? Thank you very much for your help.

[R] Intercept between two lines

2012-04-25 Thread pannigh
Dear List, I know this is not the first post on this topic, but I need basic help I guess. Assuming the simple case of two lines with one intercept, how can I make R calculate this intercept, NOT using locator(). par (xaxs="i", yaxs="i") plot( 1, bty="n" ,xlim=c(0,300) , ylim=c(0,300) , xlab="X",

Re: [R] Intercept between two lines

2012-04-26 Thread pannigh
Thank you Jorge, this did get me started and who else might be interested in the topic, a possible code could be something like: # Define the functions f1 <- function(x) 100-0.5*x f2 <- function(x) 150- x # Plot the functions par (xaxs="i", yaxs="i") plot(

[R] Using if and else in a data frame

2012-04-26 Thread pannigh
Dear list, I get the ifelse function to work on a data frame but don't know how to do something similar (only more conditions) with the combination of if and else like in the example: A <- c("a","a","b","b","c","c") B <- c(rep(2,6)) dat <- data.frame(A,B) dat$C <- if(AB$A=="a") {AB$B^2} else

Re: [R] braking a label in two lines when using expression()

2012-05-03 Thread pannigh
Your code did not run on my computer, however the "atop" function should do what you are looking for I guess. This is more or less your axis, only changed a bit in your formula, think it looks better this way: e.g. par(mar=c(5,7,.5,.5), las=1, adj=.5, cex.lab=1.5) plot(1, type="n" , xlab="Wee

[R] additional axis, different scale

2012-05-10 Thread pannigh
Dear list, I am looking for a possibility to present results in a more graphical way by adding an axis. But I have trouble relating my data to the added axis. Imagine the following example: a <- c(10, 20, 30, 40) b <- c(50, 250, 500, 600) ba <- b/a par(las=1, mar=c(5,5,.5,5)) plot(a,b, type

Re: [R] additional axis, different scale

2012-05-10 Thread pannigh
Hi Jim, hi John, thank you very much for your tips. The "plotrix" package solves the problem! However, thank you also for the advice that my way of plotting the data might not be the best. I will think about it. So once again thanx ! -- View this message in context: http://r.789695.n4.nabble.c

[R] Transfering data from R list to other document format

2012-05-15 Thread pannigh
Dear users, I want to transfer a list of results from R to some practical format, from where I can continue manipulating, copying,... the values, e.g. : list1 <- list("My first list", matrix(1:6, ncol=3), c(1,2,3,4,5,6) ) # Imagining I forgot something and want to add it to the list like: list1[[4

Re: [R] counts on bars on barplot

2012-05-15 Thread pannigh
If you use simple barplot graphic try this, e.g.: a<-barplot(some.data) text(a, some.data, some.data) The "text" command needs x and y coordinates, by assigning your barplot to "a" (here), you have the x coordinats and by using the y-values of the barplot, the values will be written ontop of the

Re: [R] Transfering data from R list to other document format

2012-05-15 Thread pannigh
Thanx for your effort answering by phone! dput (list, "list.txt") does write something to a text doc but in a confusing manner. All previous commands that created the list seem to appear. However, I will check out the pack you mentioned. Guess my aim would be to read the list into a simple .txt f

Re: [R] Transfering data from R list to other document format

2012-05-15 Thread pannigh
Yup, “rapply“ does the magic. Thank you very much, this command is new to me! My “glaringly obvious error” is indeed very obvious and was a result of constructing an example here and copying my “lapply” command into the text. So don't worry, when the question arose both names were identical Once