Skip to content
Prev 305908 / 398525 Next

Merging two or more frequency tables

HI,

Inspired from Rui's function:
Slightly modified:
?fun1<-function(x,...){
?z<-paste(unlist(list(x,...)),collapse=" ")
?tsum<-table(strsplit(tolower(z),"\\W"))
?tsum}
?fun1(x,y)
? # age????? belief??? darkness?????? epoch foolishness incredulity 
??? # ???? 2?????????? 1?????????? 1?????????? 2?????????? 1?????????? 1 
???? # ?? it?????? light????????? of????? season???????? the???????? was 
?????? # ? 6?????????? 1?????????? 6?????????? 2?????????? 6?????????? 6 
??? # wisdom 
????? # ?? 1 
A.K.




----- Original Message -----
From: Rui Barradas <ruipbarradas at sapo.pt>
To: mcelis <mcelis at lightminersystems.com>
Cc: r-help at r-project.org
Sent: Wednesday, September 19, 2012 6:18 PM
Subject: Re: [R] Merging two or more frequency tables

Hello,

Try the following.


fun <- function(x, ...){
? ?  z <- Reduce(paste, list(x, ...))
? ?  tsum <- table(strsplit(tolower(z), "\\W"))
? ?  tsum
}

x <- "It was the age of wisdom it was the age of foolishness it was the 
epoch of belief"
y <- "it was the epoch of incredulity it was the season of Light it was 
the season of Darkness"

fun(x, y)
z <- "It was the era of R"
fun(x, y, z)

Hope this helps,

Rui Barradas

Em 19-09-2012 20:08, mcelis escreveu:
______________________________________________
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.