Reputation: 541
I have to make a histogram of the given text file hw4aldData containing:
170 172 173 174 174 175 176 177 180 180 180 180 180 181 181 182 182 182 182 184 184 185 186 188 0.84 1.31 1.42 1.03 1.07 1.08 1.04 1.80 1.45 1.60 1.61 2.13 2.15 0.84 1.43 0.90 1.81 1.94 2.68 1.49 2.52 3.00 1.87 3.08
But each data set shows up as a different column in R like:
v1 v2 v3 v4 v5
TankTemp 170 172 173 174
EffRat 0.84 1.31 1.42 1.03
I know how to separate columns to make a histogram:
hist(hw4aldData$v1)
but I'm not sure how to make a histogram using all the data points in this form.
P.s. I will also need to know how find the average of the data set. Any help is welcome, thanks.
Upvotes: 1
Views: 597
Reputation: 13570
You only need to transpose your data frame:
hist(t(df))
mean(t(df)) # or rowMeans(df)
[1] 0.752449
Upvotes: 2