[R] Information Frequency problem calculation

arun smartpink111 at yahoo.com
Mon Oct 7 18:45:12 CEST 2013


Hi,
Not sure what your expected output would be:
a<- read.table(text="Name1 Name2 category
mauro francesco E234
luca  giuseppe  E5578
luca  franco  E5569
maria luca E4556",sep="",header=TRUE,stringsAsFactors=FALSE)
sapply(seq_len(nrow(a)),function(i) sum(a[,2] %in% a[i,1]))
#[1] 0 1 1 0


A.K.





----- Original Message -----
From: "jarod_v6 at libero.it" <jarod_v6 at libero.it>
To: r-help at r-project.org
Cc: 
Sent: Monday, October 7, 2013 12:09 PM
Subject: [R] Information Frequency problem calculation

Dear All,

I Have a dataframe like that:

Name1 Name2 category

mauro francesco E234
luca   giuseppe  E5578
luca   franco  E5569
maria luca E4556
...
I would like to calculate the frequency of many time in my data I found  in 
the list name:

a<-read.table("pippo.csv",header=T,sep="\t")
name1<-as.character(a[,1])
name2<-as.character(a[,2])
category<-as.character(a[,3])

for(i in 1:lenght(name1)){
re <-which(name1 == name2)

}

So how can create a table of frequncy of many times I found a name in column 
one respect to the second ?
Thanks in advance for your help!
M.

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




More information about the R-help mailing list