Re: [R] Reshape a data set

2009-12-16 Thread xavier . chardon
Hi, You need an additional id column in your data frame, which represents the replication number within each subject (the 1, 2 in the column headings after reshaping in what you showed). test - data.frame(subject=c(1,1,2,2,3,3), coder=c(1,2,3,2,2,1), score=c(20,30,10,5,15,NA),

Re: [R] Problems with code containing a for loop

2009-10-09 Thread xavier . chardon
A parenthesis is missing. You can figure that out easily watching the first error. text(0.5,0.5, text = paste(letters[i], +, numbers[j],=, letters [i+j+k])) Xavier - Mail Original - De: Antje## ann3bu...@hotmail.com À: r-help@r-project.org Envoyé: Vendredi 9 Octobre 2009 17h36:34 GMT

Re: [R] To hell with OpenSuse, ditch it and go to Ubuntu

2009-10-08 Thread xavier . chardon
Whatever your final choice is, I think you should really try to use the distribution's package management system. I don't use the distributions you cited so I can't give you precise hints, but I'm sure you can easily find tutorials on how to install/remove software. It will make things a lot

Re: [R] Running an ANOVA with a BY

2009-09-29 Thread xavier . chardon
Or with plyr there's a more flexible approach: res.aov - dlply(warpbreaks, .(tension), function(x) aov(breaks ~ wool, data=x)) # aov results are stored in a list, you can directly extract what you want with l*ply l_ply(res.aov, function(x) print(summary(x))) ldply(res.aov, function(x)

Re: [R] sort dates within a factor

2009-09-29 Thread xavier . chardon
Is this what you want? test[order(test$nr, -as.integer(test$date)),] Xavier - Mail Original - De: Stefan Uhmann stefan.uhm...@googlemail.com À: r-help@r-project.org Envoyé: Mardi 29 Septembre 2009 11h27:20 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: [R]

Re: [R] sort dates within a factor

2009-09-29 Thread xavier . chardon
Apologies for the misunderstanding. I can come up with a solution that might suit your needs: library(plyr) out - ddply(test, .(nr), function(x) data.frame(date=x$date, index=rank(-as.integer(x$date out[is.na(out$nr) | is.na(out$date), index] - NA Xavier - Mail Original - De:

Re: [R] Reshape package: Casting data to form a grid

2009-08-18 Thread xavier . chardon
Hi, You can't use cast directly on your dataframe. You need to use the melt function before, and use cast on its result. Very good examples are provided in the doc of the package: http://had.co.nz/reshape/ Also, you need to provide one formula (not several as in your code), something like:

Re: [R] using ddply but preserving some of the outside data

2009-08-06 Thread xavier . chardon
Hi, Apart from everything that's been answered already, it seems in your first mail that you were confusing merge and rbind. rbind is to append rows to a data set. merge performs joints, like in a relational database - Mail Original - De: Jarrett Byrnes byr...@msi.ucsb.edu À: R help

Re: [R] problem with pattern matching

2009-08-05 Thread xavier . chardon
Hi, I don't think grep can handle a vector of patterns. grep( c(foo1, foo2), c(fffoo5, fffoo6, fffoo2, fffoo1)) [1] 4 This call is equivalent to: grep( foo1, c(fffoo5, fffoo6, fffoo2, fffoo1) ) Maybe you could use the plyr package. I am only speculating, but something like this might work:

Re: [R] quetions about dimensions

2009-07-29 Thread xavier . chardon
Try this: bj2=bjerrdata$tyerr[ (bjyearnum[2]+1):bjyearnum[3] ] I think it's more like what you meant to do. I believe what you wrote actually did: bjyearnum[2]+(1:bjyearnum[3]) So the problem was with arithmetic priorities, in my opinion (: having a higher priority than +). Check this:

Re: [R] Re gression by groups questions

2009-06-18 Thread xavier . chardon
Hi, It seems like your multivariate regression works for groups A and B. For group C, values are calculated using an interaction between x1 and x2. Try to include it in the regression model to find the right coeffs: y ~ grp:x1:x2 + grp:x1 + grp:x2 + grp - 1 It works for me. Notice in

Re: [R] Questíon regarding the use of write.csv2, write.table ...

2009-06-18 Thread xavier . chardon
Hi, It sounds like the first column that is added is actually the row names. That's why a previous answer pointed this argumented. Default for write.csv is to write the row names along with the data. So, this should work: write.csv2(exampleDataframe,file=exampleDataframe.csv, row.names=FALSE)

Re: [R] confusion on levels() function, and how to assign a wanted order to factor levels, intentionally?

2009-06-16 Thread xavier . chardon
Hi, The way you do it actually renames the factors one after each other (it replaces the values in the data frame, which is not what you want). Have a look at this code: test - data.frame(id=c(1,2,3), fac=c(lv1, lv2, lv3) ) levels(test$fac) test$fac2 - factor(test$fac, levels=c(lv3, lv2, lv1))

[R] model fitting using by(): how to get fitted values?

2009-05-06 Thread xavier . chardon
Hi all, I'm doing nonlinear regressions on data with several factors. I want to fit say a logistic curve with different parameter values for each factor level. So I'm doing something like: tmp - by( myData, list(myFactor1, myFactor2), function(x) nls(...) ) It works fine. However, I could not

Re: [R] ggplot2: font size mismatch for pdf output

2008-05-13 Thread Xavier Chardon
). Xavier hadley wickham a écrit : More generally, how do I control the size of fonts used in legends and axis labels? There is no general way (yet) - it is on my customisation to do list, which I hope to make progress on over summer. Hadley -- Xavier Chardon Thésard Institut de l'élevage

Re: [R] ggplo2: x_discrete labels size/direction

2008-05-06 Thread Xavier Chardon
Postdoctoral Fellow EMBL/EBI UK Germany -- Xavier Chardon Thésard Institut de l'élevage / INRA Projet ACTA modélisation environnementale des systèmes bovins et porcins [EMAIL PROTECTED] [EMAIL PROTECTED] 02 23 48 50 91 __ R-help@r-project.org mailing list

Re: [R] ggplot2: labels and breaks order does not match and I can't use scale_fill_identity

2008-04-30 Thread Xavier Chardon
and I can't use scale_fill_identity Date: Tue, 29 Apr 2008 17:29:13 +0200 De: Xavier Chardon [EMAIL PROTECTED] Répondre à :: [EMAIL PROTECTED] Pour :: Mikhail Spivakov [EMAIL PROTECTED] Références: [EMAIL PROTECTED] Hi, I had a similar problem. I don't know if the solution

Re: [R] ggplot2: setting global graphic parameters with png driver

2008-04-29 Thread Xavier Chardon
as being in device units (pixels) rather than in points. On Tue, 29 Apr 2008, Xavier Chardon wrote: Hi all, I prepared a few charts with ggplot2, and was happy with the results as displayed on screen. I tried to draw them with a PNG driver instead. But I ran into several problems while trying