Re: [R] Merging data XXXX

2012-01-13 Thread David Winsemius


On Jan 13, 2012, at 1:42 PM, Dan Abner wrote:


Hello everyone,

I have 1 data frame (just a vector in the example below) with 12
individuals listed and a separate vector of 36 days (in week  
intervals).

What is the best way to merge these together so that each individual
("specialist" here) has all 36 days matched with their specialist  
number (a

one to many merge in SAS; essentially resulting in long format data).

implement<-as.Date("2012-4-30")
start<-implement-91
weeks<-seq(start,by="weeks",length=36)
weeks
specialist<-1:12


?rep
?data.frame

I would not think 'merge' is needed ... you just want to make the  
right number of copies and you should be paying attention to the  
'each' and 'times' parameters.



[[alternative HTML version deleted]]

The above suggests failure adhere to the below

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html


--

David Winsemius, MD
West Hartford, CT

__
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, minimal, self-contained, reproducible code.


Re: [R] Merging data XXXX

2012-01-13 Thread Marc Schwartz

On Jan 13, 2012, at 12:42 PM, Dan Abner wrote:

> Hello everyone,
> 
> I have 1 data frame (just a vector in the example below) with 12
> individuals listed and a separate vector of 36 days (in week intervals).
> What is the best way to merge these together so that each individual
> ("specialist" here) has all 36 days matched with their specialist number (a
> one to many merge in SAS; essentially resulting in long format data).
> 
> implement<-as.Date("2012-4-30")
> start<-implement-91
> weeks<-seq(start,by="weeks",length=36)
> weeks
> specialist<-1:12
> 
> 
> Thanks!
> 
> Dan


Two ways:

  merge(specialist, weeks)

  expand.grid(specialist, weeks)

See ?merge which performs a SQL-like join operation and ?expand.grid which 
provides for all possible combinations of two or more vectors

HTH,

Marc Schwartz

__
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, minimal, self-contained, reproducible code.


[R] Merging data XXXX

2012-01-13 Thread Dan Abner
Hello everyone,

I have 1 data frame (just a vector in the example below) with 12
individuals listed and a separate vector of 36 days (in week intervals).
What is the best way to merge these together so that each individual
("specialist" here) has all 36 days matched with their specialist number (a
one to many merge in SAS; essentially resulting in long format data).

implement<-as.Date("2012-4-30")
start<-implement-91
weeks<-seq(start,by="weeks",length=36)
weeks
specialist<-1:12


Thanks!

Dan

[[alternative HTML version deleted]]

__
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, minimal, self-contained, reproducible code.