Re: [R] Extract student ID that match certain criteria

2017-03-15 Thread roslinazairimah zakaria
gt;> I would like to select the student id where the third and fourth value >> represent the year they register data is eg. AA15..., AE14,... and I would >> also to select their cgpa value. >> >> Thank you. >> >> On Mon, Mar 13, 2017 at 2:26 PM, roslina

Re: [R] Extract student ID that match certain criteria

2017-03-15 Thread Rui Barradas
A15..., AE14,... and I would also to select their cgpa value. Thank you. On Mon, Mar 13, 2017 at 2:26 PM, roslinazairimah zakaria < roslina...@gmail.com> wrote: Thank you so much for your help. On Mon, Mar 13, 2017 at 1:52 PM, bioprogrammer <bioprogram...@gmail.com> wrote: Hi.

Re: [R] Extract student ID that match certain criteria

2017-03-15 Thread roslinazairimah zakaria
rimah zakaria < roslina...@gmail.com> wrote: > Thank you so much for your help. > > On Mon, Mar 13, 2017 at 1:52 PM, bioprogrammer <bioprogram...@gmail.com> > wrote: > >> Hi. >> >> I would use the "substr" function: >> >> https://stat.et

Re: [R] Extract student ID that match certain criteria

2017-03-13 Thread Jim Lemon
Hi Roslinazairimah, What you seem to want is fairly simple: dt<-c("AA14068","AA13194","AE11054","AA12251","AA13228", "AA13286","AA14090","AA13256","AA13260","AA13291", "AA14099","AA15071","AA13143","AA14012","AA14039", "AA15018","AA13234","AA13149","AA13282","AA13218")

Re: [R] Extract student ID that match certain criteria

2017-03-13 Thread Ulrik Stervbo
Hi Roslinazairimah, As Bert suggested, you should get acquainted with regular expressions. It can be confusing at times, but pays off in the long run. In your case, the pattern of "^[A-Z]{2}14.*" might work. Best, Ulrik On Mon, 13 Mar 2017 at 06:20 roslinazairimah zakaria

Re: [R] Extract student ID that match certain criteria

2017-03-12 Thread roslinazairimah zakaria
Another question, How do I extract ID based on the third and fourth letter: I have for example, AA14004, AB15035, CB14024, PA14009, PA14009 etc I would like to extract ID no. of AB14..., CB14..., PA14... On Mon, Mar 13, 2017 at 12:37 PM, roslinazairimah zakaria < roslina...@gmail.com> wrote:

Re: [R] Extract student ID that match certain criteria

2017-03-12 Thread roslinazairimah zakaria
Hi Bert, Thank you so much for your help. However I don't really sure what is the use of y values. Can we do without it? x <- as.character(FKASA$STUDENT_ID) y <- c(1,786) My.Data <- data.frame (x,y) My.Data[grep("^AA14", My.Data$x), ] I got the following data: x y 1 AA14068

Re: [R] Extract student ID that match certain criteria

2017-03-12 Thread Bert Gunter
1. Your code is incorrect. All entries are character strings and must be quoted. 2. See ?grep and note in particular (in the "Value" section): "grep(value = TRUE) returns a character vector containing the selected elements of x (after coercion, preserving names but no other attributes)." 3.

[R] Extract student ID that match certain criteria

2017-03-12 Thread roslinazairimah zakaria
Dear r-users, I have this list of student ID, dt <- c(AA14068, AA13194, AE11054, AA12251, AA13228, AA13286, AA14090, AA13256, AA13260, AA13291, AA14099, AA15071, AA13143, AA14012, AA14039, AA15018, AA13234, AA13149, AA13282, AA13218) and I would like to extract all student of ID AA14... only.