[R] sampling and testing
Grant Humphries
ftgrh at uaf.edu
Wed Nov 12 20:57:25 CET 2008
Hello everyone,
I have a dataset in the following format:
col1 col2
# #
# #
# #
# #
# #
# #
What I want to do is:
loop a random sample 10 times, and for each time it is sampled I want to
run a correlation between both columns. What I have so far is this:
>feb <- read.csv("corr.csv") # where the dataset is for February
>attach(feb)
>for(i in 1:10){
> feb[sample(nrow(feb),###),] # "###" represents the number of rows
> print(cor(col1,col2),)
>}
all this is doing for me is doing 10 correlations between all 10 samples
at the same time. What I was thinking was to do something like:
- append a sample of the data: sample1 <- sample()
- do the correlation cor()
- remove that sample using rm(sample1) function
- repeat 9 more times
any help is greatly appreciated
Cheers,
Grant Humphries
University of Alaska Fairbanks
-EWHALE-lab Irving I Rm 419
902 Koyukuk Dr.
Fairbanks, Alaska
99775
907-474-7959
ftgrh at uaf.edu
More information about the R-help
mailing list