when i write mean it worked
mean(b1temp[1, ])
but for standard deviation, it returns NA
sd(b1temp[1, ])
NA
SO, I modified the function but still returns NA
sd(b1temp[1, ], na.rm=FALSE)
NA
my dataset contains only a row. Is this an issue?
when i write mean it worked
mean(b1temp[1, ])
but for standard deviation, it returns NA
sd(b1temp[1, ])
NA
SO, I modified the function but still returns NA
sd(b1temp[1, ], na.rm=FALSE)
NA
my dataset contains only a row. Is this an issue?
 
    
     
    
    The problem here is incorrect subsetting of data.frame as in effect when you execute b1temp[1, ] you get only 1 number where the standard deviation is not defined. Which is the reason of getting NA.
By default data.frame data are organized by column, not by row. So to apply sd to your data you should use subsetting for the columns bitemp[, 1].
Please see the code and simulation below:
b1temp <- data.frame(x = 1:10)
b1temp[1, ]
# [1] 1
mean(b1temp[1, ])
# [1] 1
sd(b1temp[1, ])
# [1] NA
sd(1)
# [1] NA
b1temp[1, ]
# [1]  1  2  3  4  5  6  7  8  9 10
sd(b1temp[, 1])
# [1] 3.02765
