Hello everyone. In matlabĀ (again) there is a fucntion find that returns you the indexes where the condition in find was met. I want the same functionality in R i.e find(Mydata>2) to return all the indexes where the condition is met. Do you know something like that? Also when I try to search in google using for example the word R inside the search lemma I get very few results as the R confuses the search engine. When I was looking something in matlab ofcourse it was easier to get results as the search engine performs better. What are your tricks when you want to find some function that provides some functionality? I would like to thank you for your help Regards Alex [[alternative HTML version deleted]]
Hi again! The "Introduction to R" or other documentation might help you to get started. And you should REALLY read the posting guide and provide a reproducible example. In this case, some sample data corresponding to the type of objects you have, plus the result you expect would be enough (I guess). From you precedent posts, I would think you're looking for something similar to this: df <- data.frame(let=rep(LETTERS[1:5],4), num=rnorm(20)) df[df$let=="A", ] df[df$num>0, ] By the way, if you just want the indexes, that will do: which(df$num>0) Ivan Le 11/17/2010 15:35, Alaios a ?crit :> Hello everyone. > In matlab (again) there is a fucntion find that returns you the indexes where the condition in find was met. I want the same functionality in R i.e find(Mydata>2) to return all the indexes where the condition is met. Do you know something like that? > > Also when I try to search in google using for example the word R inside the search lemma I get very few results as the R confuses the search engine. When I was looking something in matlab ofcourse it was easier to get results as the search engine performs better. > What are your tricks when you want to find some function that provides some functionality? > > I would like to thank you for your help > Regards > Alex > > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > 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.-- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. S?ugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calandra at uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php
Hi Alex, This ought to do what you are after. For searching, I found the most helpful thing to be thinking about what I was really after---this helps with generating several key words to look for, which is more likely to turn up results. I also included some functions/packages to help with R specific searching below. Cheers, Josh ####################### ## pseudo-random data with mean = 0 x <- rnorm(20) ## Logical, vectorized test so it compares each element ## of x and determines whether it is greater than 2 or not ## returns a vector of TRUE/FALSE x > 2 ## When indexing in R, if you pass a TRUE/FALSE vector of equal ## length, it will select TRUE elements and exclude the FALSE ## so your solution is: x[x > 2] ## or if you just want the indices, not the actual values which(x > 2) ## for documentation see ?Comparison #logical comparison/test ?logical # TRUE/FALSE class ?which # which function ?"[" # indexing ############################################ ## You can use this built in search function RSiteSearch("your key word(s)") ## If you think you almost know the name, apropos looks up objects ## in R that include your search string apropos("find") ## There is a package to help with searching: install.packages("sos") library(sos) findFn("words for desired function") On Wed, Nov 17, 2010 at 6:35 AM, Alaios <alaios at yahoo.com> wrote:> Hello everyone. > In matlab? (again) there is a fucntion find that returns you the indexes where the condition in find was met. I want the same functionality in R i.e find(Mydata>2) to return all the indexes where the condition is met. Do you know something like that? > > Also when I try to search in google using for example the word R inside the search lemma I get very few results as the R confuses the search engine. When I was looking something in matlab ofcourse it was easier to get results as the search engine performs better. > What are your tricks when you want to find some function that provides some functionality? > > I would like to thank you for your help > Regards > Alex > > > > > ? ? ? ?[[alternative HTML version deleted]] > > > ______________________________________________ > 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. > >-- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
Alaios <alaios at yahoo.com> writes:> Also when I try to search in google using for example the word R inside the search lemma I get very few results as the R confuses the search engine. When I was looking something in matlab ofcourse it was easier to get results as the search engine performs better. > What are your tricks when you want to find some function that provides some functionality?To search R-specific sites the best place to go is this one: http://www.rseek.org/ Cheers, Georg