I'm not sure is this correct, but maybe you are looking for something like
this:

test<-function(){
permuted.Qtot<-permn(data$Qtot)
n<-length(permuted.Qtot)
correlation<-rep(NA,n)
for(i in 1:n){
correlation[i]<-cor(data$Itot,permuted.Qtot[[i]])}
p<-sum(correlation>=cor(data$Qtot,data$Itot))/n
print(paste("P-value:", round(p,5)),quote=F)
}
test()

-- 
Miłego dnia

	[[alternative HTML version deleted]]

