I'm trying to create a histogram from the following code, but my data keeps
adding the Num vector and plotting that.  My data in the CSV file is just
one vector.  Does anyone know why?

Thanks
Conrad


SPXdf = data.frame(read.csv(file = "SPX.csv", header = TRUE, sep = ",", dec
= ".", fill = TRUE))

Max = max(SPXdf[,2])
Min = min(SPXdf[,2])
Count = length(SPXdf[,2])
sig = sd(SPXdf[,2])

BinSize = (3.5*sig)/(Count^(1/3))
BinNum = (Max - Min)/(BinSize)
Bins = seq(Min,Max,by = BinSize)
Count2 = length(Bins)
Num = mat.or.vec(1,Count2)


for (i in 1:Count){

    for (j in 1:Count2){


        if ((SPXdf[i,2] < Bins[j]))
        {Num[j] = Num[j] + 1}
    }

}

barplot(Num,Bins, xlab = "SPXdf", ylab = "Frequency")

        [[alternative HTML version deleted]]

______________________________________________
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