'For loop in simple R function is spitting out null vector

I don't know why this is occurring, but I wrote a simple function and when I use a for loop within my function it keeps on spitting out a null vector.

power_vector_sample_size_sim = function(alpha){
  
  power_value_vector = vector(mode = "numeric")
  
    for(i in 1:10){  
    power_value_vector[i] = power_calc_simulation_by_samp(sample_size_1 = i, alpha_1 = alpha)
   } 
}

Here's the thing. The individual parts of the for loop work just fine and give me the desired result: a vector of length 10. That is if I just highlight the initialized variable and the for loop, the desired result comes about. But as soon as I try to wrap this up in a function then it goes null. I should add that above I have the argument alpha in the code, but when I was testing it I was using a numerical constant getting my desired results. I feel my scoping of the function is right, but something very small is stopping it from working. Thoughts?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source