On Nov 16, 2010, at 12:13 PM, Mariana wrote:


Hi there:
I am a total beginner in R,

Time to read the Posting Guide. (Especially since Nabble appears to deficient in providing an introductory document, at least judging from the email behavior of some of its users.)

and I have a simple question:
I have a table with thousands of lines that represent locations, and two columns: latitude and longitude. I need to randomly sample 1000 lines. How
do I do it? I know the command "sample", but it samples elements
independently, not lines.

So use that vector as an index:

latlong.tbl[ sample(NROW(latlong.tbl), 1000) , ]

# should work for matrices or dataframes or table objects

If there is a better place for me to ask that type of question, please let
me know.
Thanks a lot,
Mariana (from Brazil)


--
David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to