kayj <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]:

> 
> I have two data sets data1 and data2  with no column names( No
> header). The first coluimn in both data sets represents the case ID.
> How can I tell R to merge the two data sets by the case ID if there
> is no header? Also, In data1 I have more cases and I would like the
> result of the merge to have all the cases in both data1 and data2.
> there may be some duplicate cases. 

If you bring the data into a dataframe, default variable names will be 
assigned. merge would be the function to use but you will need to 
decide if its default behavior is satisfactory.

See whether these examples are illuminating:

vv <- data.frame(V1=1:10, V2=letters[1:10]) 

# read.table("data1.txt", header=FALSE)  would produce a data.frame 
# with # first variable, V1
# However, merge would use all the column names the are shared unless 
# told to not do so. So give the other columns different names:

vv2 <- data.frame(V1=5:14, V8=letters[5:14])
merge(vv,vv2)
merge(vv,vv2,all=TRUE)

# create a duplicate
vv[8,1] <- 7
merge(vv,vv2,all=TRUE)

-- 
David Winsemius

______________________________________________
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.

Reply via email to