[R] merge two data frames

2010-08-04 Thread arnaud gaboury
Dear list, here are my two data frames: av - structure(list(DESCRIPTION = c(COFFEE C Sep/10, COPPER Sep/10, CORN Dec/10, CRUDE OIL miNY Sep/10, GOLD Aug/10, HENRY HUB NATURAL GAS Sep/10, PALLADIUM Sep/10, SILVER Sep/10, SOYBEANS Nov/10, SPCL HIGH GRADE ZINC USD, SUGAR NO.11 Oct/10, WHEAT

Re: [R] merge two data frames

2010-08-04 Thread arnaud gaboury
/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- ** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F

[R] sum specific rows in a data frame

2010-04-14 Thread arnaud Gaboury
I have a data frame called pose: DESCRIPTION QUANITY CLOSING.PRICE 1 WHEAT May/101467.75 2 WHEAT May/102467.75 3 WHEAT May/101467.75 4 WHEAT May/101467.75 5 COTTON NO.2 May/101 78.13

Re: [R] sum specific rows in a data frame

2010-04-14 Thread arnaud Gaboury
/10 78.133 2 WHEAT May/10 467.754 Op is a data.frame object.The trick is done! *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F __ R-help@r-project.org mailing list https

[R] sum rows in a data.frame

2010-04-15 Thread arnaud Gaboury
Dear group, Here is a data.frame, lme: lme DESCRIPTION CLOSING.PRICE POSITION 4PRIMARY NICKEL USD 04/06/1025,755.71000 5PRIMARY NICKEL USD 10/06/1025,760.86000 6 PRM HGH GD ALUMINIUM USD 09/07/10 2,415.90000 8 SPCL

[R] sum rows in a data.frame...solution

2010-04-15 Thread arnaud Gaboury
0 If someone has a better idea, it is welcomed. -Original Message- From: arnaud Gaboury [mailto:arnaud.gabo...@gmail.com] Sent: Thursday, April 15, 2010 9:50 AM To: 'r-help@r-project.org' Subject: sum rows in a data.frame Dear group, Here is a data.frame, lme: lme

[R] data.frame and ddply

2010-04-15 Thread arnaud Gaboury
Dear group, I have this following data.frame: c DESCRIPTION CREATED.DATE QUANITY CLOSING.PRICE 26 PRM HGH GD ALU 2010-04-09 -12,415.9000 27 PRM HGH GD ALU 2010-04-09 12,415.9000 28 PRIMARY NICKEL 2010-03-04 1 25,755.7100 29 PRIMARY NICKEL 2010-03-05

Re: [R] Replace / with - in date

2010-04-16 Thread arnaud Gaboury
Why don't you try something like : Xd$x=as.date(xd$x,format=%y/%m/%d). -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Christian Raschke Sent: Thursday, April 15, 2010 8:28 PM To: r-help@r-project.org Subject: Re: [R]

[R] data frame manipulation

2010-04-16 Thread arnaud Gaboury
Dear group, Here is my data.frame : df - structure(list(DESCRIPTION = c(PRM HGH GD ALU, PRM HGH GD ALU, PRIMARY NICKEL, PRIMARY NICKEL, PRIMARY NICKEL, PRIMARY NICKEL, STANDARD LEAD , STANDARD LEAD , STANDARD LEAD , STANDARD LEAD , STANDARD LEAD , STANDARD LEAD , STANDARD LEAD , STANDARD

Re: [R] data frame manipulation

2010-04-16 Thread arnaud Gaboury
*** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F *** From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Friday, April 16, 2010 1:05 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation Hi, I'm not sure I understand what you want

Re: [R] data frame manipulation

2010-04-16 Thread arnaud Gaboury
Excellent!! You saved me hours and hours of turning around and around. TY so much. From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Friday, April 16, 2010 1:37 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation It works for me... DF - + structure(list

[R] data.frame and ddply

2010-04-16 Thread arnaud Gaboury
-1 4 ROBUSTA COFFEE (10) May/10 1,353. 15 5 WHEAT May/10467.75004 It is almost exactly what I want, except I am expecting the POSITION column before the SETTLEMENT column. How can I modified my code to obtain this? TY *** Arnaud

Re: [R] data.frame and ddply

2010-04-16 Thread arnaud Gaboury
:02 PM To: arnaud Gaboury; r-help@r-project.org Subject: Re: [R] data.frame and ddply You can do something like this after the output from opfut opfut - data.frame(opfut$CONTRAT,opfut$POSITION,opfut$SETTLEMENT) names(opfut) - c('CONTRAT','POSITION','SETTLEMENT') opfut Felipe D. Carrillo

[R] read.csv data frame thousands separator

2010-04-23 Thread arnaud Gaboury
. *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F *** [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

[R] substract start from the end of the vector

2010-04-23 Thread arnaud Gaboury
, start, stop), but in my case, I need to indicate I want to start from the end of the vector, and I have no idea how to pass this argument. TY for any help *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F

Re: [R] substract start from the end of the vector

2010-04-23 Thread arnaud Gaboury
:11 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] substract start from the end of the vector Hi, On Fri, Apr 23, 2010 at 11:57 AM, arnaud Gaboury arnaud.gabo...@gmail.com wrote: Dear group, Here is my df : df - structure(list(DESCRIPTION = c(PRM HGH GD

[R] save a data frame in environment

2010-04-27 Thread arnaud Gaboury
is the process to save these 2 objects in order to access them later in another function? *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F *** [[alternative HTML version deleted]] __ R

Re: [R] save a data frame in environment

2010-04-27 Thread arnaud Gaboury
To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] save a data frame in environment Don't print them but return() them from your function position() within a list. Then you will have a list of two data.frames for later usage assigned to your list. Uwe Ligges On 27.04.2010 11

[R] data frame manipulation and regex

2010-04-28 Thread arnaud Gaboury
Dear group, Here is my data.frame : avprix - structure(list(DESCRIPTION = c(CORN Jul/10, CORN May/10, ROBUSTA COFFEE (10) Jul/10, SOYBEANS Jul/10, SPCL HIGH GRADE ZINC USD Jul/10, STANDARD LEAD USD Jul/10), prix = c(-1.5, -1082, 11084, 1983.5, -2464, -118), quantity = c(0, -3, 8, 2, -1, 0)),

[R] gsub,regex and replacing

2010-04-28 Thread arnaud Gaboury
Dear group, I need to modify some characters in a data frame. I want to use gsub and the regex functionalities to do this. Here is the data frame (df): DESCRIPTIONprix quantity 1 CORN Jul/10-1.50 2 CORN May/10 -1082.0

Re: [R] gsub,regex and replacing

2010-04-28 Thread arnaud Gaboury
)), .Names = c(DESCRIPTION, prix, quantity), row.names = c(NA, -6L), class = data.frame) From: jim holtman [mailto:jholt...@gmail.com] Sent: Wednesday, April 28, 2010 1:31 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] gsub,regex and replacing Next time you include a data frame

Re: [R] data frame manipulation and regex

2010-04-28 Thread arnaud Gaboury
TY so much david. We are getting close. But I need to keep USD in my object name (i.e STANDARD LEAD USD) *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F *** -Original Message- From: David Winsemius [mailto:dwinsem

[R] data frame move columns

2010-04-28 Thread arnaud Gaboury
Dear group, Here is my df: avprix - structure(list(DESCRIPTION = c(CORN Jul/10, CORN May/10, ROBUSTA COFFEE (10) Jul/10, SOYBEANS Jul/10, SPCL HIGH GRADE ZINC USD, STANDARD LEAD USD), prix = c(-1.5, -1082, 11084, 1983.5, -2464, -118), quantity = c(0, -3, 8, 2, -1, 0), fees = c(-8.64, -30.24,

Re: [R] data frame move columns

2010-04-28 Thread arnaud Gaboury
I want the 0s to be at the end or beginning. -Original Message- From: Erik Iverson [mailto:er...@ccbr.umn.edu] Sent: Wednesday, April 28, 2010 5:21 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame move columns avprix - structure(list(DESCRIPTION

Re: [R] data frame move columns

2010-04-28 Thread arnaud Gaboury
TY david. Here we go with a correct code! -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Wednesday, April 28, 2010 5:28 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame move columns On Apr 28, 2010, at 11:14 AM

[R] convert Factor as numeric

2010-04-29 Thread arnaud Gaboury
Dear group, I know this issue has been already covered, and before you reply I must say I have read the R-FAQ and search the mailing list archive. I still can't manage to change my factor to numeric as I couldn't find any clear answer. Here is my df : Pose1 - structure(list(DESCRIPTION =

Re: [R] convert Factor as numeric

2010-04-29 Thread arnaud Gaboury
TY petr, I was just trying something like that few mn ago :-) as.numeric(gsub(,, , S)) does exactly what I want. -Original Message- From: Petr PIKAL [mailto:petr.pi...@precheza.cz] Sent: Thursday, April 29, 2010 1:28 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Odp

[R] read.csv and blank character in object name of my data.frame

2010-04-30 Thread arnaud Gaboury
Dear group, Here is my data frame: position100415 - structure(list(DESCRIPTION = structure(1:9, .Label = c( SUGAR NO.11 Jul/10 , SUGAR NO.11 May/10 , CORN May/10 , COTTON NO.2 Jul/10 , CRUDE OIL miNY May/10 , ROBUSTA COFFEE (10) Jul/10 , SILVER May/10 , SOYBEANS Jul/10 , WHEAT May/10 ),

Re: [R] read.csv and blank character in object name of my data.frame

2010-04-30 Thread arnaud Gaboury
TY so much, I ignored about this argument. Adding stripe.white=T as an argument in my read.csv does the job. -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Friday, April 30, 2010 1:08 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re

[R] short question about data frame manipulation

2010-04-30 Thread arnaud Gaboury
Dear group, I am losing my mind with a simple question. Sorry if obvious, but I maybe start to be confused after days and days of reading documentations. Df : df - structure(list(a = 1:3, b = 4:6, c = structure(c(1L, 1L, 1L), class = factor, .Label = w)), .Names = c(a, b, c), row.names =

[R] Regex and gsub

2010-05-11 Thread arnaud Gaboury
$DESCRIPTION). Can't write the pattern argument in regex. Any help would be appreciated. TY *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Regex and gsub

2010-05-11 Thread arnaud Gaboury
TY for the two answers. Both work. -Original Message- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: Tuesday, May 11, 2010 11:21 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] Regex and gsub df3$DESCRIPTION = sub(' [a-z]{3}/[0-9]{2

[R] merging data frame

2010-05-11 Thread arnaud Gaboury
Dear group, I have 3 data frames I would like to merge. Here they are: pose16 - structure(list(DESCRIPTION = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 12L), .Label = c(COPPER May/10, COTTON NO.2 Jul/10, CRUDE OIL miNY May/10, GOLD Jun/10, ROBUSTA COFFEE (10) Jul/10, SOYBEANS Jul/10,

Re: [R] merging data frame

2010-05-11 Thread arnaud Gaboury
In fact, that is one solution. I can then do a ddply(x,DESCRIPTION,summarise, pl=sum(prix),quantity=sum(POSITION)). It does work. I was just wandering if it exists another solution. From: jim holtman [mailto:jholt...@gmail.com] Sent: Tuesday, May 11, 2010 2:14 PM To: arnaud Gaboury Cc: r-help

[R] merge two data frames

2010-05-11 Thread arnaud Gaboury
Dear group, I have these 2 following data frame: allcon - structure(list(DESCRIPTION = structure(1:17, .Label = c(COFFEE C Jul/10, COPPER May/10, CORN Jul/10, CORN May/10, COTTON NO.2 Jul/10, CRUDE OIL miNY May/10, GOLD Jun/10, HENRY HUB NATURAL GAS May/10, ROBUSTA COFFEE (10) Jul/10, SILVER

Re: [R] merge two data frames

2010-05-11 Thread arnaud Gaboury
SYSTEMATICALLY add the argument strip.white=T when I read a csv file, so all blanks are removed. -Original Message- From: arnaud Gaboury [mailto:arnaud.gabo...@gmail.com] Sent: Tuesday, May 11, 2010 4:25 PM To: r-help@r-project.org Cc: 'arnaud Gaboury' Subject: merge two data frames Dear

[R] data frame subscription

2010-05-12 Thread arnaud Gaboury
Dear group, Here is my df : pose16 - structure(list(DESCRIPTION = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 12L), .Label = c(COPPER May/10, COTTON NO.2 Jul/10, CRUDE OIL miNY May/10, GOLD Jun/10, ROBUSTA COFFEE (10) Jul/10, SOYBEANS Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 May/10, WHEAT

Re: [R] data frame subscription

2010-05-12 Thread arnaud Gaboury
I was just adding the minus sign to the line when I got your mail. Yes, it works that way. TY for the transform function. -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Wednesday, May 12, 2010 5:07 PM To: Henrique Dallazuanna Cc: arnaud Gaboury; r

Re: [R] data frame subscription

2010-05-12 Thread arnaud Gaboury
, 244.77, 166.48, 2273.8, 24876, 2985, 80.9, -15.95, 2512.5, -2423)), .Names = c(DESCRIPTION, POSITION, prix), row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 51), class = data.frame) From: Henrique Dallazuanna [mailto:www...@gmail.com] Sent: Wednesday, May 12, 2010 3:32 PM To: arnaud Gaboury Cc: r

Re: [R] data frame subscription

2010-05-12 Thread arnaud Gaboury
TY. Didn't know this function. From: Henrique Dallazuanna [mailto:www...@gmail.com] Sent: Wednesday, May 12, 2010 3:32 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame subscription Try this: transform(pose16, prix = POSITION * SETTLEMENT, SETTLEMENT = NULL

[R] access objects in my environment

2010-05-13 Thread arnaud Gaboury
Dear group, Here are my objects in my environment: ls() [1] Pos100415 Pos100416 posA pose15pose16pose16t position trade x I need to pass the object Pos100415 to a function. This element is a data.frame, obtained through a function: Pos(x)-myfun(x) with x-100415 in this

Re: [R] access objects in my environment

2010-05-13 Thread arnaud Gaboury
Wonderful!! TY so much for the help. -Original Message- From: Patrizio Frederic [mailto:frederic.patri...@gmail.com] Sent: Thursday, May 13, 2010 10:47 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] access objects in my environment Hi, have a look

[R] long command line cut in 2 parts

2010-05-13 Thread arnaud Gaboury
Dear group, I have this command line in a function: zz-merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,VALUE= NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F) I want to cut it in 2 lines (just for convenient purpose). Here is what I did :

Re: [R] long command line cut in 2 parts

2010-05-13 Thread arnaud Gaboury
Removing the + sign resolves the problem. TY -Original Message- From: Muhammad Rahiz [mailto:muhammad.ra...@ouce.ox.ac.uk] Sent: Thursday, May 13, 2010 3:15 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] long command line cut in 2 parts Dear Arnaud, Wrap

[R] regex and sub

2010-05-14 Thread arnaud Gaboury
Dear group, Here is an object: z - c(LSCPos100415.csv, LSCPos100416.csv, LSCPos100419.csv, LSCPos100420.csv, LSCPos100421.csv, LSCPos100422.csv, LSCPos100423.csv, LSCPos100426.csv, LSCPos100427.csv, LSCPos100428.csv, LSCPos100429.csv, LSCPos100430.csv, LSCPos100503.csv, LSCPos100504.csv,

Re: [R] regex and sub

2010-05-14 Thread arnaud Gaboury
Of course this helps! I didn't noticed the difference between sub and gsub. TY -Original Message- From: Bernd Weiss [mailto:bernd.we...@uni-koeln.de] Sent: Friday, May 14, 2010 12:23 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] regex and sub Am 14.05.2010

[R] writing function

2010-05-20 Thread arnaud Gaboury
Dear group, I am trying to write functions, but as a beginner, everything is not so obvious. Let's say I want the results in a list of elemts like this : tot1, tot2, etc Here is a function: toto - function(x,y) { for(i in x:y){ paste(c(tot,i),collapse=)-(i*2) } } If I type this :

[R] select elements in a list

2010-05-21 Thread arnaud Gaboury
-100415 et y-100420, the result I want is 100415,100416,100419,100420. The object l is a list, but can be of any other kind if it can help. I tried something like this : select-l[c(x:y)] But it doesn't return the needed result Any help would be appreciated *** Arnaud

Re: [R] select elements in a list

2010-05-21 Thread arnaud Gaboury
elements in a list Hi, This should work: select - l[which(l==x):which(l==y)] The problem is that you tried to select the values, but gave x and y as indexes. That's why you didn't get the expected result. See ?which for more info. HTH, Ivan Le 5/21/2010 11:07, arnaud Gaboury

[R] indexing problem

2010-05-21 Thread arnaud Gaboury
Dear group, Here is my environment : ls() [1] l PLglobal Pos100415 Pos100416 Pos100419 Pos100420 position select Trad100415 Trad100416 Trad100419 Trad100420 trade y With objects : l [1] 100415 100416 100419 100420 100421 100422 100423 100426 100427 100428 100429

Re: [R] indexing problem

2010-05-21 Thread arnaud Gaboury
Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Friday, May 21, 2010 4:00 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] indexing problem On May 21, 2010, at 9:19 AM, arnaud Gaboury wrote: Dear group, Here is my environment : ls() [1

Re: [R] indexing problem

2010-05-21 Thread arnaud Gaboury
This do the trick : for (i in 1:length(sel) ){ posA-get(paste(c(Pos,sel[i]),collapse=)) posB-get(paste(c(Pos,sel[i]+1),collapse=)) } -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Friday, May 21, 2010 4:00 PM To: arnaud Gaboury Cc: r

[R] writing function:loop and rbind

2010-05-24 Thread arnaud Gaboury
Dear group, I have a function, let's call it myfun, wich give me a list of result: R1,R2,R3... There is a loop in this function to get my results. Here is the structure of my function: Myfun-function() { For (i in X ){ ---instructions- Ri { { All Results (R1,R2...) are

Re: [R] writing function:loop and rbind

2010-05-24 Thread arnaud Gaboury
,] DailyPL100416 DailyPL100419 DailyPL100420 That's not what I want! I expect DF to be a data.frame binded by row. I suspect there is an issue with get() or assign(), or something like that. Any help is appreciated. -Original Message- From: arnaud Gaboury [mailto:arnaud.gabo...@gmail.com

Re: [R] writing function:loop and rbind

2010-05-24 Thread arnaud Gaboury
Maybe is there a neater solution, but the function mget() does the trick. So until further advice, I will work with your solution. Thank you -Original Message- From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] Sent: Monday, May 24, 2010 5:07 PM To: arnaud Gaboury Cc: r-help@r

Re: [R] writing function:loop and rbind

2010-05-24 Thread arnaud Gaboury
Do you think there is a way to add somewhere the argument row.names=NULL ? Or should I have to write another line to remove the row.names? -Original Message- From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] Sent: Monday, May 24, 2010 5:07 PM To: arnaud Gaboury Cc: r-help@r

[R] writing function

2010-05-24 Thread arnaud Gaboury
Dear group, Here is my environment after I run a function, myfun() myfun() ls() [1] allconavprix16 DailyPL100416 DailyPL100419 DailyPL100420 l llmyl PL PLdaily PLglobal PLmonthly [13] Pos100415 Pos100416 Pos100419

Re: [R] writing function

2010-05-24 Thread arnaud Gaboury
Thank you so much. You are totally right. -Original Message- From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] Sent: Monday, May 24, 2010 6:33 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] writing function My guess is that either ls(), called inside grep

[R] writing function : can't find an object

2010-05-26 Thread arnaud Gaboury
Dear group, Here is my function: #return the daily PL for day y PLDaily-function(x,y) { #find elements in my directory with LSCPos in the name, keep the numeric part in the name and #create a list l-gsub(\\D,,dir()[grep(LSCPos,dir())]) #select in the list the desired elements

[R] (no subject)

2010-05-26 Thread arnaud Gaboury
help is appreciated *** Arnaud Gaboury Mobile: +41 79 392 79 56 BBM: 255B488F __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting

[R] condition apply to elements of a data frame column

2010-05-26 Thread arnaud Gaboury
Oops, forgot to give a subject -Original Message- From: arnaud Gaboury [mailto:arnaud.gabo...@gmail.com] Sent: Wednesday, May 26, 2010 2:31 PM To: r-help@r-project.org Cc: 'arnaud Gaboury' Subject: Dear group, Here is my data frame: dput(u) structure(list(DESCRIPTION

Re: [R] condition apply to elements of a data frame column

2010-05-26 Thread arnaud Gaboury
element different from zero). From: Joris Meys [mailto:jorism...@gmail.com] Sent: Wednesday, May 26, 2010 2:48 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] (no subject) What exactly are you trying to do? If you want to know which position is wrong, try : if (sum(u$POSITION

[R] data frame manipulation change elements meeting criteria

2010-05-26 Thread arnaud Gaboury
Dear group, Here is my df : trade - structure(list(Trade.Status = c(DEL, INS, INS), Instrument.Long.Name = c(SUGAR NO.11, CORN, CORN), Delivery.Prompt.Date = c(Jul/10, Jul/10, Jul/10), Buy.Sell..Cleared. = c(Sell, Buy, Buy), Volume = c(1L, 2L, 1L), Price = c(15.2500, 368., 368.5000),

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
Thank you for the answer. Is there any way to combine if() and switch() in one line? In my case, something like : if(trade$Trade.Status==DEL)switch(.) I would like to avoid the loop . From: Joris Meys [mailto:jorism...@gmail.com] Sent: Wednesday, May 26, 2010 9:15 PM To: arnaud Gaboury

[R] switch function

2010-05-27 Thread arnaud Gaboury
Dear group, Here is my df : trades - structure(list(Trade.Status = c(DEL, INS, INS), Instrument.Long.Name = c(SUGAR NO.11, CORN, CORN), Delivery.Prompt.Date = c(Jul/10, Jul/10, Jul/10), Buy.Sell..Cleared. = c(Sell, Buy, Buy), Volume = c(1L, 2L, 1L), Price = c(15.2500, 368., 368.5000),

[R] data frame change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
. NULL That's certainly not what I want. From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 8:43 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria The loop is due to the switch statement

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
..sum. NULL That's certainly not what I want. From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 8:43 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria The loop is due to the switch statement

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
, Instrument.Long.Name, Delivery.Prompt.Date, Buy.Sell..Cleared., Volume, Price, Net.Charges..sum.), row.names = c(NA, 3L), class = data.frame) From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 10:38 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame

Re: [R] data frame manipulation change elements meeting criteria

2010-05-27 Thread arnaud Gaboury
To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame manipulation change elements meeting criteria Off course. You put in a matrix to sapply, but sapply is for vectors. You want to apply the switch command on every entry of the vector trades$Buy.Sell..Cleared for which trades

Re: [R] switch function

2010-05-27 Thread arnaud Gaboury
, Instrument.Long.Name, Delivery.Prompt.Date, Buy.Sell..Cleared., Volume, Price, Net.Charges..sum.), row.names = c(NA, 3L), class = data.frame) From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 10:38 AM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] data frame

Re: [R] switch function

2010-05-27 Thread arnaud Gaboury
: Thursday, May 27, 2010 2:34 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] switch function try this: toBuy - trades$Trade.Status == DEL trades$Buy.Sell..Cleared. == Sell toSell - trades$Trade.Status == DEL trades$Buy.Sell..Cleared. == Buy x - trades # make a copy

[R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
Dear group, Here is the kind of data.frame I obtain every day with my function : futures - structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10, CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10, LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
To: arnaud Gaboury Subject: Re: [R] data frame manipulation with zero rows On Tue, 1 Jun 2010, arnaud Gaboury wrote: Dear group, Here is the kind of data.frame I obtain every day with my function : futures - structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10, CORN Jul/10

[R] data frame manipulation ddply

2010-06-01 Thread arnaud Gaboury
Dear group, Here is my data frame: futures - structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10, CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10, LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10 ),

Re: [R] data frame manipulation ddply

2010-06-01 Thread arnaud Gaboury
...@uni-bremen.de] Sent: Tuesday, June 01, 2010 11:38 AM To: arnaud Gaboury Subject: Re: [R] data frame manipulation ddply Hi Arnaud, maybe aggregate can help: PosFut - aggregate(futures$QUANTITY, list(DESCRIPTION = futures$DESCRIPTION, SETTLEMENT

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
It is indeed ddply() from package plyr. -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: Tuesday, June 01, 2010 12:24 PM To: Peter Ehlers Cc: arnaud Gaboury; r-help@r-project.org Subject: Re: [R] data frame manipulation with zero rows On Tue, 1

[R] as.date

2010-06-01 Thread arnaud Gaboury
Dear group, Here is my df (obtained with a read.csv2()): df - structure(list(DESCRIPTION = c(COTTON NO.2 Jul/10, COTTON NO.2 Jul/10, PALLADIUM Jun/10, PALLADIUM Jun/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10), CREATED.DATE = c(13/05/2010, 13/05/2010, 14/05/2010, 14/05/2010, 10/05/2010,

Re: [R] as.date

2010-06-01 Thread arnaud Gaboury
TY for the tip. The lower case is in fact the culprit. -Original Message- From: Erik Iverson [mailto:er...@ccbr.umn.edu] Sent: Tuesday, June 01, 2010 6:05 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] as.date Where does the problem comes from?? Maybe from

Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
Maybe not the cleanest way, but I create a fake data frame with one row so ddply() is happy!! if (nrow(futures)==0) futures-data.frame(...) -Original Message- From: Peter Ehlers [mailto:ehl...@ucalgary.ca] Sent: Tuesday, June 01, 2010 12:07 PM To: arnaud Gaboury Cc: 'Prof

[R] which function

2010-06-02 Thread arnaud Gaboury
Dear group, Here is a list of elements : l - c(100415, 100416, 100419, 100420, 100421, 100422, 100423, 100426, 100427, 100428, 100429, 100430, 100503, 100504, 100505, 100506, 100507, 100510, 100511, 100512, 100513, 100514, 100517, 100518, 100519, 100520, 100521, 100524, 100525, 100526,

Re: [R] which function

2010-06-02 Thread arnaud Gaboury
The correct line is : l[(which(100420==l)-1):which(100420==l)] [1] 100419 100420 -Original Message- From: arnaud Gaboury [mailto:arnaud.gabo...@gmail.com] Sent: Wednesday, June 02, 2010 9:41 AM To: r-help@r-project.org Cc: 'arnaud Gaboury' Subject: which function Dear group

Re: [R] data frame manipulation with zero rows

2010-06-02 Thread arnaud Gaboury
I do really think it is a very good idea. TY -Original Message- From: h.wick...@gmail.com [mailto:h.wick...@gmail.com] On Behalf Of Hadley Wickham Sent: Wednesday, June 02, 2010 3:31 PM To: arnaud Gaboury Cc: Peter Ehlers; r-help@r-project.org; Prof Brian Ripley Subject: Re: [R

[R] bind select data frames

2010-06-02 Thread arnaud Gaboury
Dear group, Here is my environment: ls() [1] DailyPL100419 DailyPL100420 DailyPL100421 ddi l PLglobal Pos100416 Pos100419 Pos100420 Pos100421 position [13] resultsel Trad100416Trad100419 Trad100420Trad100421trade With

Re: [R] bind select data frames

2010-06-02 Thread arnaud Gaboury
Wiley [mailto:jwiley.ps...@gmail.com] Sent: Wednesday, June 02, 2010 4:48 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] bind select data frames Hello, Does this do what you are looking for? output - NULL for(i in paste(DailyPL, sel, sep=)[-1

Re: [R] bind select data frames

2010-06-02 Thread arnaud Gaboury
-Original Message- From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] Sent: Wednesday, June 02, 2010 4:48 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] bind select data frames Hello, Does this do what you are looking for? output - NULL for(i in paste

Re: [R] bind select data frames

2010-06-02 Thread arnaud Gaboury
= ), envir = .GlobalEnv), : unused argument(s) (row.names = NULL) Why this error? TY for your help -Original Message- From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] Sent: Wednesday, June 02, 2010 5:08 PM To: arnaud Gaboury Cc: r-help@r-project.org Subject: Re: [R] bind

Re: [R] bind select data frames

2010-06-02 Thread arnaud Gaboury
Here we go : dd-data.frame(do.call(rbind, mget(paste(DailyPL,sel[-1],sep=),envir=.GlobalEnv)),row.names=NULL) TY so much Joshua and Jorge. -Original Message- From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] Sent: Wednesday, June 02, 2010 5:11 PM To: arnaud Gaboury Cc: r-help@r

Re: [R] bind select data frames

2010-06-02 Thread arnaud Gaboury
Jorge, Your line works and give the desired result. Now I need to be able to work with i instead of 100419..., as I need to be able to change these numbers. TY for your help From: Jorge Ivan Velez [mailto:jorgeivanve...@gmail.com] Sent: Wednesday, June 02, 2010 5:09 PM To: arnaud Gaboury Cc

[R] data frame colnames through ddply

2012-02-23 Thread Arnaud Gaboury
and renamed it Nbr.Lots. This line works. What I would like is changing the col names in the same line, thus avoiding another line with colnames(exportfile)-c(Contract,Price,Nbr.Lots) Is there a possibility to change my col names in the same line? TY Arnaud Gaboury   A2CT2 Ltd

[R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
. TY for any help. Trading   A2CT2 Ltd. Arnaud Gaboury   A2CT2 Ltd. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
TY Uwe, So I will have to write a line for each condition? Right? In fact I was trying to do something with apply in one line, but couldn't achieve any result. In fact, all my transformation will be multiplying one object by a specific number according to the value of df$x. Arnaud Gaboury

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
this as result : df x y 1 AA 10 if df$x==AA, df$y-1*10 2 BB 50 if df$x==BB, df$y-2*25 3 CC 3 NOTHING 4 AA 40 if df$x==AA, df$y-4*10 5 DD 75 if df$x==DD, df$y-5*15 6 DD 90 if df$x==DD, df$y-6*15 Arnaud Gaboury   A2CT2 Ltd. -Original Message

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
clear enough, and YES I have tried many workarounds myself before posting. Feel free to ignore my post if you think I am lazy and disrespectful to the list. Arnaud Gaboury   A2CT2 Ltd. -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: vendredi 24 février

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
, 14L, 15L, 16L, 17L, 18L, 19L, 8L, 9L, 10L, 11L, 12L, 20L, 21L, 22L, 23L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 31L, 32L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 2L, 3L, 1L, 33L, 34L), class = data.frame) Have a good weekend. Arnaud Gaboury   A2CT2 Ltd. Trade: +41 22 849 88 63 Fax:   +41 22 849 88

Re: [R] data frame manipulation with condition

2012-02-24 Thread Arnaud Gaboury
WORKING Now day 2 with df2: df2 - data.frame(x = c(AA,AA,BB,BB,BB,CC,DD,DD), y = 1:8) df2$y - df2$y * mult[as.character(df2$x)] df2 x y 1 AA 2 2 AA 4 3 BB 15 4 BB 20 5 BB 25 6 CC 6 7 DD 14 8 DD 16 WORKING Ty both of you and have a good weekend. Arnaud Gaboury   A2CT2 Ltd

Re: [R] install rJava in Ubuntu 11.10

2012-02-24 Thread Arnaud Gaboury
the openJDK path in your environment. Hope this help. Arnaud Gaboury   A2CT2 Ltd. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of John Kane Sent: vendredi 24 février 2012 19:32 To: r-help@r-project.org Subject: [R] install

Re: [R] data frame manipulation with conditions

2012-02-24 Thread Arnaud Gaboury
TY Elai for your answer. One solution has been given earlier in this list by Sarah Goslee and William Dunlap. Arnaud Gaboury   A2CT2 Ltd. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of ilai Sent: vendredi 24 février 2012 20:14

[R] compare two data frames with same columns names but of different dimensions

2012-02-27 Thread Arnaud Gaboury
= c(NA, 9L), class = data.frame) As you can see, they have same column names. My idea was to merge these two df when passing as argument not to take into account duplicate rows, so I will get one df with rows which are not in both df. Is it possible? How to do it? TY for any help. Arnaud

Re: [R] Ubuntu jaunty - R can't be install

2012-02-27 Thread Arnaud Gaboury
I don't understand where is your problem. Are you looking for jaunty as a package on R Crans?? Are you looking to install R package on your Ubuntu box? As you know, Jaunty is no more supported by Ubuntu, so packets have been moved in Archives. Arnaud Gaboury   A2CT2 Ltd. -Original

[R] compare two data frames of different dimensions and only keep unique rows

2012-02-27 Thread Arnaud Gaboury
, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61, -61, 6, 40, 40, -1, -1, -1, 1, -61, -61, 5, 1, 40, 40, -1, -1, -1, 1)), .Names = c(Product, Price, Nbr.Lots), row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 21, 31, 41, 61, 71, 51, 10, 81, 91), class = data.frame) TY for your help Arnaud Gaboury   A2CT2

  1   2   >