[R] Find in R and R books
Joshua Wiley
jwiley.psych at gmail.com
Wed Nov 17 16:07:43 CET 2010
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/
More information about the R-help
mailing list