Hello, Or more simple, xtabs( ~ ATTRIBUTE + TRAIT, dd) Hope this helps, Rui Barradas ?s 19:27 de 14/03/2019, Ivan Krylov escreveu:> On Fri, 15 Mar 2019 03:06:28 +0800 > roslinazairimah zakaria <roslinaump at gmail.com> wrote: > >> how many of ATTRIBUTE related to TRAITS. > > The table() function can be used to count occurrences of each > combination of factor levels. Does extracting the two columns by > dd[,c('ATTRIBUTE','TRAIT')] and passing the result to table() help? >
Yes, it does. table(dd$ATTRIBUTE, dd$TRAIT) #or xtabs( ~ ATTRIBUTE + TRAIT, dd) Thank you so much Rui and Ivan. On Fri, Mar 15, 2019 at 5:51 AM Rui Barradas <ruipbarradas at sapo.pt> wrote:> Hello, > > Or more simple, > > xtabs( ~ ATTRIBUTE + TRAIT, dd) > > > Hope this helps, > > Rui Barradas > > ?s 19:27 de 14/03/2019, Ivan Krylov escreveu: > > On Fri, 15 Mar 2019 03:06:28 +0800 > > roslinazairimah zakaria <roslinaump at gmail.com> wrote: > > > >> how many of ATTRIBUTE related to TRAITS. > > > > The table() function can be used to count occurrences of each > > combination of factor levels. Does extracting the two columns by > > dd[,c('ATTRIBUTE','TRAIT')] and passing the result to table() help? > > >-- *Roslinazairimah Zakaria* *Tel: +609-5492370; Fax. No.+609-5492766* *Email: roslinazairimah at ump.edu.my <roslinazairimah at ump.edu.my>; roslinaump at gmail.com <roslinaump at gmail.com>* Faculty of Industrial Sciences & Technology University Malaysia Pahang Lebuhraya Tun Razak, 26300 Gambang, Pahang, Malaysia [[alternative HTML version deleted]]
Hi Rui and Ivan,
Yes both works well.
table(dd$ATTRIBUTE, dd$TRAIT) #or
xtabs( ~ ATTRIBUTE + TRAIT, dd)
I have another question,I also want to extract all the PCT_SCORE to draw
box plot. I have tried to draw box of PCT_SCORE for all attribute scores.
boxplot(dd$PCT_SCORE, ylim=c(0,100),
main="Cohort 2015:Distribution of Score % of all attributes",
xlab="Score(%) of all attribute",horizontal=TRUE,
cex.axis=0.8,cex.main=0.8, cex.lab=0.8, col="lightblue" )
However, I want to draw boxplot for each individual score of the
attributes. That is to extract data of the sub-attribute eg. COMMUNICATION,
CREATIVITY, ENTREPRENEURIAL SKILLS and etc.
Thank you.
On Fri, Mar 15, 2019 at 5:51 AM Rui Barradas <ruipbarradas at sapo.pt>
wrote:
> Hello,
>
> Or more simple,
>
> xtabs( ~ ATTRIBUTE + TRAIT, dd)
>
>
> Hope this helps,
>
> Rui Barradas
>
> ?s 19:27 de 14/03/2019, Ivan Krylov escreveu:
> > On Fri, 15 Mar 2019 03:06:28 +0800
> > roslinazairimah zakaria <roslinaump at gmail.com> wrote:
> >
> >> how many of ATTRIBUTE related to TRAITS.
> >
> > The table() function can be used to count occurrences of each
> > combination of factor levels. Does extracting the two columns by
> > dd[,c('ATTRIBUTE','TRAIT')] and passing the result to
table() help?
> >
>
--
*Roslinazairimah Zakaria*
*Tel: +609-5492370; Fax. No.+609-5492766*
*Email: roslinazairimah at ump.edu.my <roslinazairimah at ump.edu.my>;
roslinaump at gmail.com <roslinaump at gmail.com>*
Faculty of Industrial Sciences & Technology
University Malaysia Pahang
Lebuhraya Tun Razak, 26300 Gambang, Pahang, Malaysia
[[alternative HTML version deleted]]
? Fri, 15 Mar 2019 08:06:52 +0800 roslinazairimah zakaria <roslinaump at gmail.com> ?????:> I want to draw boxplot for each individual score of the > attributes.You mean, a box per every possible ATTRIBUTE value? This is easily doable with the bwplot() function from library(lattice). -- Best regards, Ivan
Hello,
Something like this?
old_par <- par(mar = par("mar") + c(5, 0, -2, 0))
boxplot(SCORE ~ ATTRIBUTE, dd, cex.axis = 0.6, las = 2)
par(old_par)
Hope this helps,
Rui Barradas
?s 00:06 de 15/03/2019, roslinazairimah zakaria
escreveu:> Hi Rui and Ivan,
> Yes both works well.
>
> table(dd$ATTRIBUTE, dd$TRAIT) #or
> xtabs( ~ ATTRIBUTE + TRAIT, dd)
>
> I have another question,I also want to extract all the PCT_SCORE to draw
> box plot. I have tried to draw box?of PCT_SCORE for all attribute scores.
>
> boxplot(dd$PCT_SCORE, ylim=c(0,100),
> ? ? ? ? main="Cohort 2015:Distribution of Score % of all
attributes",
> ? ? ? ? xlab="Score(%) of all attribute",horizontal=TRUE,
> cex.axis=0.8,cex.main=0.8, cex.lab=0.8, col="lightblue" )
>
> However, I want to draw boxplot for each individual score of the
> attributes. That is to extract data of the sub-attribute eg.
> COMMUNICATION, CREATIVITY, ENTREPRENEURIAL SKILLS and etc.
>
> Thank you.
>
>
>
> On Fri, Mar 15, 2019 at 5:51 AM Rui Barradas <ruipbarradas at sapo.pt
> <mailto:ruipbarradas at sapo.pt>> wrote:
>
> Hello,
>
> Or more simple,
>
> xtabs( ~ ATTRIBUTE + TRAIT, dd)
>
>
> Hope this helps,
>
> Rui Barradas
>
> ?s 19:27 de 14/03/2019, Ivan Krylov escreveu:
> > On Fri, 15 Mar 2019 03:06:28 +0800
> > roslinazairimah zakaria <roslinaump at gmail.com
> <mailto:roslinaump at gmail.com>> wrote:
> >
> >> how many of ATTRIBUTE related to TRAITS.
> >
> > The table() function can be used to count occurrences of each
> > combination of factor levels. Does extracting the two columns by
> > dd[,c('ATTRIBUTE','TRAIT')] and passing the
result to table() help?
> >
>
>
>
> --
> *Roslinazairimah Zakaria*
> *Tel: +609-5492370; Fax. No.+609-5492766*
> *Email: roslinazairimah at ump.edu.my <mailto:roslinazairimah at
ump.edu.my>;
> roslinaump at gmail.com <mailto:roslinaump at gmail.com>
> *
> Faculty of Industrial Sciences & Technology
> University Malaysia Pahang
> Lebuhraya Tun Razak, 26300 Gambang, Pahang, Malaysia