Re: [R] data manipulation question

2021-08-23 Thread Jim Lemon
Hi Kai, How about setting: germlinepatients$DisclosureStatus <- NA then having your three conditional statements as indices: germlinepatients$DisclosureStatus[germlinepatients$gl_resultsdisclosed == 1] <-"DISCLOSED" germlinepatients$DisclosureStatus[germlinepatients$ gl_resultsdisclosed == 0]

[R] data manipulation question

2021-08-23 Thread Kai Yang via R-help
Hello List, I wrote the script below to assign value to a new field DisclosureStatus. my goal is if gl_resultsdisclosed=1 then DisclosureStatus=DISCLOSED else if gl_resultsdisclosed=0 then DisclosureStatus= ATTEMPTED else if gl_resultsdisclosed is missing and gl_discloseattempt1 is not missing

Re: [R] Data Manipulation Question

2009-12-04 Thread Barry Rowlingson
On Thu, Dec 3, 2009 at 9:52 PM, John Filben johnfil...@yahoo.com wrote: Can R support data manipulation programming that is available in the SAS datastep?  Specifically, can R support the following: -  Read multiple dataset one record at a time and compare values from each; then base

Re: [R] Data Manipulation Question

2009-12-04 Thread Gray Calhoun
This is probably far more discussion than the question warranted, but... On Thu, Dec 3, 2009 at 11:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Dec 3, 2009, at 10:52 PM, Gray Calhoun wrote: The data import/export manual can elaborate on a lot of these; this is all straightforward,

[R] Data Manipulation Question

2009-12-03 Thread John Filben
Can R support data manipulation programming that is available in the SAS datastep?  Specifically, can R support the following: -          Read multiple dataset one record at a time and compare values from each; then base on if-then logic write to multiple output files -        

Re: [R] Data Manipulation Question

2009-12-03 Thread hadley wickham
On Thu, Dec 3, 2009 at 3:52 PM, John Filben johnfil...@yahoo.com wrote: Can R support data manipulation programming that is available in the SAS datastep?  Specifically, can R support the following: -  Read multiple dataset one record at a time and compare values from each; then base

Re: [R] Data Manipulation Question

2009-12-03 Thread Jason Morgan
Please refrain from posting HTML. The results can be incomprehensible: On 2009.12.03 13:52:09, John Filben wrote: Can R support data manipulation programming that is available in the SAS datastep??? Specifically, can R support the following: -?? Read multiple dataset one

Re: [R] Data Manipulation Question

2009-12-03 Thread Gray Calhoun
The data import/export manual can elaborate on a lot of these; this is all straightforward, although many people would prefer to use a relational database for some of the things you mentioned. I'm not aware of a goto command in R, though (although I could be wrong). --Gray On Thu, Dec 3, 2009 at

Re: [R] Data Manipulation Question

2009-12-03 Thread David Winsemius
On Dec 3, 2009, at 10:52 PM, Gray Calhoun wrote: The data import/export manual can elaborate on a lot of these; this is all straightforward, although many people would prefer to use a relational database for some of the things you mentioned. See Wickham's pithy response to this. I'm not

[R] Data manipulation question

2008-11-06 Thread Peter Jepsen
Dear R-listers, I am a relatively inexperienced R-user currently migrating from Stata. I am deeply frustrated by this data manipulation question: I know how I could do it in Stata, but I cannot make it work in R. I have a data frame of hospitalization data where each row represents an admission.

Re: [R] Data manipulation question

2008-11-06 Thread bartjoosen
How about: id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1)) start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0)) stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6)) data - data.frame(id,start,stop) f - function(data){ m - match(data$start,data$stop) + 1 if (length(m)==1

Re: [R] Data manipulation question

2008-11-06 Thread cruz
On Thu, Nov 6, 2008 at 4:23 PM, Peter Jepsen [EMAIL PROTECTED] wrote: Here is an example: id - c(rep(a,4),rep(b,2), rep(c,5), rep(d,1)) start - c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0)) stop - c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6)) data - as.data.frame(cbind(id,start,stop)) data

Re: [R] Data manipulation question

2008-11-06 Thread Peter Jepsen
special cases outside my small example dataset. Thank you again! Peter. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bartjoosen Sent: 6. november 2008 11:31 To: r-help@r-project.org Subject: Re: [R] Data manipulation question How about: id - c(rep(a,4

[R] Data manipulation question (opposite of table?)

2008-01-27 Thread Michael Denslow
Dear R users, I am a new user (probably obvious by my question) and have really learned a lot from reading this list. Thank you all very much. My main struggles with R are with data manipulation. So here is my question... I have data that is organized as below, this is a short example. value

Re: [R] Data manipulation question (opposite of table?)

2008-01-27 Thread David Winsemius
Michael Denslow [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Dear R users, I am a new user (probably obvious by my question) and have really learned a lot from reading this list. Thank you all very much. My main struggles with R are with data manipulation. So here is my

[R] Data manipulation question

2007-10-10 Thread Julien Barnier
Hi all, Suppose I have the following data.frame, with an id column and two variables columns : idX Y 0001 NA 21 0002 NA 13 0003 000145 0004 NA 71 0005 000320 What I would like to do is to create a new variable Z whose values are the

Re: [R] Data manipulation question

2007-10-10 Thread Gabor Grothendieck
Try this: transform(d, z = y[match(x, id)]) On 10/10/07, Julien Barnier [EMAIL PROTECTED] wrote: Hi all, Suppose I have the following data.frame, with an id column and two variables columns : idX Y 0001 NA 21 0002 NA 13 0003 000145 0004