[R] to calculate c(rep("1", 43), rep("2",43),...., rep("10",43))

2014-12-11 Thread Arnaud Michel
Hello I would like to find an elegant way of calculating c(rep("1", 43), rep("2",43),, rep("10",43)) Any idea ? Thank you -- Michel ARNAUD DGDRD-Drh - TA 174/04 tel : 04.67.61.75.38 port: 06.47.43.55.31 __ R-help@r-project.org mailing list -- To U

Re: [R] outputs of a function

2014-12-04 Thread Arnaud Michel
. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On December 4, 2014 2:09:12 AM PST, Arnaud Michel wrote: Hello I have a function named FctModele13 in which 1) I calculate a dataframe named Total and 2) I used ggplot2. I have the following

[R] outputs of a function

2014-12-04 Thread Arnaud Michel
Hello I have a function named FctModele13 in which 1) I calculate a dataframe named Total and 2) I used ggplot2. I have the following problem. I cannot produce simultaneously * the graphic by ggplot2 * the dataframe My simplified code is the following one : TT <- FctModele13(ListePlusde50a

[R] To calculate the month number between 2 dates

2014-11-07 Thread Arnaud Michel
Hello Can one calculate the month number between two dates D1 <- "01/01/2007" and D2 <- "01/04/2009" ? Thank you -- Michel ARNAUD Cirad __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] To build a new Df from 2 Df

