R: Reset data frames

Summary: The output file format for the summary (dataFrame) .

This data frame dataFrame , summary (dataFrame) produces output that is easy to read only if the number of columns in the dataFrame is small.

Question:

How to create a conclusion that contains one fact at a time?

For example:

dataFrame <- data.frame(x=rnorm(100), y=rnorm(100), z=rnorm(100)); summary(dataFrame); 

gives:

  xyz Min. :-2.13427 Min. :-2.12077 Min. :-2.4453 1st Qu.:-0.53324 1st Qu.:-0.78915 1st Qu.:-0.4100 Median : 0.05675 Median :-0.22321 Median : 0.1356 Mean : 0.09102 Mean :-0.04939 Mean : 0.1306 3rd Qu.: 0.69685 3rd Qu.: 0.58358 3rd Qu.: 0.7847 Max. : 2.48204 Max. : 2.65971 Max. : 2.0504 

and the desired result will be:

  x Min. :-2.13427 1st Qu.:-0.53324 Median : 0.05675 Mean : 0.09102 3rd Qu.: 0.69685 Max. : 2.48204 y Min. :-2.13427 1st Qu.:-0.53324 Median : 0.05675 Mean : 0.09102 3rd Qu.: 0.69685 Max. : 2.48204 z Min. :-2.13427 1st Qu.:-0.53324 Median : 0.05675 Mean : 0.09102 3rd Qu.: 0.69685 Max. : 2.48204 
+7
source share
1 answer

You can use the lapply() function to apply the summary() function to each column, and then cbind() to display the data as a column.

  lapply(dataFrame,function(x) cbind(summary(x))) $x [,1] Min. -2.09200 1st Qu. -0.56240 Median 0.07069 Mean -0.04267 3rd Qu. 0.54060 Max. 2.07800 $y [,1] Min. -2.55200 1st Qu. -0.62190 Median -0.07336 Mean -0.06966 3rd Qu. 0.58540 Max. 2.07100 $z [,1] Min. -2.80800 1st Qu. -0.52890 Median -0.03279 Mean -0.06263 3rd Qu. 0.53730 Max. 2.88500 
+8
source

All Articles