[R] Data.frame Question

2010-03-11 Thread GULATI, BRIJESH (Global Markets FFO NY)
Hi: I want to add a constant to an existing col of the data.frame. I have the following dataset: structure(list(x = c(1, 1, 1, 1, 1), y = c(1, 1, 1, 1, 1)), .Names = c(x, y), row.names = c(NA, 5L), class = data.frame) I want to add a

Re: [R] Data.frame Question

2010-03-11 Thread Henrique Dallazuanna
Try this: sweep(DF, 2, 1:2, '+') On Thu, Mar 11, 2010 at 9:20 AM, GULATI, BRIJESH (Global Markets FFO NY) brijesh.gul...@baml.com wrote:       Hi:               I want to add a constant to an existing col of the data.frame. I have the following dataset:       structure(list(x = c(1, 1,

[R] Data.frame Question (add constant to a row)

2010-03-10 Thread GULATI, BRIJESH (Global Markets FFO NY)
Hi: I want to add a constant to an existing col of the data.frame. I have the following dataset: structure(list(x = c(1, 1, 1, 1, 1), y = c(1, 1, 1, 1, 1)), .Names = c(x, y), row.names = c(NA, 5L), class = data.frame) I want to add a constant to col 1 and col 2 to get the

[R] data.frame question

2010-03-07 Thread joseph
hello can you show me how to create a data.frame from two factors x and y. column 1 should be equal to x and column 2 is 1 if it is common to y and 0 if it is not. x=factor(c(A,B,C,D,E,F,G)) y=factor(c(B,C,G)) the output should look like this: A0 B1 C1 D0 E0 F0 G1

Re: [R] data.frame question

2010-03-07 Thread baptiste auguie
Hi, try this, data.frame(x,as.numeric(x %in% y)) HTH, baptiste On 7 March 2010 21:06, joseph jdsan...@yahoo.com wrote: hello can you show me how to create a data.frame from two factors x and y. column 1 should be equal to x and column 2 is 1 if it is common to y and 0 if it is not.

Re: [R] data.frame question

2010-03-07 Thread Stephan Kolassa
Hi, data.frame(x=x,y=as.numeric(x%in%y)) HTH, Stephan joseph schrieb: hello can you show me how to create a data.frame from two factors x and y. column 1 should be equal to x and column 2 is 1 if it is common to y and 0 if it is not. x=factor(c(A,B,C,D,E,F,G)) y=factor(c(B,C,G)) the