Hi, i have a dataframe containing some values. for eg:- MyDataFrame<- Name Age Place ------- ------ ----------- Aby 12 USA Raj 25 UK Romi 32 ENG Amy 31 IND My requirement what is, i have a search key word[it should search from all the columns], that i need to find out from this dataframe. If search keyword found , it should return that particular row and column number. For eg:- My search keyword is "ENG". After searching, it should return particular row & column number. Here it is " MyDataFrame[3,3] " Can anyone help me please ? - Antony. -- View this message in context: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722.html Sent from the R help mailing list archive at Nabble.com.
Searching from Dataframe.
6 messages · David Winsemius, Rantony, Bert Gunter
On Sep 11, 2012, at 12:11 AM, Rantony wrote:
Hi, i have a dataframe containing some values. for eg:- MyDataFrame<- Name Age Place ------- ------ ----------- Aby 12 USA Raj 25 UK Romi 32 ENG Amy 31 IND My requirement what is, i have a search key word[it should search from all the columns], that i need to find out from this dataframe. If search keyword found , it should return that particular row and column number. For eg:- My search keyword is "ENG". After searching, it should return particular row & column number. Here it is " MyDataFrame[3,3] "
which(MyDataFrame=="ENG", arr.ind=TRUE)
row col [1,] 3 3 You can certainly massage those values in any paste()y expression you choose. -- David Winsemius, MD Alameda, CA, USA
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120911/682552cf/attachment.pl>
And how to get the vector from a list if the list item found inside ?
for eg:- MyList<- c("US","UK","UAE")
Here i want to check a list item UAE which is in 3rd row.
How i will get that row position ?
- Thanks in advance
Antony
--
View this message in context: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642744.html
Sent from the R help mailing list archive at Nabble.com.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120911/2ea4e9e8/attachment.pl>
Have you read "An Introduction to R" (ships with every copy of R) where these sorts of questions are answered? There are other R tutorials on the web also, if you look. -- Bert
On Tue, Sep 11, 2012 at 3:59 AM, Rantony <antony.akkara at ge.com> wrote:
And how to get the vector from a list if the list item found inside ?
for eg:- MyList<- c("US","UK","UAE")
Here i want to check a list item UAE which is in 3rd row.
How i will get that row position ?
- Thanks in advance
Antony
--
View this message in context: http://r.789695.n4.nabble.com/Searching-from-Dataframe-tp4642722p4642744.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm