Hi
you maybe could use paste
> f1<-sample(letters[1:3], 10, replace=T)
> f2<-sample(letters[4:7], 10, replace=T)
> f3<-sample(letters[9:11], 10, replace=T)
> interaction(f1, f2, f3, drop=T)
[1] c.e.j b.e.j a.e.j c.g.i a.f.j b.g.k a.e.i a.e.k a.d.j b.e.j
Levels: a.e.i c.g.i a.d.j a.e.j b.e.j c.e.j a.f.j a.e.k
b.g.k> paste(f1, f2, f3, sep=".")
[1] "c.e.j" "b.e.j" "a.e.j" "c.g.i"
"a.f.j" "b.g.k" "a.e.i" "a.e.k"
"a.d.j"
[10] "b.e.j"
The difference is that interaction gives you directly factor, paste gives you
character vector, but it may be convenient too for your purpose.
Regards
Petr
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Arnaud Michel
> Sent: Monday, July 22, 2013 10:57 AM
> To: R help
> Subject: [R] Calculate interaction for a big dataframe
>
> Hi
>
> To calculate the value of the interaction between factors of a
> dataframe df, does exist any function which could replace the function
> when the dataframe df has the numbers of rows of df is large (~55000)
> and also the numbers of combinaison of the three factors is large. The
> calcul abort.
> The function to calculate the interaction is :
> as.numeric(interaction(df [,c(1:3)],drop=TRUE))
>
> To complete the question and to calculate interaction beetween 3
> factors f1, f2, f3, does it possible to calculate first f12 >
interaction
> (f1,f2) and after calculate interaction (f12, f3).
> It seems to me that yes.
>
> Thanks for your help
>
>
>
>
> --
> Michel ARNAUD
> Charg? de mission aupr?s du DRH
> DGDRD-Drh - TA 174/04
> Av Agropolis 34398 Montpellier cedex 5
> tel : 04.67.61.75.38
> fax : 04.67.61.57.87
> port: 06.47.43.55.31
>
> ______________________________________________
> R-help at 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.