2014-10-14 Thread Arnaud Michel
"C", "D", "B", "D", "B", "C", "D", "B", "B", "B", "A", "C", "D", "B", "A", "D", "D"), Unite = c("Unite8", "Un

[R] To build a new Df from 2 Df

2014-10-14 Thread Arnaud Michel
Hello I have 2 df Dem and Rap. I would want to build all the df (dfnew) by associating these two df (Dem and Rap) in the following way : For each value of Dem$Nom (dfnew$Demandeur), I associate 2 different values of Rap$Nom (dfnew$Rapporteur1 and dfnew$Rapporteur2) in such a way * for each d

Re: [R] To Add a variable from Df1 to Df2 which have a same common variable

2014-09-19 Thread Arnaud Michel
Thank you to Marc Schwartz, Rui Barrada and Sarah Goslee Michel Le 19/09/2014 19:46, Marc Schwartz a écrit : On Sep 19, 2014, at 12:15 PM, Arnaud Michel wrote: Hello I have the two dataframes Df1 and Df2 which have the common variable AgeSexeCadNCad I would like to add the new variable Df2

[R] To Add a variable from Df1 to Df2 which have a same common variable

2014-09-19 Thread Arnaud Michel
Hello I have the two dataframes Df1 and Df2 which have the common variable AgeSexeCadNCad I would like to add the new variable Df2$Pourcent which correspond at the value of Df1$AgeSexeCadNCad. Thank you for your help. Michel Df1 <- structure(list(AgeSexeCadNCad = structure(1:36, .Label = c("6

Re: [R] Plotrix and twoord.plot with date on x-axe

2014-07-26 Thread Arnaud Michel
Perfect Jim, It's fine ! Thank you Michel Le 26/07/2014 12:16, Jim Lemon a écrit : On Sat, 26 Jul 2014 09:36:49 AM Arnaud Michel wrote: Hello With package plotrix and twoord.plot function, I would like to put the labels of the ticks values of x-axe which are date ( c("2006 Jan&q

Re: [R] Plotrix and twoord.plot with date on x-axe

2014-07-26 Thread Arnaud Michel
Perfect Jim, It's fine ! Michel Le 26/07/2014 12:16, Jim Lemon a écrit : On Sat, 26 Jul 2014 09:36:49 AM Arnaud Michel wrote: Hello With package plotrix and twoord.plot function, I would like to put the labels of the ticks values of x-axe which are date ( c("2006 Jan", "

[R] Plotrix and twoord.plot with date on x-axe

2014-07-26 Thread Arnaud Michel
Hello With package plotrix and twoord.plot function, I would like to put the labels of the ticks values of x-axe which are date ( c("2006 Jan", "2007 Jan", "2008 Jan", "2009 Jan", "2010 Jan", "2011 Jan", "2012 Jan") with if possible, the angle of labels and x-axe = 40 Any idea ? Thank you fo

[R] To map population of European countries from Eurostat

2014-02-06 Thread Arnaud Michel
Hello I would like to map the population of the European countries in 2011. I am using the spatial shapefiles of Europe published by EUROSTAT. I applyed the script below of Markus Kainubut but I had a problem with the map. Any ideas ? Thanks for your help ##

[R] to modify a dataframe

2014-01-01 Thread Arnaud Michel
Dear All, From the dataframe df1 df1 <- structure(list(Nom = structure(1:9, .Label = c("A1", "A2", "A3", "B1", "B2", "C1", "C2", "C3", "C4"), class = "factor"), Pays1 = c(1, 1, 0, 0, 1, 0, 0, 0, 0), Pays2 = c(0, 0, 0, 1, 1, 0, 1, 0, 1), Pays3 = c(0, 0, 0, 0, 1, 0, 0, 0, 0), Pays4 = c(1, 0, 0

[R] to replace the for loop

2013-12-13 Thread Arnaud Michel
Hello I would like to replace the for loop this below T <- as.matrix(T) for(i in 1: nrow(TEMP)){ for(j in 1: nrow(TEMP)){if (i <= j) T[i, j] <- 0 }} I don't find the function in the doc. Thanks in advance for your help. -- Michel ARNAUD Chargé de mission auprès du DRH DGDRD-Drh - TA 174/04 Av

[R] To transform a vector of qualitatives values into a dataframe of quantitatives values

2013-12-11 Thread Arnaud Michel
Hi From the vector X <- c(A, A, B, C, B, A, C) I would like to build the Dataframe : data.frame( A=c(1,1,0,0,0,1,0), B=c(0,0,1,0,1,0,0), C=c(0,0,0,1,0,0,1)) Any ideas ? -- Michel ARNAUD Chargé de mission auprès du DRH DGDRD-Drh - TA 174/04 Av Agropolis 34398 Montpellier cedex 5 tel : 04.67.61

Re: [R] To transform a vector

2013-12-08 Thread Arnaud Michel
Thank you Michel Le 09/12/2013 08:14, Berend Hasselman a écrit : On 09-12-2013, at 08:04, Arnaud Michel wrote: Dear R Users I have the vector X <- c( 6 , 4 ,12 , 3) I would like to build a new vector by to transform it into Y <- c(rep(X[1], X[1]), rep(X[2], X[2]), rep(X[3], X[3]), r

[R] To transform a vector

2013-12-08 Thread Arnaud Michel
Dear R Users I have the vector X <- c( 6 , 4 ,12 , 3) I would like to build a new vector by to transform it into Y <- c(rep(X[1], X[1]), rep(X[2], X[2]), rep(X[3], X[3]), rep(X[4], X[4])) Have you a more elegant answer ? PS : Sorry for this basic question -- Michel ARNAUD Chargé de mission au

Re: [R] To transform an adjacency matrix

2013-11-20 Thread Arnaud Michel
Thank you also for your help Michel Le 20/11/2013 19:04, Dennis Murphy a écrit : Hi: which(m == 1L, arr.ind = TRUE) Dennis On Wed, Nov 20, 2013 at 2:28 AM, Arnaud Michel wrote: Hi I have the following problem I would like to build, from a matrix filled with 0 and with 1, a matrix or a

Re: [R] To transform an adjacency matrix

2013-11-20 Thread Arnaud Michel
On 20 November 2013 19:28, Arnaud Michel wrote: Hi I have the following problem I would like to build, from a matrix filled with 0 and with 1, a matrix or a data.frame which contains, in every line, the number of the line and the number of the column of the matrix for which the value is equal to 1. E

[R] To transform an adjacency matrix

2013-11-20 Thread Arnaud Michel
Hi I have the following problem I would like to build, from a matrix filled with 0 and with 1, a matrix or a data.frame which contains, in every line, the number of the line and the number of the column of the matrix for which the value is equal to 1. Exemple : dput(m) structure(c(0, 0, 0, 1, 0

[R] add points on an existant ggplot from another dataframe

2013-10-14 Thread Arnaud Michel
Hello I had draw the results of PCA (Principal Components Analysis) (1) Is it possible to put on this graphic the 75% ellipse confidence of each sex calculated by dataEllipse (library(car)) ? My code is 1) PCA data frame with 169 rows and 2 columns library(ggplot2) p <- ggplot(PCA, aes(x=F1, y=

Re: [R] ggplot2 : to change the title of legend

2013-10-11 Thread Arnaud Michel
-bounces@r- project.org] On Behalf Of Arnaud Michel Sent: Friday, October 11, 2013 11:02 AM To: R help Subject: [R] ggplot2 : to change the title of legend Hello I don't arrive to change the title of the legend My code is : library(ggplot2) ma <- max(General$AgeChangCat) ; mi <- min(Gene

[R] ggplot2 : to change the title of legend

2013-10-11 Thread Arnaud Michel
Hello I don't arrive to change the title of the legend My code is : library(ggplot2) ma <- max(General$AgeChangCat) ; mi <- min(General$AgeChangCat) Test$Recrutement <- factor(Test$CadNonCadRecrut) p <- ggplot(Test, aes(x=factor(Cat1), y=AgeChangCat )) + ylim(mi,ma) + geom_point() + geom_boxplot(a

Re: [R] delete some lines of a dataframe

2013-09-17 Thread Arnaud Michel
Merci Arun Michel Le 17/09/2013 22:41, arun a écrit : Hi Arnaud, You could also try: indx<- Df1$Mat[-1]==Df1$Mat[-nrow(Df1)] indx1<-c(indx,FALSE) indx2<-c(FALSE,indx) Df1[indx1,] Df1[indx2,] A.K. From: arun To: Arnaud Michel Cc: R help Sent

Re: [R] delete some lines of a dataframe

2013-09-17 Thread Arnaud Michel
Thank you Arun but the values of other columns may be different !!! Michel Le 17/09/2013 20:56, arun a écrit : Hi, Try: Df1[duplicated(Df1),] Df1[duplicated(Df1,fromLast=TRUE),] A.K. - Original Message - From: Arnaud Michel To: R help Cc: Sent: Tuesday, September 17, 2013 2:14 PM

[R] delete some lines of a dataframe

2013-09-17 Thread Arnaud Michel
Hi I have a dataframe Df1 dput(Df1) structure(list(Mat = c(141, 141, 157, 157, 188, 188, 232, 232, 253, 253, 253, 254, 254, 254, 254, 256, 256, 264, 264), Prenom = c("Pierre", "Pierre", "Jean-Claude", "Jean-Claude", "Jean-Louis", "Jean-Louis", "Philippe", "Philippe", "Christophe", "Christophe",

Re: [R] Change the color of the line inside of the function lines

2013-09-16 Thread Arnaud Michel
+1], col='grey') Regards, Pascal On 16/09/2013 15:42, Arnaud Michel wrote: Hi I have the following problem : I have 3 vectors xx, yy, zz : xx <- c(5479, 6209, 6940, 7670, 8766, 9496, 10227, 11048, 11778, 12509, 13239, 13970, 14700, 15340, 15948) yy <- c( 267, 275, 281, 287, 29

Re: [R] Change the color of the line inside of the function lines

2013-09-16 Thread Arnaud Michel
ot;) > > If you use a color vector, say cols, then you can also do > > lines(xx,yy,col=cols[zz-2],type="s") > > Hope it helps, > > Tsjerk > > > On Mon, Sep 16, 2013 at 8:42 AM, Arnaud Michel <mailto:michel.arn...@cirad.fr>> wrote: > >

[R] Change the color of the line inside of the function lines

2013-09-15 Thread Arnaud Michel
Hi I have the following problem : I have 3 vectors xx, yy, zz : xx <- c(5479, 6209, 6940, 7670, 8766, 9496, 10227, 11048, 11778, 12509, 13239, 13970, 14700, 15340, 15948) yy <- c( 267, 275, 281, 287, 296, 306, 316, 325, 334, 351, 365, 377, 389, 419, 419) zz <- c( 3, 3, 3, 3, 4, 4, 4, 4,

[R] to delete lines by means of a vector

2013-09-10 Thread Arnaud Michel
Hi I would like to eliminate a large number of lines of the dataframe df1 The lines to delete are given here by the values of Mat (ex : 2,4,7,10). but I have a large number (300) values of Mat dput(df1) structure(list(Mat = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5

Re: [R] to avoid a do loop

2013-09-08 Thread Arnaud Michel
t, sprintf("%02d", df1$Ech), sep = ".") ) # user system elapsed # 0.170.000.17 # R Lancelot system.time(df1$CatEch3 <- paste(df1$Cat, formatC(df1$Ech, flag = "0", width = max(nchar(df1$Ech))), sep = ".")) # user system elapsed # 0.340

Re: [R] to avoid a do loop

2013-09-08 Thread Arnaud Michel
Thanks to all three for your fast answer Michel Le 08/09/2013 18:41, Renaud Lancelot a écrit : > paste(df1$Cat, > formatC(df1$Ech, flag = "0", width = max(nchar(df1$Ech))), > sep = ".") > > > > 2013/9/8 Arnaud Michel <mailto:michel.arn...@c

[R] to avoid a do loop

2013-09-08 Thread Arnaud Michel
Hello I have a large dataframe (nrow=55000). This below df1 an extract of the original dataframe dput(df1) structure(list(Cat = c(6, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 4, 4, 8, 8, 9, 9, 9, 9, 9, 9, 9, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8

Re: [R] To represent on the same plot the relation (y1, x) and (y2, x)

2013-08-31 Thread Arnaud Michel
col=c("red","blue")) #or library(ggplot2) dat1<- data.frame(x,y1,y2) ggplot(dat1,aes(x))+geom_line(aes(y=y1,colour="y1"))+ geom_line(aes(y=y2,colour="y2")) +ylab("y1:y2") A.K. - Original Message - From: Arnaud Michel To: R help Cc: Sent

Re: [R] To represent on the same plot the relation (y1, x) and (y2, x)

2013-08-31 Thread Arnaud Michel
=4,main="y1, y2 vs. x") A.K. ----- Original Message - From: Arnaud Michel To: arun Cc: R help Sent: Sunday, September 1, 2013 1:18 AM Subject: Re: [R] To represent on the same plot the relation (y1, x) and (y2, x) Thank you Arun But have you a solution if y1 and y2 have not the

[R] To represent on the same plot the relation (y1, x) and (y2, x)

2013-08-31 Thread Arnaud Michel
Hello, I have 3 vectors x, y1 and y2 I would like to represent on the same plot the two graph (y1, x) and (y2, x). Is it possible with ggplot ? other package ? Thanks for your help -- Michel ARNAUD Chargé de mission auprès du DRH DGDRD-Drh - TA 174/04 Av Agropolis 34398 Montpellier cedex 5 tel

Re: [R] Change values in a dateframe-Speed TEST

2013-07-25 Thread Arnaud Michel
Le 25/07/2013 08:50, Berend Hasselman a écrit : On 25-07-2013, at 08:35, Arnaud Michel wrote: But I just noticed that the two solutions are not comparable : the change concern only Nom and Prenom (solution Berend) and not also Sexe or Date.de.naissance orother variables (solution Arun) that

Re: [R] Change values in a dateframe-Speed TEST

2013-07-24 Thread Arnaud Michel
But I just noticed that the two solutions are not comparable : the change concern only Nom and Prenom (solution Berend) and not also Sexe or Date.de.naissance orother variables (solution Arun) that can changed. But my question was badly put. Michel Le 25/07/2013 08:06, Arnaud Michel a écrit

Re: [R] Change values in a dateframe-Speed TEST

2013-07-24 Thread Arnaud Michel
identical(df2New,df2) #[1] TRUE A.K. - Original Message - From: Arnaud Michel To: R help Cc: Sent: Wednesday, July 24, 2013 2:39 AM Subject: [R] Change values in a dateframe Hello I have the following problem : The dataframe TEST has multiple lines for a same person because : there are

Re: [R] Change values in a dateframe

2013-07-24 Thread Arnaud Michel
Matricule,FUN=max)),]) row.names(df2New)<-1:nrow(df2New) identical(df1New,df1) #[1] TRUE identical(df2New,df2) #[1] TRUE A.K. - Original Message - From: Arnaud Michel To: R help Cc: Sent: Wednesday, July 24, 2013 2:39 AM Subject: [R] Change values in a dateframe Hello I have t

Re: [R] Change values in a dateframe

2013-07-24 Thread Arnaud Michel
Thank you Berend It is exactly what I wanted. Michel Le 24/07/2013 09:48, Berend Hasselman a écrit : On 24-07-2013, at 08:39, Arnaud Michel wrote: Hello I have the following problem : The dataframe TEST has multiple lines for a same person because : there are differents values of Nom or

[R] Change values in a dateframe

2013-07-23 Thread Arnaud Michel
Hello I have the following problem : The dataframe TEST has multiple lines for a same person because : there are differents values of Nom or differents values of Prenom but the values of Matricule or Sexe or Date.de.naissance are the same. TEST <- structure(list(Matricule = c(66L, 67L, 67L, 68L,

Re: [R] Calculate interaction for a big dataframe

2013-07-22 Thread Arnaud Michel
s you directly factor, paste gives you character vector, but it may be convenient too for your purpose. Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Arnaud Michel Sent: Monday, July 22, 2013 10:57 AM To: R help Subjec

[R] Calculate interaction for a big dataframe

2013-07-22 Thread Arnaud Michel
Hi To calculate the value of the interaction between factors of a dataframe df, does exist any function which could replace the function when the dataframe df has the numbers of rows of df is large (~55000) and also the numbers of combinaison of the three factors is large. The calcul abort. T

Re: [R] simplify a dataframe

2013-07-17 Thread Arnaud Michel
#4 02/02/1995 12/03/1995 #1 13/03/1995 30/06/1995 #2 01/01/1996 31/01/1996 A.K. - Original Message - From: arun To: Arnaud Michel Cc: R help ; Rui Barradas Sent: Wednesday, July 17, 2013 4:14 PM Subject: Re: [R] simplify a dataframe Hi, You could try: df1[,1:2]<-lapply

Re: [R] simplify a dataframe

2013-07-17 Thread Arnaud Michel
1/1996 31/01/1996 Thank you for your helps Michel Le 17/07/2013 19:57, Rui Barradas a écrit : Hello, As for question (1), try the following. y2 <- cumsum(c(TRUE, diff(x1) > 0)) identical(as.integer(y1), y2) # y1 is of class "numeric" As for question (2) I'm not understanding i

[R] simplify a dataframe

2013-07-17 Thread Arnaud Michel
Hi Arun I have two questions always about the question of symplify a dataframe I would like 1) to transform the vector x1 into the vector y1 x1 <- c(1,1,1,-1000, 1,-1000, 1,1,1,1,1,1,-1000) y1 <- c(1,1,1,1,2,2, 3,3,3,3,3,3,3) 2) to transform the vectors Deb

Re: [R] Question on plotting with googleVis

2013-07-17 Thread Arnaud Michel
1:150) library(googleVis) plot(gvisBarChart(MyData, xvar="Names1", yvar=c("Values1", "Values2"),options=list(width=1200,height=1500,hAxis.gridlines = "{count: 10}",hAxis.minValue = 0, hAxis.maxValue = 100))) However this is not clearly working. Can someone point

Re: [R] Question on plotting with googleVis

2013-07-16 Thread Arnaud Michel
You can try with list options : plot(gvisBarChart(MyData, xvar="Names1", yvar=c("Values1", "Values2"), options=list(width=1200,height=1500))) Le 15/07/2013 20:00, Christofer Bogaso a écrit : Hello again, Let say I have following data-frame: MyData <- data.frame(Names1 = paste("XXX", 1:150),

Re: [R] simplify a dataframe

2013-07-14 Thread Arnaud Michel
nrow(x)])!=1))),function(x) data.frame(x[1,1:6],Debut=head(x$Debut,1),Fin=tail(x$Fin,1),stringsAsFactors=FALSE)))})) row.names(res)<- 1:nrow(res) df2[11,8]<- "31/12/2013" names(res)[1]<- "Mat" identical(res,df2) #[1] TRUE A.K. - Original Message - Fro

Re: [R] simplify a dataframe

2013-07-14 Thread Arnaud Michel
,2 and if there is no interruption of time for the lines i and i+1 then df1$F[i] + 1 == df1$D[i+1] Michel Le 14/07/2013 18:17, Arnaud Michel a écrit : > Hi, > Excuse me for the indistinctness > Le 13/07/2013 17:18, arun a écrit : >> Hi, >> "when the value of Debut of

Re: [R] simplify a dataframe

2013-07-14 Thread Arnaud Michel
6 BENARD 01/01/1996 31/01/1996 #missing this row > 58 DALNIC 24/01/1995 31/08/1995 > 68 DALNIC 01/09/1995 29/02/2000 > 7 934 FORNI 26/01/1995 31/08/2001 > 8 934 FORNI 01/09/2001 31/08/2004 > 9 934 FORNI 01/09/2004 31/08/2007 > 10 934 FORNI 01/09/2007 04/09/201

[R] simplify a dataframe

2013-07-12 Thread Arnaud Michel
Hello I have the following problem : group the lines of a dataframe when no information change (Matricule, Nom, Sexe, DateNaissance, Contrat, Pays) and when the value of Debut of lines i = value Fin of lines i-1 I can obtain it with a do loop. Is it possible to avoid the loop ? The dataframe

[R] To transform a dataframe

2013-06-29 Thread Arnaud Michel
Hello I would like to transform the dataframe df1 into df2 (ie copy the data from several lines for a men/women to only one line by individu men/women) dput(df1) structure(list(Mat = c(934L, 934L, 934L, 935L, 935L, 936L, 936L, 936L, 936L, 937L, 937L, 937L, 937L), Nom = structure(c(2L, 2L, 2L,

Re: [R] a question to transform a dataframe empty 0/1

2013-06-20 Thread Arnaud Michel
Thank you arun ! I don't know the library reshape2 Michel Le 20/06/2013 19:55, arun a écrit : Hi, Not sure if you wanted the entries with "0". library(reshape2) dfMelt<-melt(df,id.var=c("Country","Iso")) #subset those with "1" dfNew<- subset(dfMelt,value==1,select=-4) row.names(dfNew)<- 1:

[R] a question to transform a dataframe empty 0/1

2013-06-20 Thread Arnaud Michel
Hello I have the following dataframe : df <- data.frame( Country=c("Zimbabwe","Burkina Faso","South Africa","Madagascar","Tanzania", "Mali","Mozambique","Madagascar","Ghana","Nigeria","Kenya","Burkina Faso", "South Africa","Tanzania","Kenya","Ethiopia" ) , Iso=c("ZW","BF","ZA","MG","TZ","ML","M

[R] to build a data.frame

2013-06-19 Thread Arnaud Michel
Hello I have the following dataframe df <- data.frame( Project=c("Abaco","Abaco","Abac","Abaco","Abaco","Abaco", "Abaco","Adaptclone","Adaptclone","Adaptclone","Adaptclone","Adaptclone", "Adaptclone","Adopt","Adopt","Adopt"), Country=c("Zimbabwe","Burkina Faso","South Africa","Madagascar","Tanz

[R] transform 3 numeric vectors empty of 0/1

2013-06-18 Thread Arnaud Michel
Dear all, Without a loop, I would like transform 3 numeric vectors empty of 0/1 of same length Vec1 : transform 1 to A and 0 to "" Vec2 : transform 1 to B and 0 to "" Vec3 : transform 1 to C and 0 to "" to obtain only 1 vector Vec who is the paste of the 3 vectors (Ex : ABC, BC, AC, AB,...) An

[R] a title on the map (function gvisGeoChart package googleVis )

2013-06-11 Thread Arnaud Michel
Hi I am using the package googleVis and the function gvisGeoChart Is it possible to put a title on the map ? Here is the call of the function : library(googleVis) G1 <- gvisGeoChart(PaysProjets, locationvar='Pays', colorvar='NbProj', options=list( region= "world", displayMode="regions", height=3