[R] Information Frequency problem calculation
jim holtman
jholtman at gmail.com
Mon Oct 7 18:38:34 CEST 2013
does 'table' do the job for you?
> input <- read.table(text = "Name1 Name2 category
+
+ mauro francesco E234
+ luca giuseppe E5578
+ luca franco E5569
+ maria luca E4556", header = TRUE, as.is = TRUE)
> input
Name1 Name2 category
1 mauro francesco E234
2 luca giuseppe E5578
3 luca franco E5569
4 maria luca E4556
> table(input$Name1, input$Name2)
francesco franco giuseppe luca
luca 0 1 1 0
maria 0 0 0 1
mauro 1 0 0 0
>
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Mon, Oct 7, 2013 at 12:09 PM, jarod_v6 at libero.it <jarod_v6 at libero.it> wrote:
> 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