Re: [R] Finding unique terms

2018-10-16 Thread roslinazairimah zakaria
Yes you are right, I want the sum. I wll change the formula accordingly. On Fri, Oct 12, 2018 at 10:36 AM Jeff Newmiller wrote: > You said "add up"... so you did not mean to say that? Denes computed the > mean... > > On October 11, 2018 3:56:23 PM PDT, roslinazairimah zakaria < > roslina...@gmai

Re: [R] Finding unique terms

2018-10-15 Thread Bert Gunter
Here is a base R solution: "dat" is the data frame as in Robert's solution. > aggregate(dat[,3:6], by= dat[1], FUN = sum, na.rm = TRUE) STUDENT_ID PO1M PO1T PO2M PO2T 1AA15285 287.80 350 37 50 2AA15286 240.45 330 41 50 Cheers, Bert Bert Gunter "The trouble with having an

Re: [R] Finding unique terms

2018-10-15 Thread Robert Baer
On 10/11/2018 5:12 PM, roslinazairimah zakaria wrote: Dear r-users, I have this data: structure(list(STUDENT_ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("AA15285", "AA15286"), class = "factor"), COURSE_CODE = structure(c(1L, 2L, 5L, 6L, 7L, 8L, 2L, 3L,

Re: [R] Finding unique terms

2018-10-15 Thread Robert Baer
Dear r-users, I have this data: structure(list(STUDENT_ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("AA15285", "AA15286"), class = "factor"), COURSE_CODE = structure(c(1L, 2L, 5L, 6L, 7L, 8L, 2L, 3L, 4L, 5L, 6L), .Label = c("BAA1113", "BAA1322", "BAA2113"

Re: [R] Finding unique terms

2018-10-12 Thread Tóth Dénes
On 10/12/2018 08:58 AM, Dénes Tóth wrote: On 10/12/2018 04:36 AM, Jeff Newmiller wrote: You said "add up"... so you did not mean to say that? Denes computed the mean... Nice catch, Jeff. Of course I wanted to use 'sum' instead of 'mean'. Oh, and one more note: If you have NAs in your co

Re: [R] Finding unique terms

2018-10-11 Thread Dénes Tóth
On 10/12/2018 04:36 AM, Jeff Newmiller wrote: You said "add up"... so you did not mean to say that? Denes computed the mean... Nice catch, Jeff. Of course I wanted to use 'sum' instead of 'mean'. On October 11, 2018 3:56:23 PM PDT, roslinazairimah zakaria wrote: Hi Denes, It works pe

Re: [R] Finding unique terms

2018-10-11 Thread Jim Lemon
Yes, I thought that as well and had worked out this but didn't send it: add_Pscores<-function(x) { return(sum(unlist(x),na.rm=TRUE)) } by(rzdf[,c("PO1M", "PO1T", "PO2M", "PO2T")],rzdf$STUDENT_ID,FUN=add_Pscores) rzdf$STUDENT_ID: AA15285 [1] 724.8 ---

Re: [R] Finding unique terms

2018-10-11 Thread Jeff Newmiller
You said "add up"... so you did not mean to say that? Denes computed the mean... On October 11, 2018 3:56:23 PM PDT, roslinazairimah zakaria wrote: >Hi Denes, > >It works perfectly as I want! > >Thanks a lot. > >On Fri, Oct 12, 2018 at 6:29 AM Dénes Tóth >wrote: > >> >> >> On 10/12/2018 12:12 A

Re: [R] Finding unique terms

2018-10-11 Thread roslinazairimah zakaria
Hi Denes, It works perfectly as I want! Thanks a lot. On Fri, Oct 12, 2018 at 6:29 AM Dénes Tóth wrote: > > > On 10/12/2018 12:12 AM, roslinazairimah zakaria wrote: > > Dear r-users, > > > > I have this data: > > > > structure(list(STUDENT_ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, > > 2L, 2L, 2

Re: [R] Finding unique terms

2018-10-11 Thread Dénes Tóth
On 10/12/2018 12:12 AM, roslinazairimah zakaria wrote: Dear r-users, I have this data: structure(list(STUDENT_ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("AA15285", "AA15286"), class = "factor"), COURSE_CODE = structure(c(1L, 2L, 5L, 6L, 7L, 8L, 2L, 3L,

[R] Finding unique terms

2018-10-11 Thread roslinazairimah zakaria
Dear r-users, I have this data: structure(list(STUDENT_ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("AA15285", "AA15286"), class = "factor"), COURSE_CODE = structure(c(1L, 2L, 5L, 6L, 7L, 8L, 2L, 3L, 4L, 5L, 6L), .Label = c("BAA1113", "BAA1322", "BAA2113",