0

I would like to reproduce this presentation: enter image description here

This is my code but I get the text of the columns aligned on the left. Do you have an idea how to align it to the right?

cat("===========================================================\n \n") 
cat("\n Statistiques des variables vitesse_10km vitesse_21km \n") 
cat("----------------------------------------------------------- \n \n") 
cat("\t ", "\t ", "vitesse_10km", "\t ", "vitesse_21km", "\n")
cat("Moyenne   ", "\t ", mean10,  "\t ", "\t ", mean21, "\n")
cat("Ecart-type   ", "\t ", sd10, "\t ","\t ", sd21, "\n")
cat("Minimum  ", "\t ", min10, "\t ", "\t ", min21, "\n")
cat("Maximum  ", "\t ", max10, "\t ", max21, "\n")
cat("===========================================================\n \n")
LC-datascientist
  • 1,960
  • 1
  • 18
  • 32
Ralitza
  • 1
  • 1

1 Answers1

0

You can use sprintf to format numbers (or strings) with a fixed size filled up with leading spaces. Example:

> cat(sprintf("++% 8.2f++", 20))
++   20.00++
cdalitz
  • 1,019
  • 1
  • 6
  • 7