Skip to content
Prev 317839 / 398506 Next

addition in the initial question [SCL:4]

Hi Elisa,

I think your question is regarding "why the third column (Frequency) is absent??
aggregate(row.names(dat1)~class,dat1,function(x) x)[1]? #Here, the first two class are not there, because it was not in the dataset. (0.1<x<=0.2) was not there and (0<x<=0.1) is also not present, eventhough 0 was present, but our class should be >0.
#?????? class
#1 0.2<x<=0.3
#2 0.3<x<=0.4
#3 0.4<x<=0.5
#4 0.5<x<=0.6
#5 0.6<x<=0.7
#6 0.7<x<=0.8
#7 0.8<x<=0.9
#8?? 0.9<x<=1


vecNew1<-as.data.frame(table(vecNew))
? # ??? vecNew Freq
#1??? 0<x<=0.1??? 0
#2? 0.1<x<=0.2??? 0
#3? 0.2<x<=0.3?? 15
#4? 0.3<x<=0.4?? 24
#5? 0.4<x<=0.5?? 27
#6? 0.5<x<=0.6?? 20
#7? 0.6<x<=0.7?? 15
#8? 0.7<x<=0.8?? 12
#9? 0.8<x<=0.9??? 9
#10?? 0.9<x<=1??? 1


res1<- data.frame(aggregate(row.names(dat1)~class,dat1,function(x) x),Frequency=as.data.frame(table(vecNew))[-c(1,2),2]) #first two classes were not present
names(vecNew1)<-names(res1)[c(1,3)]
library(plyr)
join(vecNew1,res1,by=c("class","Frequency"),type="full")
?# ????? class Frequency
#1??? 0<x<=0.1???????? 0
#2? 0.1<x<=0.2???????? 0
#3? 0.2<x<=0.3??????? 15
#4? 0.3<x<=0.4??????? 24
#5? 0.4<x<=0.5??????? 27
#6? 0.5<x<=0.6??????? 20
#7? 0.6<x<=0.7??????? 15
#8? 0.7<x<=0.8??????? 12
#9? 0.8<x<=0.9???????? 9
#10?? 0.9<x<=1???????? 1
?# ?????????????????????????????????????????????????????????????????????????????????????????????? row.names.dat1.
#1?????????????????????????????????????????????????????????????????????????????????????????????????????????? NULL
#2?????????????????????????????????????????????????????????????????????????????????????????????????????????? NULL
#3???????????????????????????????????????????????? 2, 10, 14, 32, 34, 36, 70, 85, 95, 99, 101, 103, 104, 113, 120
#4???????????? 8, 45, 46, 51, 54, 57, 58, 60, 61, 63, 67, 78, 86, 87, 88, 91, 92, 96, 97, 102, 110, 114, 115, 124
#5? 11, 12, 15, 20, 27, 30, 33, 35, 48, 53, 55, 59, 68, 69, 71, 74, 77, 81, 82, 83, 89, 90, 93, 98, 105, 107, 121
#6??????????????????????????????? 4, 13, 17, 18, 21, 23, 24, 25, 28, 29, 31, 37, 43, 47, 62, 64, 65, 94, 100, 111
#7???????????????????????????????????????????????? 3, 16, 38, 41, 42, 50, 52, 72, 80, 84, 106, 108, 117, 118, 122
#8????????????????????????????????????????????????????????????????? 5, 6, 7, 9, 39, 40, 73, 76, 79, 109, 112, 116
#9??????????????????????????????????????????????????????????????????????????? 19, 22, 26, 44, 49, 56, 66, 75, 123
#10?????????????????????????????????????????????????????????????????????????????????????????????????????????? 119

A.K.