Re: [R] yet another vectorization question

2006-01-30 Thread Jacques VESLOT
this looks similar: do.call(expand.grid,split(t(replicate(3,c(0,1,NA))),1:3)) Adrian DUSA a écrit : Dear R-helpers, I'm trying to develop a function which specifies all possible expressions that can be formed using a certain number of variables. For example, with three variables A, B and C

Re: [R] Help with R: functions

2006-01-30 Thread Jacques VESLOT
st - function(data, x, y){ attach(data) rcc - coef(lm(y~x)) plot(x,y) abline(rcc) detach(data)} st(data=dats, x=visual24, y=visual52) Pryseley Assam a écrit : Hello R-users I am new to R and trying to write some functions. I have problems writing functions that

[R] match() seq()

2006-01-30 Thread Jacques VESLOT
sorry if it has already been discussed but i can't understand this: seq(0.1,1,by=0.1) [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 match(0.1,seq(0.1,1,by=0.1)) [1] 1 match(0.2,seq(0.1,1,by=0.1)) [1] 2 match(0.3,seq(0.1,1,by=0.1)) [1] NA match(0.4,seq(0.1,1,by=0.1)) [1] 4 R.version

Re: [R] match() seq()

2006-01-30 Thread Jacques VESLOT
at the article mentionned in FAQ 7.31 since everything is not clear for me yet . identical(0.4-0.3,0.1) [1] FALSE all.equal(0.4-0.3,0.1) [1] TRUE jacques Roger Bivand a écrit : On Mon, 30 Jan 2006, Jacques VESLOT wrote: sorry if it has already been discussed but i can't understand

Re: [R] [Q] extracting lower diagonal elements of a matrix

2006-01-26 Thread Jacques VESLOT
try: as.vector(as.dist(data)) Taka Matzmoto a écrit : Hi R users I like to extract lower diagonal elements of a matrix in such a way like, data[1,2], data[1,3], , data[5,6] are extracted from a matrix called 'data' This short script below is what I have written so far.

Re: [R] column of a list

