x=iris[,1:4]
xx=matrix(ncol=4,nrow=6)
i=1
while(i<=4){
xx[1,i]=paste0("Min. :",min(x[,i]))
xx[2,i]=paste0("1st Qu.:",quantile(x[,i])[2])
xx[3,i]=paste0("Median :",median(x[,i]))
xx[4,i]=paste0("Mean :",mean(x[,i]))
xx[5,i]=paste0("3rd Qu.:",quantile(x[,i])[4])
xx[6,i]=paste0("Max. :",max(x[,i]))
i=i+1
dimnames(xx)=list(c("Min", "1st Qu", "median","mean","3rd Qu","Max"), names(x))
dimnames(xx)[[1]]=rep("",nrow(xx))
options=(digits=4)
}
print(xx)
This result is
Sepal.Length Sepal.Width Petal.Length Petal.Width
"Min. :4.3" "Min. :2" "Min. :1" "Min. :0.1"
"1st Qu.:5.1" "1st Qu.:2.8" "1st Qu.:1.6" "1st Qu.:0.3"
"Median :5.8" "Median :3" "Median :4.35" "Median :1.3"
"Mean :5.84333333333333" "Mean :3.05733333333333" "Mean :3.758" "Mean :1.19933333333333"
"3rd Qu.:6.4" "3rd Qu.:3.3" "3rd Qu.:5.1" "3rd Qu.:1.8"
"Max. :7.9" "Max. :4.4" "Max. :6.9" "Max. :2.5"
but i want to make
Sepal.Length Sepal.Width Petal.Length Petal.Width
Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100
1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300
Median :5.800 Median :3.000 Median :4.350 Median :1.300
Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
like this.
How can i make this table?
- without ""
- not 5.843333333 but 5.843
It's too difficult. How can i convert 5.84333 to 5.843?