r: Plotting each column against each column

后端 未结 2 1750
粉色の甜心
粉色の甜心 2021-01-12 17:03

I have a dataframe (\"data\") with 7 columns (2 Factor, 5 num). The first column is containing the names of 7 different countries and in the following columns I have collect

相关标签:
2条回答
  • 2021-01-12 17:28

    I've alway thought that splom function in package 'lattice' was quite useful for this sort of exploratory analysis. This is obviously not a great example since it obscures the group memberships but it shows the combinations of points and a non-parametric regression line in the "pairs" format:

    png()
        print( splom(~iris[1:4], groups = Species, data = iris,
              panel = function(x, y, i, j, ...) {
              panel.points(x,y, ...)
              panel.loess(x,y, ...)
          })); dev.off()
    

    0 讨论(0)
  • 2021-01-12 17:32

    You can use pairs() directly from R. Note that dt represents your dataset.

    pairs(dt)
    

    dt <- structure(list(Country = structure(c(5L, 4L, 7L, 2L, 1L, 6L, 
    3L), .Label = c("Brazil", "Chile", "China", "France", "Germany", 
    "India", "Netherlands"), class = "factor"), GDP = c(0.46, 0.57, 
    0.75, 0.56, 0.28, 0.88, 1), Population = c(0.18, 0.09, 0.54, 
    0.01, 0.02, 0.17, 0.84), Birth.rate = c(87.21, 18.34, 63.91, 
    14.21, 5.38, 51.19, 209.26), Income = c(43.89, 18.23, 63.91, 
    12.3, 0.1, 14.61, 160.82), Savings = c(43.32, 0.11, 0, 1.91, 
    5.29, 36.58, 50.38), Continent = structure(c(2L, 2L, 2L, 3L, 
    3L, 1L, 1L), .Label = c("Asia", "Europe", "South America"), class =      "factor")), .Names = c("Country",  
    "GDP", "Population", "Birth.rate", "Income", "Savings", "Continent"
    ), class = "data.frame", row.names = c(NA, -7L))
    
    0 讨论(0)
提交回复
热议问题