[R] Interweaving of two datasets
Rui Barradas
ruipbarradas at sapo.pt
Fri May 4 16:19:31 CEST 2012
Hello,
lunarossa wrote
>
> I have two datasets, the first has this shape (each word is a column)
> Name address phone .. ..
>
> The second one has the following shape
> Name request
>
> I need a contingency table with for example phone and request.
>
>
> The people registered in these datasets are present in both datasets, BUT
> in the first every record is a person, so every person is counted once and
> is 1 row, in the second every row is a request, so if a person has
> requested 1 thing this person is present only once, but is the person has
> requested 3 things, this person we'll be present 3 times.
>
> I now that to use access could be the solution, but in this moment the
> computer expert give me data only as .xls/.csv data.
>
> This creates the possibility of two different cross tab, I really need
> both,
> the first has as total count the number of people
> The second one has as total count the number of request
>
Try
?merge
set.seed(1)
df1 <- data.frame(Name=LETTERS[1:5], Phone=1:5)
df2 <- data.frame(Name=sample(LETTERS[1:5], 20, TRUE),
Request=sample(letters[1:3], 20, TRUE))
joined <- merge(df1, df2)
with(joined, table(Name, Request))
Also, I hope this is what you want, it corresponds to your description but
there's no "reproducible example (posting-guide)".
Rui Barradas
--
View this message in context: http://r.789695.n4.nabble.com/Interweaving-of-two-datasets-tp4608505p4608740.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list