2006-01-24 Thread Jacques VESLOT
lapply(a,[[,s) Thomas Steiner a écrit : I have a list of (same type) lists. I want to retrieve the same entries of all my objects in the outer list. eg: a-list(2006-01-23=list(r=5,s=c(7,12,12,11,4)), 2006-01-24=list(r=6,s=c(3,8,8,9,12))) a[][[s]] gives NULL, but I am looking for all the

Re: [R] assign object to list

2006-01-20 Thread Jacques VESLOT
if you have a list of data frames without the attribute and a vector/list of the values for this attributes: mapply(function(x,y) {attr(x,names) - y ; x}, list(data.frame(1:10), data.frame(11:20)), c(something, anything), SIMPLIFY=F) Christian Bieli a écrit : Dear all I want to generate

Re: [R] Data frame index?

2006-01-18 Thread Jacques VESLOT
try: DF2 - as.data.frame(matrix(vec, nr=nrow(DF),nc=ncol(DF))== matrix(1:ncol(DF),nr=nrow(DF),nc=ncol(DF),byrow=T)) DF3 - data.frame(mapply(function(z,x,y) { x[y] - 0 ; x }, names(DF), DF, DF2, SIMPLIFY=F)) but there must be an easier way... Kenneth Cabrera a écrit : Hi, R

Re: [R] Coercing a list to integer?

2006-01-18 Thread Jacques VESLOT
i am not sure i clearly understood... do you want to coerce a vector into a list of its elements ?! like this: split(1:5,1:5) Norman Goodacre a écrit : Dear group, I am nearly beside myself. After an entire night spent on a niggling little detail, I am no closer to to the truth. I

Re: [R] Coercing a list to integer?

2006-01-18 Thread Jacques VESLOT
of course unlist()/as.list() do that !!! (sorry, i am tired) Norman Goodacre a écrit : Dear group, I am nearly beside myself. After an entire night spent on a niggling little detail, I am no closer to to the truth. I loaded an Excel file in .csv form into R. It apparentely loads as

Re: [R] Legend Outside Plot Dimension

2006-01-18 Thread Jacques VESLOT
use xpd argument in par(), as follows: ?par par(xpd=T, mar=par()$mar+c(0,0,0,4)) plot(1,1) legend(1.5,1,point,pch=1) Abd Rahman Kassim a écrit : Dear All, I'm trying to attach a legend outside the plot (Inside plot OK), but failed. Any help is very much appreciated. Thanks. Abd.

Re: [R] sapply on data frames - $X vs.[X]

2006-01-18 Thread Jacques VESLOT
with apply loop, x is a vector you are indexing in the first sample code with its names. so it failed when you tried indexing it with $ which is dedicated to data frames. Fernando Saldanha a écrit : I have a program where the following code works fine: df.opt$Delta - apply(df.opt, 1,

Re: [R] Problems of data processing

2006-01-17 Thread Jacques VESLOT
(1,1,2,3,6) Y - c(1,1,9,7,8) toto - data.frame(Num,Date,Place,X,Y) Any suggestion is welcome. Florent Bonneu. Jacques VESLOT wrote: OK ! so try this: merge(toto[1:3], unique(na.omit(toto[3:5])),by=Place,all.x=T) Florent Bonneu a écrit : Indeed, X - c(1,Na,2,3,3,3,6,6) Y - c(1,Na

Re: [R] Problems of data processing

2006-01-16 Thread Jacques VESLOT
something wrong in X and Y definitions... but this could work: do.call(rbind, lapply(split(toto, toto$Num), function(x) x[which.min(as.POSIXct(strptime(toto$Date, %d/%m/%y %H:%M))),])) i don't understand the second query; do you want to keep the first line when there are several lines for

Re: [R] Problems of data processing

2006-01-16 Thread Jacques VESLOT
in my line Num=2 for my columns X and Y. Jacques VESLOT wrote: something wrong in X and Y definitions... but this could work: do.call(rbind, lapply(split(toto, toto$Num), function(x) x[which.min(as.POSIXct(strptime(toto$Date, %d/%m/%y %H:%M))),])) i don't understand the second query; do

Re: [R] matrix logic

2006-01-11 Thread Jacques VESLOT
I don't know how to keep factors' levels with : data.frame(mapply(function(x,y,z) ifelse(is.na(y), z, y), names(D), D, D2, SIMPLIFY=FALSE)) but in that way it's ok : data.frame(mapply(function(z,x,y) { y[is.na(y)] - x[is.na(y)] ; y }, names(D), D, D2, SIMPLIFY=F)) (?) Uwe

Re: [R] (no subject)

2005-12-27 Thread Jacques VESLOT
?Control but there are alternative ways : sapply(), apply(), lapply()... ifelse() etc. Barbora Kocúrová a écrit : Hallo. Could you please tell me if it is possible in R use something like for-cycle or conditions with if and then. I would need to index z from 0 to m and repeat some operations

Re: [R] 2D Matrix Plot

2005-12-25 Thread Jacques VESLOT
image() is fine to plot the cells of a matrix. i think balloonplot() in gplots and mosaicplot() can do it too. i sometimes do it with bubble() in gstat. Jaydutt Bhalshankar a écrit : Hello Everyone, I am Naive user of 'R' statistical environment and still i'm in learning mode. I would like to

Re: [R] strsplit with dataframes

2005-12-22 Thread Jacques VESLOT
try: cbind.data.frame(do.call(rbind, strsplit(as.character(yourdf$ID), -)), yourdf$data) Henrik Andersson a écrit : Hello fellow R people, I can not figure out a pretty way to use strplit with vectors Imagine that I got the following data from someone with ID's representing several factors

Re: [R] Plot problems: xlim

2005-12-22 Thread Jacques VESLOT
Please give an example of your data. set.seed(231) morp - rnorm(20) range(morp) [1] -2.311664 1.650254 You can plot 2 histograms, one of them with the extreme value: par(mfrow=c(2,1)) hist(morp, breaks=10, freq=F) lines(density(morp)) par(mfrow=c(1,2)) hist(morp, breaks=10, freq=F)

Re: [R] Help with data.frame and lapply

2005-12-16 Thread Jacques VESLOT
d - data.frame(x1 = rnorm(100), x2 = rnorm(100), x3 = rnorm(100), cls = rnorm(100)) dd - subset(d, sel=-cls) lapply(paste(lm(cls ~, names(dd), ,data=d)), function(x) eval(parse(text=x))) Juan Daniel López Serna a écrit : -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello: I'm having

Re: [R] Vector of matrix

2005-12-16 Thread Jacques VESLOT
It seems that Xi is a matrix; so it can't be included in a vector. You need to create a list for the result of your for loop. res - list() for ( i in ...) { res[[i]] - Xi } Vieilledent Ghislain a écrit : Dear statisticians, I would like to save results for a for loop in a vector

Re: [R] package for factor analysis

2005-12-14 Thread Jacques VESLOT
you can try : plot(hclust(dist(ach, manh), ward), hang=-1) you can choose distance method and clustering method. you can find a lot of useful functions for multivariate analysis in the ade4 package ; but, for clustering, the cluster package is quite nice. Birgit Kessler a écrit : I have

Re: [R] no subject

2005-12-14 Thread Jacques VESLOT
try with merge() : table1 = data.frame(CGID=c(CG_1,CG_3,CG_2, CG_4, CG_5), diff=c(3,5,6,4,3)) table2 = data.frame(CGID=c(CG_2,CG_3,CG_4, CG_1, CG_5), diff=c(4,6,3,9,10)) newtable- merge(table1, table2, by=CGID) matplot(merge(table1,

Re: [R] Simplifying matrices ?

2005-12-13 Thread Jacques VESLOT
unique(x[,-2]) Sérgio Nunes a écrit : Hi again, the previous answers were great. I was able to do what was planned. Now, I would like to do the following to a matrix: || year | event | team | total || where I can have multiple event per team, but each team only has a year and a total. Thus,

Re: [R] question about date's

2005-12-12 Thread Jacques VESLOT
do.call(rbind, strsplit(as.character(date.vector), -)) Richard van Wingerden a écrit : Hi, Given a frame with calendar date's: 2005-07-01, 2005-07-02,2005-07-03,2005-07-04,2005-07-05,etc. I want to extract the following from these dates: week number month number year number Any ideas how

Re: [R] store and retrieve object names in a vector

2005-12-12 Thread Jacques VESLOT
try: y - sapply(x, function(x) eval(parse(text=x))) zhihua li a écrit : hi netters, suppose i have a series of objects X1, X2, B1,C1... they all have the same dimensions. i want to combine into one by using cbind: y-cbind(X1,X2,B1,C1.) but i don't want to type the names of

Re: [R] how to change a dataframe with characters to a numeric matrix?

2005-12-08 Thread Jacques VESLOT
you probably have a dataframe like this : z - data.frame(y1=c(1,2,3),y2=c(4,5,6),y3=c(4,z,5)) you can do : z - as.matrix(z) mode(z) - numeric zhihua li a écrit : hi netters, i have a dataframe TEST like this: Y1 Y2 Y3 X1 4 7 8 X2 6 2 Z X3 8 0 1 i would like to change it to a

Re: [R] ploting the two sets of data side by side

2005-12-07 Thread Jacques VESLOT
try : barplot(do.call(rbind,lapply(list(x,y), function(x) table(cut(x, breaks =c(0,5,10,20,25,30),beside=T) Subhabrata a écrit : Hello R-users, I am new to R-commands. I have two sets of data: x - c(7, 7 , 8, 9, 15, 17, 18) y - c(7, 8, 9, 15, 17, 19, 20, 20, 25, 23, 22) I have used

[R] Random effect models

2005-10-28 Thread Jacques VESLOT
standard deviations of random effects (I don't know how to find them) but I can't find F tests for random effects. I only want to know if there is an easy way (a function ?) to do F tests for random effects in random effect models. Thanks in advance. Best regards, Jacques VESLOT Data

[R] F tests for random effect models

2005-10-27 Thread Jacques VESLOT
) + (1 | Lignee) + (1 | Pollinisateur:Lignee), data=mca2)) but I can't get F tests. Thanks in advance. Best regards, Jacques VESLOT __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

Re: [R] F tests for random effect models

2005-10-27 Thread Jacques VESLOT
-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Thanks, Jacques VESLOT Prof Brian Ripley a écrit : Nothing was enclosed, nor was the output from summary.aov, so we are left guessing. On Thu, 27 Oct 2005, Jacques VESLOT wrote: Dear R-users, My question is how

Re: [R] F tests for random effect models

2005-10-27 Thread Jacques VESLOT
effect models. Jacques VESLOT Doran, Harold a écrit : I think what you're looking for is in anova() fm1 - lmer(dv ~ IV ...) anova(fm1) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jacques VESLOT Sent: Thursday, October 27, 2005 2:22 AM

Re: [R] PCA and overlaying points

2005-07-07 Thread Jacques VESLOT
if it is not necessary. I hoped there might be an heavier function able to change coordinates in an let's say intelligent or surgical manner... jacques Renaud Lancelot a écrit : Jacques VESLOT a écrit : Dear R-users, Is there an easy way to avoid points one upon another when ploting rows and columns

[R] About ade4 and overlaying points

2005-07-07 Thread Jacques VESLOT
of these points to get a readable plot ?). Thanks in advance. Best regards, Jacques VESLOT __ R-help@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

Re: [R] lwd less than 1

2005-05-19 Thread Jacques VESLOT
: (...) some devices do not implement line widths less than one. What I am looking for is how to get readable plots (with not too wide lines) after size reduction... Best regards, Jacques VESLOT Paul Murrell a écrit : Hi Jacques VESLOT wrote: Dear R-users, Someone, who uses R under Mac, wants to insert

[R] Tests on contingency tables

2005-02-15 Thread Jacques VESLOT
replaced in Chi2 distribution function to get p-value: 1-pchisq(486.199, df=63) [1] 0 Is there a better way to perform this or a more appropriate function dedicated to tests on large-dimensioned contingency tables ? Thanks in advance, Jacques VESLOT

RE: [R] Tests on contingency tables

2005-02-15 Thread Jacques VESLOT
+ pl, data = z) Statistics: X^2 df P( X^2) Likelihood Ratio 286.1236 490 Pearson 450.5332 490 Jacques -Message d'origine- De : Prof Brian Ripley [mailto:[EMAIL PROTECTED] Envoye : mardi 15 fevrier 2005 17:41 A : Jacques VESLOT Cc : R-HELP

RE: [R] Double sort a data frame

2005-02-11 Thread Jacques VESLOT
class(df) [1] data.frame names(df) [1] x y z df - df[order(df$x, df$y),]# sort df by x and y with priority to x -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] la part de Luis Ridao Cruz Envoye : vendredi 11 fevrier 2005 16:03 A :

RE: [R] plot

2005-01-28 Thread Jacques VESLOT
if * in x1[1:50,]*x2[1:50,] means times, try : matplot(matrix(x1,ncol=4)*matrix(x2,ncol=4)) if * means vs, try : matplot(matrix(x1,ncol=4),matrix(x2,ncol=4)) -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] la part de NICOLAS DEIG Envoye : vendredi 28 janvier 2005

[R] Still avoiding loops

2005-01-26 Thread Jacques VESLOT
; for that, my first idea was to add this matrix: X1=X[,rep(1:46,46:1)] to this one: res=NULL for (i in (2:47)) res=c(res,i:47) X2=X[,res] (Is it a nice alternative way ?) Is there a way to create the second matrix X2 without a loop, such as for X1 ? Thanks in advance, Jacques VESLOT

RE: [R] Still avoiding loops

2005-01-26 Thread Jacques VESLOT
Y and counting the number of 0, 1 and 2 in it for inclusion in other operations. I read your posting... Thanks for helping, Jacques VESLOT -Message d'origine- De : Adaikalavan Ramasamy [mailto:[EMAIL PROTECTED] Envoyé : mercredi 26 janvier 2005 15:57 À : [EMAIL PROTECTED] Cc : R-help

[R] an R script editor for Mac

2005-01-21 Thread Jacques VESLOT
Dear all, Could someone please make me know if there is a nice script editor available under Mac, similar to Crimson, that offers R syntax highlighting (and pairs of parentheses underlining) ? Thanks in advance, Jacques VESLOT Cirad __ R-help

[R] layout for xyplot

2004-09-22 Thread Jacques VESLOT
in if (!any(cond.max.level - cond.current.level 0) (row - 1) * : missing value where TRUE/FALSE needed I tried some changes in arguments - notably layout=c(0,1), but anything works. Thanks for helping... Jacques VESLOT CIRAD Réunion __ [EMAIL

RE: [R] layout for xyplot

2004-09-22 Thread Jacques VESLOT
22 September 2004 09:32, Jacques VESLOT wrote: Dear all, I tried to use layout argument in xyplot to get one panel per page. I have a dataframe named 'data' with the following variables: x, y = coords, sub, bloc = 2-level factors, etat = 5-level factor, I did : lset(theme = col.whitebg

[R] bubble plots

2004-09-21 Thread Jacques VESLOT
if there is another - maybe better - way to plot spatial marked data. Jacques VESLOT CIRAD Réunion __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] Indexing dataframe

2004-09-09 Thread Jacques VESLOT
- d2004[, -c(concentration, stade)] Thanks... Jacques VESLOT / CIRAD __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] Cross-variograms

2004-08-05 Thread Jacques VESLOT
a gstat object with two variables. Could you please let me know if this is the right way to operate (and what formula argument means here) ? Best regards, Jacques VESLOT CIRAD __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman

RE: [R] 2 questions : format and hh:mm

2004-07-29 Thread Jacques VESLOT
in order to generate your series, maybe : format(seq(ISOdate(2003,1,1, 0, 0, 0, tz=), by=min, length=1440),format=%H:%M) jacques -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] la part de Bruno Cutayar Envoyé : jeudi 29 juillet 2004 13:43 À : [EMAIL PROTECTED] Objet

[R] How to sort TWO columns ?

2004-07-21 Thread Jacques VESLOT
to have these two columns sorted in increasing order. But sort() and order() seem to apply to vectors - or one single column - only. Could somedy please let me know how to sort two columns of a dataframe, with priority to one of them, just like in access ? Thanks, Jacques VESLOT CIRAD Another related

RE: [R] How to sort TWO columns ?

2004-07-21 Thread Jacques VESLOT
Sorry sorry, I didn't pay enough attention to order() help pages indeed... and it costs me much useless indexing. As concerns how to put legend in image() plot, is there a piece of information about somewhere ? thanks a lot for helping, Jacques VESLOT -Message d'origine- De : Uwe

[R] About lattice plots and loops

2004-07-15 Thread Jacques VESLOT
inside a loop ? Jacques VESLOT CIRAD - CIRAD 3P Reunion - MailScanner - Ce message a été vérifié par MailScanner et analyse par 4 antivirus : ClamAv - BitDefender - F-Prot - Panda. Aucun

RE: [R] About lattice plots and loops

2004-07-15 Thread Jacques VESLOT
It works indeed. Thanks a lot. Jacques VESLOT CIRAD -Message d'origine- De : Uwe Ligges [mailto:[EMAIL PROTECTED] Envoyé : jeudi 15 juillet 2004 11:35 À : [EMAIL PROTECTED] Cc : [EMAIL PROTECTED] Objet : Re: [R] About lattice plots and loops Jacques VESLOT wrote: I cannot operate

<    1   2