Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread baptiste auguie
[correcting a stupid error in my previous post] testTwoStages <- function(x, y, head.stop = 100){ if(!isTRUE(all(head(x, head.stop) == head(y, head.stop { print(paste("quick test returned FALSE")) return(FALSE) } else { full.test = isTRUE(all(tail(x, length(x) - head.stop) == tail(

Re: [R] searching help for partial matches

2009-06-17 Thread baptiste auguie
Steve Jaffe wrote: The situation is that I know there is a function and know approximately what the name is, and want to find the exact name. Is there a way of searching for near-matches (similar to unix apropos). For example, I know there is a function called something like allequal (or allequal

Re: [R] Warning messages when using rbind

2009-06-21 Thread baptiste auguie
Hi, You seem to have a glitch in one file, testread12=read.table("Test100.txt", head = T) str(testread12) # Column131 is converted to a factor # $ Column131: Factor w/ 2920 levels "--","-0.000122393",.. combining the second data set with this one will convert the new data into factor for this

Re: [R] curvedarrow (some graphics problem)

2009-06-23 Thread baptiste auguie
Hi, Grid offers several functions to help drawing such graphs, see Paul Murrell's "Can R Draw Graphs? " (useR! 2006) I came up with this, as a quick example, vp <- viewport( x = unit(0, "npc"), y = unit(0, "npc"), just = c("left", "bottom"), xscale = c(-1, 1) , yscale = c(-1, 1)) vp2 <- vi

Re: [R] Apply as.factor (or as.numeric etc) to multiple columns

2009-06-23 Thread baptiste auguie
Wacek helped me out on a similar topic a while back, ize = function (d, columns = names(d), izer = as.factor) { d[columns] = lapply(d[columns], izer) d } d = data.frame(x=1:10, y=1:10, z =1:10) str( ize(d, 'y') ) # y is now a factor str( ize(d, 1:2, `cumsum`) ) # x and y are affected etc

Re: [R] curvedarrow (some graphics problem)

2009-06-24 Thread baptiste auguie
You're right, I meant to write "lines"not "line". The strange thing is, although "line" isn't listed in ?unit, it doesn't return an error on my machine, > unit(-1, "line") [1] -1line > unit(-1, "lines") [1] -1lines Reading from http://svn.r-project.org/R/trunk/src/library/grid/src/unit.c "l

Re: [R] lattice multipanel strip placement - with two factors

2009-03-23 Thread baptiste auguie
I'm not sure I understood your problem (can you provide an reproducible example?), but perhaps you can try useOuterStrips() in the latticeExtra package (the formatting becomes similar to that of the ggplot2 package, perhaps another option to consider) Hope this helps, baptiste On 23 Mar

Re: [R] Problems with combining plots

2009-03-23 Thread baptiste auguie
On 23 Mar 2009, at 11:52, johnhj wrote: I have still the same problem... As you said I tried with par(mfrow=c(2,1)) and par(mfrow=c(1,2)) but without success. Could R compiler be the problem ? Why not? But may I suggest you try first the following example I sent you yesterday, pn

Re: [R] Looping of read.table and assignment

2009-03-23 Thread baptiste auguie
You need only one loop, year <- 1951:2000 filelist <- paste("C:\\Documents and Settings\\Data\ \table_",year,".txt", sep="") filelist for (ii in seq_along(year)) { assign(paste("table_", year[ii], sep=""), read.table(file=ifile[ii], header=TRUE, sep

Re: [R] Replacing a few variable values within a DataFrame...

2009-03-23 Thread baptiste auguie
On 23 Mar 2009, at 17:39, Jason Rupert wrote: I would like to replace a few varaibles within a data frame. For example, in the dataframe below (contrived) I would like to replace the current housesize value only if the Location is HSV. However, I would like to leave the other values int

Re: [R] How to set up a function for "Central Limit Theorem"

2009-03-23 Thread baptiste auguie
(a <- replicate(5,rnorm(10))) colMeans(a) should get you started. HTH, baptiste On 23 Mar 2009, at 18:29, pfc_ivan wrote: I tried using the for (i..) to make 1000 differents sets of numbers, but then I dont know how to get the mean value of all of them... because I dont even think 1000

Re: [R] Manual sort in a for loop

2009-03-25 Thread baptiste auguie
well, the literal answer is that paste("arunoff_",table_year,"_temp") is a character vector of length 1 so your indexing cannot work. What you want is to index the data that corresponds to this variable name, ?get But I should stress that this manipulation with assign and get seems complete

[R] "[.data.frame" and lapply

2009-03-25 Thread baptiste auguie
Dear all, Trying to extract a few rows for each element of a list of data.frames, I'm puzzled by the following behaviour, d <- lapply(1:4, function(i) data.frame(x=rnorm(5), y=rnorm(5))) str(d) lapply(d, "[", i= c(1)) # fine, this extracts the first columns lapply(d, "[", j= c(1, 3)) #

Re: [R] "[.data.frame" and lapply

2009-03-25 Thread baptiste auguie
thanks to some off-list replies, I got this to work, On 25 Mar 2009, at 18:56, baptiste auguie wrote: Dear all, Trying to extract a few rows for each element of a list of data.frames, I'm puzzled by the following behaviour, d <- lapply(1:4, function(i) data.frame(x=rnorm(5), y

Re: [R] "[.data.frame" and lapply

2009-03-26 Thread baptiste auguie
-0.25873225 > > However, we would still have this, which is expected (same as > d[1:2] ): > >> `[.data.frame`(d, i=1:2) >x y > 1 0.45141341 0.03943654 > 2 -0.87954548 1.83690210 > 3 -0.91083710 0.22758584 > 4 0.06924279 1.26799176 > 5 -

Re: [R] Reading in files with variable parts to names

2009-03-26 Thread baptiste auguie
Hi, If your directory contains only files you want to load anyway, then list.files() is your friend, list.files(pattern = "comp") # or pattern =".asc" for example If you do need to create the names manually, then you could create the combinations with expand.grid, as in, do.call(paste

Re: [R] Ploting a matrix

2009-03-27 Thread baptiste auguie
Something like this perhaps, a <- matrix(rnorm(5*49), ncol=49) pdf(width=15, height=15) par(mfrow= c(8,6)) apply(a[,-1], 2, plot, x= a[,1]) dev.off() HTH, baptiste On 27 Mar 2009, at 11:05, skrug wrote: Hi evrybody, in a matrix consisting of 49 columns, I would like to plot all column

Re: [R] color vectors other than gray()

2009-03-27 Thread baptiste auguie
?colorRamp Hope this helps, baptiste On 27 Mar 2009, at 13:16, Paulo E. Cardoso wrote: I'm trying to create a graph where different cells of a grid (a shapefile) will be painted with a color share scale, where the most easy way is to use gray(). Can I somehow get a vector (gradient) of c

Re: [R] color vectors other than gray()

2009-03-27 Thread baptiste auguie
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I need to discriminate shading level accordingly to the abundance value (level). I don't know how to proceed. Paulo E. Cardoso -Mensagem original- De: baptiste auguie [mailto:ba...@exeter.ac.uk] Enviada: sexta-feira,

Re: [R] Ploting a matrix

2009-03-27 Thread baptiste auguie
wing columns with vectors. apply(b[,-1], 2, plot, x= b[,1]) Also all columns have the same length, [R] states that the length are different. Can you help me? baptiste auguie schrieb: Something like this perhaps, a <- matrix(rnorm(5*49), ncol=49) pdf(width=15, height=15) par(mfrow= c(8,6)) ap

Re: [R] Ploting a matrix

2009-03-27 Thread baptiste auguie
3699 8375 19200 36563 83993 123167 $ X6 : int 248 730 3056 2327 4092 8905 15931 37895 84565 Thanks baptiste auguie schrieb: the result of read.table is a data.frame, not a matrix as you first suggested. Can you copy the result of str(b) so we know what your data is made of? I'

Re: [R] Assignment to variables fails to loop

2009-03-27 Thread baptiste auguie
The variable name in your call to assign should vary within the for loop, otherwise you're always assigning the value to the same variable. Consider the following example, listOfNames <- c("a", "b", "c") listOfVariables <- c("vara", "varb", "varc") for(index in seq_along(listOfNames)){

Re: [R] text matching and substitution

2009-03-28 Thread baptiste auguie
yet another attempt, colours <- as.character(paste(letters,colours(),"stuff",LETTERS)) target <- c("red","blue","green","gray") matches <- melt(sapply(target, grep, x=colours)) colours[matches$value] <- matches$L1 (probably a worse idea than a straight for loop, though) baptiste On 2

Re: [R] how to input multiple .txt files

2009-03-30 Thread baptiste auguie
may i suggest the following, a <- do.call(rbind, lapply(cust1_files, read.table)) (i believe expanding objects in a for loop belong to the R Inferno) baptiste On 30 Mar 2009, at 12:58, Mike Lawrence wrote: cust1_files = list.files(path=path_to_my_files,pattern='cust1',full.names=TRUE) a

Re: [R] Using apply to get group means

2009-03-31 Thread baptiste auguie
Not exactly the output you asked for, but perhaps you can consider, library(doBy) > summaryBy(x3~x2+x1,data=x,FUN=mean) x2 x1 x3.mean 1 1 A 1.5 2 1 B 2.0 3 1 C 3.5 4 2 A 4.0 5 2 B 5.5 6 2 C 6.0 the plyr package also provides similar functionality, as do t

Re: [R] STACK

2009-04-01 Thread baptiste auguie
perhaps, unlist(d, use.names=F) baptiste On 1 Apr 2009, at 22:15, oscar linares wrote: Dear Rxperts I have a data.frame as follows ABCD 14 710 25 811 36 912 I want to convert it to a data frame with a single row (i.e., stack the columns w

Re: [R] how to sort and group the data?

2009-04-02 Thread baptiste auguie
try this, d = read.table(textConnection("USER NAME 12 admin 12 admin 10 admin 10 advertising 61 process 17snapshot 61ticket 61ticket 30snapshot 10advertising 10advertising 10advertising 10advertising "),head=T) str(d) # note that NAME is a fact

Re: [R] Deleting rows based on identity variable

2009-04-02 Thread baptiste auguie
just for curiosity, `%ni%` <- Negate(`%in%`) > 1 %ni% c(2,1) [1] FALSE d1[id %ni% c(1,4), ] baptiste On 2 Apr 2009, at 22:17, gina patel wrote: I have another question, if I now want to remove multiple id's e.g. id=1 or 4 is there a simple OR command I can use? I tried d2<-(d1[id != 1 |

[R] plyr and table question

2009-04-03 Thread baptiste auguie
Dear all, I'm puzzled by the following example inspired by a recent question on R-help, cc <- textConnection("user_id website time 20google0930 21yahoo0935 20facebook1000 25facebook1015 61google

Re: [R] Help pasting string as object name

2009-04-03 Thread baptiste auguie
Hi, Is this what you want? d <- data.frame(density.AL = seq(1, 10), density.AK = seq(1, 10), # many others... Date=letters[1:10]) # dummy example library(reshape) melt(subset(d, Date == "b"), id="Date") BTW, I spotted a few awkward things in your code, st <- c("AL",

[R] "factorise" variables in a data.frame

2009-04-03 Thread baptiste auguie
Dear list, I often need to convert several variables from numeric or integer into factors (before plotting, for instance), as in the following example, d <- data.frame( x = seq(1, 10), y = seq(1, 10), z = rnorm(10), a = letters[1:10]) d2 <- within(d,

Re: [R] "factorise" variables in a data.frame

2009-04-03 Thread baptiste auguie
Excellent! I felt it was fairly trivial but i can be quite dense on Friday mornings. I really like the generalisation. Many thanks, baptiste On 3 Apr 2009, at 12:11, Wacek Kusnierczyk wrote: baptiste auguie wrote: Dear list, I often need to convert several variables from numeric or

Re: [R] plyr and table question

2009-04-03 Thread baptiste auguie
hoo 935 1 4 25 facebook 1015 1 5 61 google 940 1 Have I missed a built-in function to obtain this result? Thanks, baptiste On 3 Apr 2009, at 14:16, hadley wickham wrote: On Fri, Apr 3, 2009 at 4:43 AM, baptiste auguie wrote: Dear all, I'm puzzled by the f

Re: [R] plyr and table question

2009-04-03 Thread baptiste auguie
of course! Thanks, baptiste On 3 Apr 2009, at 14:48, hadley wickham wrote: On Fri, Apr 3, 2009 at 8:43 AM, baptiste auguie wrote: That makes sense, so I can do something like, count <- function(x){ as.integer(unclass(table(x))) } count(d$user_id) ddply(d, .(user_id), transf

Re: [R] Conversions From standard to metric units

2009-04-03 Thread baptiste auguie
I had a similar need for conversions in optics. I put together several functions and data on r-forge, where it does not clutter CRAN but can still be shared conveniently with others. baptiste On 3 Apr 2009, at 19:27, Duncan Murdoch wrote: stephen sefick wrote: I am starting to use R fo

Re: [R] help with formula and data= argument

2009-04-05 Thread baptiste auguie
Hi, It seems to me that you could write a generic function myplot() and have different methods for each class of object (like plot does). Either S3 or S4 classes would do I think. Then it is only a matter of making each method work separately. In particular, the method for a formula coul

Re: [R] comparing columns in a dataframe

2009-04-05 Thread baptiste auguie
Hi, Have you looked at the compare package? It might do what you want (I just remember seeing its description on R News recently but I've never used it), d <- data.frame(x=1:10,y=sin(1:10),z=factor(letters[1:10])) d1 <- d d1$x[2:3] <- jitter(d$x[2:3] ) d2 <- subset(d1, !(z %in% c("a","g")

Re: [R] Collapse data matrix with extra info separated by commas

2009-04-06 Thread baptiste auguie
Here's one attempt with plyr, hopefully Hadley will give you a better solution ( I could not get cast() to do it either) test <- data .frame (a=c("A","A","A","A","B","B","B"),b=c(1,1,2,2,1,1,1),c=sample(1:7)) ddply(test,.(a,b),.fun=function(.) paste(.)[3]) a b V1 1 A 1c(2, 4

Re: [R] strange (?) behavoir of expand.grid()

2009-04-07 Thread baptiste auguie
Hi, I think it's a FAQ (== vs all.equal to test for equality), and not related to expand.grid. See ?all.equal and ?"==" You don't need which, gridd[gridd[,2]=="0.6" , ] would work fine, or more elegantly (imho), gridd <- expand.grid(x=x,y=y ) subset(gridd, factor(x) == "0.6") Hope

Re: [R] change default output size when using Sweave

2009-04-08 Thread baptiste auguie
On 8 Apr 2009, at 11:44, Duncan Murdoch wrote: Mark Heckmann wrote: Dear Duncan, Thanks for the reply. This works, but unfortunately I need a different solution. My script is supposed to run completely automated and the graphics I produce vary in size each time I run the script. But I wan

Re: [R] Clear all with/without function()

2009-04-08 Thread baptiste auguie
clr <- function () rm(list = ls(pos = .GlobalEnv), pos = .GlobalEnv) this works for me HTH, baptiste On 8 Apr 2009, at 10:50, Taraxacum88 wrote: why rm(list=ls(all=TRUE),envir=globalenv()) is ok but ca<-function() rm(list=ls(all=TRUE),envir=globalenv()) ca() does not work? Thank yo

Re: [R] Howto Plot With Transparent Background

2009-04-08 Thread baptiste auguie
with base graphics, par(bg=NA) see ?par Hope this helps, baptiste On 8 Apr 2009, at 12:54, Gundala Viswanath wrote: Is there a way to do it in R? Especially generating plot in EPS/PDF format. By transparent I mean clear (not white) background. I want to attached it to dark PPT slides. -

Re: [R] xyplot - show values of a series on graph

2009-04-08 Thread baptiste auguie
with ggplot2, d <- melt(df2,id="year") qplot(year,value,data=d,colour=variable,geom=c("line","point")) + geom_text(data= subset(d, variable == "cars"), aes(label=value)) with lattice, my best guess would be to use grid.text in a custom panel function. Hope this helps, baptiste On 8 Apr 2

Re: [R] xyplot - show values of a series on graph

2009-04-08 Thread baptiste auguie
panel.xyplot(x,y,...) grid.text(unit(x,"native"),unit(y,"native"),label=y, just="top")} ) baptiste auguie-2 wrote: with ggplot2, d <- melt(df2,id="year") qplot(year,value,data=d,colour=variable,geom=c("line","point"))

Re: [R] turning list into vector/dataframe

2009-04-10 Thread baptiste auguie
try this, do.call(rbind, resample2) #or simply, replicate(1000, Cusum(sample(lambs,replace=F))) you could also look at the plyr package. Hope this helps, baptiste On 10 Apr 2009, at 09:03, Melissa2k9 wrote: Hi, I have used this command : resamples<-lapply(1:1000,function(i) sample(lam

Re: [R] Physical Units in Calculations

2009-04-13 Thread baptiste auguie
Hi, Two thoughts I'd like to share on this subject: 1) Something really cool for conversions between units is the Google search bar: type in " 3 inches in cm" and you get, 3 inches = 7.62 centimeters or, " 3 £ in dollar", 3 UK£ = 4.4007 U.S. dollars or "12 cubic meters to pi

Re: [R] matching lists

2009-04-14 Thread baptiste auguie
Try this, numbers <- c("one","two","three","four") values <- c(10,20,30,40) v <- list(sample(numbers,3),sample(numbers,2)) v sapply(v,function(.l) values[match(.l, numbers)] ) HTH, baptiste On 14 Apr 2009, at 13:01, Manoel Silva wrote: Dear All, Here's my problem. I have two lists: v [[

Re: [R] subset dataframe by rows using character vector?

2009-04-14 Thread baptiste auguie
Is this what you want? plotNames <- c("plot1", "plot2", "plot3") # plot is probably best left as the name of the base function full.data[full.data$PLOTID %in% plotNames, ] # note the comma HTH, baptiste On 14 Apr 2009, at 15:20, zack holden wrote: Dear List, I'm stuck on what seems

Re: [R] subset dataframe by rows using character vector?

2009-04-14 Thread baptiste auguie
glad it was helpful. %in% is a logical operator, so you can use "!" to negate the result (with parentheses), ! ( 4 %in% 1:3) Alternatively, define a new operator, `%ni%` <- Negate(`%in%`) 1 %ni% c(2,1) Next time you ask a follow-up question please send it to the r-help list so others ca

Re: [R] Automating object creation

2009-04-14 Thread baptiste auguie
?assign (but are you sure you really want to name all these objects separately? Usually in R you would put them together in a list or a data.frame, it is much more convenient for later manipulations) On 14 Apr 2009, at 18:32, Zachary Patterson wrote: I am new to R. I would like to automat

Re: [R] How to apply a function to all combinations of the values of 2 or more variables?

2009-04-15 Thread baptiste auguie
I think you want to have a look at the plyr or doBy packages. It would be easier to give a precise answer with a minimal example. HTH, baptiste On 15 Apr 2009, at 18:03, Lane, Jim wrote: Hi, All Forgive me if this is a stupid newbie question. I'm having no luck googling an answer to this, p

Re: [R] (hopefully) simple array op

2009-04-15 Thread baptiste auguie
Do you want abind? http://cran.r-project.org/web/packages/abind/index.html baptiste On 15 Apr 2009, at 19:33, Cable, Samuel B Civ USAF AFMC AFRL/RVBXI wrote: I have a multidimensional array "a", for example, a , , 1 [,1] [,2] [1,]13 [2,]24 , , 2 [,1] [,2] [1,]

Re: [R] segment between points on different plots

2009-04-16 Thread baptiste auguie
Hi, You should give a minimal reproducible example so that we know more precisely what you want to do (what's a "multigraph"?). Perhaps you can get inspiration from Paul Murrell's R graphics book, in particular Figure 5.22, http://www.stat.auckland.ac.nz/~paul/RGraphics/customgrid-lattice

Re: [R] segment between points on different plots

2009-04-16 Thread baptiste auguie
at 12:11, rajesh j wrote: > multigraph has several graphs in 1 layout.I'm drawing a large graph > and plotting small portions of it below.I'm drawing lines from the > large graph to the smaller ones to show which part of the large > graph it is. > > On Thu, Apr 16, 20

Re: [R] Howto build combinations of colums of a data frame

2009-04-16 Thread baptiste auguie
Perhaps, apply(combn(letters[1:4],2), 2, paste,collapse="") Hope this helps, baptiste On 16 Apr 2009, at 17:33, Juergen Rose wrote: Am Donnerstag, den 16.04.2009, 10:59 -0400 schrieb David Winsemius: Thanks David, is there also a shorter way to get the columns names of the new data frames?

Re: [R] Digitizing the Plot

2009-04-16 Thread baptiste auguie
The grImport package seems to provide such possibility for vector graphics, http://www.stat.auckland.ac.nz/~paul/Talks/gddg.pdf imageJ is another open-source option. baptiste On 16 Apr 2009, at 16:44, Shubha Vishwanath Karanth wrote: Hi R, Wanted to check if there are any packages avail

Re: [R] Sweave: Howto write real TeX formula in plot

2009-04-19 Thread baptiste auguie
Perhaps try the pgfSweave package on r-forge? http://r-forge.r-project.org/projects/pgfsweave/ HTH, baptiste On 19 Apr 2009, at 22:15, Jonas Stein wrote: Hi, i use Sweave to put plots in my .tex Documents. (pdflatex) Is there a nice solution for this: a) get a real LaTeX formula in the plo

Re: [R] The assign(paste(...,i),...) idiom

2009-04-20 Thread baptiste auguie
I vaguely recall thinking with such convoluted constructs when switching from Matlab to R. The lack of generic data structures such as lists makes you define variable names that you can identify and manipulate. There are structures in Matlab, but I think they are much less used than lists i

Re: [R] plotting with R

2009-04-22 Thread baptiste auguie
if it hasn't been suggested already: ggplot2 also has a book and a website: http://had.co.nz/ggplot2/ I would recommend any newcomer to have a look as it provides a clear, consistent and elegant syntax to produce very nice plots. baptiste On 22 Apr 2009, at 03:14, Erik Iverson wrote: In add

Re: [R] how to split and handle a big R program into multiple files

2009-04-23 Thread baptiste auguie
If most of the functions are quite stable (you don't change them too often), you could also consider creating a R package with package.skeleton. baptiste On 23 Apr 2009, at 10:39, jgar...@ija.csic.es wrote: source() and the use of functions ... Javier --- I am working on a program to

Re: [R] R: how to split and handle a big R program into multiple files

2009-04-23 Thread baptiste auguie
It is an R command (package utils), see ?package.skeleton baptiste On 23 Apr 2009, at 10:51, mau...@alice.it wrote: > > Is that an R command ? > I browswd for the on-line hlp about such a command but could not > find it. > Thank you. > maura > > > -Messaggio or

Re: [R] R: R: R: how to split and handle a big R program into multiple files

2009-04-23 Thread baptiste auguie
> > > -Messaggio originale- > Da: Duncan Murdoch [mailto:murd...@stats.uwo.ca] > Inviato: gio 23/04/2009 14.21 > A: mau...@alice.it > Cc: baptiste auguie; r-help Help > Oggetto: Re: [R] R: R: how to split and handle a big R program into > multiple files >

Re: [R] plot() - thicker points when pair exist more than 1 time?

2009-04-24 Thread baptiste auguie
on suitable devices, you could consider transparency, plot(f,col=alpha("grey",0.8),pch=19) baptiste On 24 Apr 2009, at 14:09, Knut Krueger wrote: f<- data.frame("x"=c(1,3,5,6,1),"y"=c(1,2,3,4,1)) plot(f) __ R-help@r-project.org mailing list http

Re: [R] Conditional plot labels

2009-04-26 Thread baptiste auguie
Hi, Have you considered using high-level plotting functions provided by the ggplot2 or lattice package? Here's a dummy example, x <- seq(0, 10, length=100) y1 <- sin(x) y2 <- cos(x) y3 <- x^2/100 y4 <- 1/x d <- data.frame(x, y1, y2, y3, y4) library(reshape) dm <- melt(d, id="x") dm$type1

Re: [R] Scatterplot of two groups side-by-side?

2009-04-26 Thread baptiste auguie
Hi, You could do this very easily using ggplot2, #install.packages("ggplot2", dep=TRUE) library(ggplot2) c <- ggplot(mtcars, aes(y=wt, x=mpg)) + facet_grid(. ~ cyl) c + stat_smooth(method=lm) + geom_point() See more examples on Hadley's website: http://had.co.nz/ggplot2/ Hope this helps

Re: [R] comparing matrices

2009-04-26 Thread baptiste auguie
I'm not sure I'm following you but have you tried, identical(matrix(c(1,1,1,1),ncol=2), matrix(c(1,1,1,1),ncol=2)) ?all.equal ?isTRUE ?identical and possibly the compare package, compare(matrix(c(1,1,1,1),ncol=2),matrix(c(1,1,1,1),ncol=2)) HTH, baptiste On 26 Apr 2009, at 18:02, Esmail wro

Re: [R] Formatting numbers

2009-04-27 Thread baptiste auguie
ER TABLE JOIN IN R (Gabor Grothendieck) 12. Re: THE EQUIVALENT OF SQL INNER TABLE JOIN IN R (Peter Dalgaard) 13. Re: 3 questions regarding matrix copy/shuffle/compares (Esmail) 14. Re: Conditional plot labels (baptiste auguie) 15. Re: Scatterplot of two groups side-by-side? (baptiste auguie)

Re: [R] selecting ith rows of a matrix

2009-04-29 Thread baptiste auguie
Try this, a = matrix(rnorm(10*10),ncol=10) a[, seq(1,ncol(a),by=2)] baptiste On 29 Apr 2009, at 09:28, Umesh Srinivasan wrote: Hi all, If I have a huge matrix/ dataframe and I want to create a new matrix/ dataframe with every second (or third, or fourth etc.) row of the original mat

Re: [R] help converting for loop to vector operation

2009-04-29 Thread baptiste auguie
Hi, Here's one approach that I find perhaps more elegant than sweeping through the columns by their index, library(ggplot2) data(economics) str(economics) # library(reshape) d <- melt(economics, id="date") foo <- function(var="pop", d, smooth=FALSE, ... ) { p <- qplot( data=subs

Re: [R] Evaluation of an expression as function argument

2009-04-29 Thread baptiste auguie
Try this, items <- c(list(col=2),list(pch=2)) par(mfrow=c(2, 1)) for (ii in seq(2)) { do.call(function(x, y, ... ) plot(1:10, ...), items[ii]) } ?do.call HTH, baptiste On 29 Apr 2009, at 19:30, Sebastien Bihorel wrote: Dear R-users, I would like to know if is it possible to set a fun

Re: [R] Creating a variable which is the sum of equal rows in a dataframe

2009-05-04 Thread baptiste auguie
Try this, # d <- read.table(pipe("pbpaste"), head=T) # read your data table(d) # library(reshape) cast(as.data.frame(table(d)), .~Firm, fun=sum) HTH, baptiste On 4 May 2009, at 13:19, Cecilia Carmo wrote: Hi everyone: I need to count the number of banks of each firm in my data. The firm

Re: [R] Producing a legend successfullly

2009-05-04 Thread baptiste auguie
your code is missing a closing bracket for the text labels, legend(1,4, c("Simulation", "Observation"), lty=1:2, col=2:3) baptiste On 4 May 2009, at 20:46, Steve Murray wrote: Dear all, I'm attempting to insert a legend into a line graph. I've sorted out the positioning, but I'm unable t

Re: [R] quick square root axes

2009-05-05 Thread baptiste auguie
On 5 May 2009, at 19:28, Duncan Murdoch wrote: On 5/5/2009 1:05 PM, Markus Loecher wrote: Dear R users, while I enjoy the built-in log argument to the plot() function, I wished it would be as easy to create more general custom transformed axes such as sqrt(), logit, etc... for example, i

Re: [R] PGF Device

2009-05-06 Thread baptiste auguie
I think the pgfSweave project on R-forge is working on this (as far as i know it currently relies on eps2pgf) http://r-forge.r-project.org/R/?group_id=331 HTH, Baptiste On 6 May 2009, at 15:37, Lasse Bombien wrote: Hi all, I saw a thread from 2007 about the possible implementation of a PG

Re: [R] Scaling error

2009-12-27 Thread baptiste auguie
Hi, Try this, x <- matrix(1:9, ncol=3, byrow=T) sca <- c(2.5, 1.7, 3.6) x %*% diag(1/sca) HTH, baptiste 2009/12/27 Muhammad Rahiz : > Hi useRs, > > I ran into an inconsistent output problem again. Here is the simplify > illustration > > I've got a matrix as follows > >> x >       V1    V2  

Re: [R] ggplot2, building a simple formula interface

2009-12-29 Thread baptiste auguie
Hi, Try print(p) instead of plot(p) HTH, baptiste 2009/12/29 Bryan Hanson : > I¹m trying to build a simple formula interface to work with a function using > ggplot2. The following scheme ³works² up until the plot(p) request, at which > point there are complaints about xlim¹s and a blank graphic

Re: [R] subsetting by groups, with conditions

2009-12-29 Thread baptiste auguie
Hi, I think you can also use plyr for this, dft <- read.table(textConnection("P1idVeg1Veg2AreaPoly2 P2ID 1 p p 1 1 1 p p 1.5 2 2 p p 2 3 2 p h 3.5 4")

Re: [R] Histogram/BoxPlot Panel

2009-12-29 Thread baptiste auguie
Hi, Here is some artificial data followed by minimal ggplot2 and lattice examples, makeUpData <- function(){ data.frame(x=sample(letters[1:4], 100, repl=TRUE), y=rnorm(100)) } datasets <- replicate(15, makeUpData(), simplify=FALSE) names(datasets) <- paste("dataset", seq_along(datasets), sep

Re: [R] Histogram/BoxPlot Panel

2009-12-29 Thread baptiste auguie
as well as a book. Lattice also has a dedicated book, and a companion website with the figures, http://r-forge.r-project.org/projects/lmdvr/ HTH, baptiste 2009/12/29 baptiste auguie : > Hi, > > Here is some artificial data followed by minimal ggplot2 and lattice examples, > > make

Re: [R] Axis Labels for Compound Plots in ggplot2

2009-12-30 Thread baptiste auguie
Hi, You can set up a Grid layout with one viewport at the bottom and another on the left and use grid.text to add your labels. An example is given below using grid.pack. The gridExtra package provides a convenient wrapper for these regular arrangements of plots, ##library(gridExtra) #http://grid

Re: [R] xyplot: problems with column names & legend

2010-01-03 Thread baptiste auguie
Hi, Using backticks might work to some extent, library(lattice) `my variable` = 1:10 y=rnorm(10) xyplot(`my variable` ~ y) but if your data is in a data.frame the names should have been converted, make.names('my variable') [1] "my.variable" HTH, baptiste 2010/1/3 Jay : > Hello! > > one more

Re: [R] [R-pkgs] fortunes: 250th fortune

2010-01-07 Thread baptiste auguie
Hi, Thank you for this fun package. I recently posted a related question on R-help that seemed to pass unnoticed. Basically, I suggested that the functionality of fortunes could be extended to R FAQ entries, also allowing contributed packages to provide their own (fortune or) faq data file. My ini

Re: [R] postscript, greek lellters

2010-01-09 Thread baptiste auguie
Hi, Something like this maybe, plot.new() lab = expression(bar(T)*"("*-x*" ; "*alpha*")"-G*"("*x*" ; "*alpha*" , "*J*")") text(0.5,0.5,lab) ?plotmath HTH, baptiste 2010/1/8 bernardo lagos alvarez : > Dear useRs, > > How can I, writting the correct greek letter using postscrip or pdf functio

Re: [R] expand.grid game

2010-01-12 Thread baptiste auguie
...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of Brian Diggs >> Sent: Thursday, December 31, 2009 3:08 PM >> To: baptiste auguie; David Winsemius >> Cc: r-help >> Subject: Re: [R] expand.grid game >> >> baptiste auguie wrote: >> &

Re: [R] expand.grid game

2010-01-13 Thread baptiste auguie
It did take me a good night's sleep to understand it. I was stuck with the exact same question but I see now how the remaining balls are shared among all 8 urns (therefore cases with 11, 12, 13, ... 17 balls are also dealt with). Thanks again, baptiste 2010/1/12 Rolf Turner : > > On 13/01/2010,

Re: [R] exporting text output to pdf

2010-01-19 Thread baptiste auguie
Hi, You could play with the splitTextGrob() function from the RGraphics package, string <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque leo ipsum, ultricies scelerisque volutpat non, volutpat et nulla. Curabitur consequat ullamcorper tellus id imperdiet. Duis semper malesuada

Re: [R] call R with un expression (String)?

2010-01-19 Thread baptiste auguie
Hi, ?eval seems like a good candidate HTH, baptiste 2010/1/15 Jiiindo : > > Hello all, > I want to call R from java. And I have a expression in Java as a String, > example : (variable 1 + variable 2)* variable 3 and i want R calculate this > expression. How can I do? > ex: > Java > -int x1,x2;

Re: [R] apply command

2010-01-19 Thread baptiste auguie
Hi, I think you could use iapply (search the archives) or the plyr package to save you from transposing the result. HTH, baptiste 2010/1/19 marco salvini : > Can you please help on the issue? > I using the apply command on a matrix below the example: > > Create a vector > x =c(5, 3, 2:4, NA, 7,

Re: [R] How do I juxtapose two lattice graphs with common X axes such that the X axes line up?

2010-01-20 Thread baptiste auguie
Hi, try c.trellis() from the latticeExtra package. HTH, baptiste 2010/1/20 George Chen : > Hello, > > I would like to juxtapose two lattice graphs with common X axes such that the > X axes line up.  I am using plot right now but the edges are not neat and it > would be nice if I could just d

Re: [R] about loops

2010-01-21 Thread baptiste auguie
Hi, One approach could be a while loop as follows. Note that your circle should have radius 0.5 if I understood the problem correctly. N <- 5 npoints <- 0 ntests <- 0 points.in.circle <- matrix(NA, ncol=2, nrow=N) while (npoints < N) { test.point <- runif(2, -0.5, 0.5) # generate new point

Re: [R] column selection in list

2010-01-22 Thread baptiste auguie
Hi, Try this, a = replicate(3, data.frame(x=1:10, y=rnorm(10)), simplify=FALSE) lapply(a, "[", "y") HTH, baptiste 2010/1/22 Ivan Calandra : > Hi everybody! > > I have a (stupid) question but I cannot find a way to do it! > > I have a list like: >> SPECSHOR_tx_Asfc > $cotau >   SPECSHOR Asfc.m

Re: [R] column selection in list

2010-01-22 Thread baptiste auguie
lected ("y"). Best, baptiste 2010/1/22 Ivan Calandra : > Thanks Baptiste, it does help. > > However, I don't really understand what "[" means. Could you please tell me > more about it? I didn't find anything helpful on that in the help. > > Thanks in

Re: [R] Fwd: Re: Graph color

2010-01-26 Thread baptiste auguie
Hi, Try this, x <- seq(0, 10, len = 100) y <- jitter(sin(x), 1000) old.par <- par() par(bg=grey(0.5)) plot(x, y, new = TRUE, t = "n") lims <- par("usr") plot(x, y, col = 1, panel.first = { rect(lims[1], lims[3], lims[2], lims[4], col = "lightblue") }) HTH, baptiste 2010/1/26 :

Re: [R] ggplot2 theme for custom point colors?

2010-01-27 Thread baptiste auguie
Hi, I remember asking a similar question some time ago, I don't know if the matter has evolved since then, http://groups.google.com/group/ggplot2/browse_frm/thread/a3df8a0d1ee335fb/e3bedd50fb9bd567?lnk=gst&q=theme#e3bedd50fb9bd567 There's also set_default_scale, somewhat related to your question

Re: [R] color matrix

2010-01-27 Thread baptiste auguie
Hi, It's easy with ggplot2, cols = matrix(c("#F7FBFF", "#DEEBF7", "#C6DBEF", "#9ECAE1", "#6BAED6", "#4292C6", "#2171B5", "#08519C" ,"#08306B"), ncol=3) library(ggplot2) m = melt(cols) qplot(factor(X1),factor(X2),data=m, fill=value, geom="tile") + scale_fill_identity() HTH, baptiste 2010/1/2

Re: [R] quartz() and dpi

2010-01-28 Thread baptiste auguie
Hi, I think it's a bug in quartz(). The following example uses png() with cairo or quartz backends, and only cairo respects the size and resolution (as verified in Adobe Photoshop). png(file="foo-300.png", type="quartz", units="in",width=5, height=3, res=300) plot(1,1) dev.off() png(file="fo

Re: [R] evaluating expressions with sub expressions

2010-01-29 Thread baptiste auguie
Hi, Would this do as an alternative syntax? g1 <- quote(1/Tm) mat <- list(0, bquote(f1*s1*.(g1))) vals <- data.frame(f1=1, s1=.5, Tm=2) sapply(mat, eval, vals) HTH, baptiste On 29 January 2010 17:51, Jennifer Young wrote: > Hallo > > I'm having trouble figuring out how to evaluate an expres

Re: [R] parsing files for plot

2010-01-30 Thread baptiste auguie
Hi, Hadley recently proposed a strategy using plyr for a very similar problem, listOfFiles <- list.files() names(listOfFiles) <- basename(listOfFiles) library(plyr) d <- ldply(listOfFiles, scan) Even if you don't want to use plyr, it's always better to group things in a list rather than clutter

Re: [R] parsing files for plot

2010-01-30 Thread baptiste auguie
d(comb,combadd) > > } > boxplot(dats ~ index, data = comb) > > > works just great. There is no additional files in the folder. But look, how > much code for such a simple task. I'd definitely prefer the plyr solution. > > Maxim > > > 2010/1/30 baptiste auguie &g

Re: [R] color blending and transparency

2010-02-03 Thread baptiste auguie
Hi, Adding two semi-transparent colours results in non-intuitive colour mixing (a mystery for me anyway). Is it additive (light), substractive (paint), or something else? Consider the following example, depending on the order of the two "layers" the overlap region is either purple or dark red. I h

<    1   2   3   4   5   6   7   8   >