Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201943

series plots for various cases by considering multiple variables from multiple tables

$
0
0

I'm trying to generate all possible number of plots from two different data frames (df1 anf df2) based on their individual cases (rows) using ggplotpreferably with Loop/facet_wrap/facet_grid. But I need some clues specifically on using multiple variables for facet_. I tried grid.arrange which works for only one type of category in df1 as the following cases 1

I have plenty of data where the category in df1 and items in df2 have multiple groups (e.g., items & category). My aim is to plot for each possibilities based on category and items from df1 and df2 considering multiple groups. For example, from items I may choose "net"or "web" or both and fromcategoryI can select only "OM"or/and "NH" etc. 2

OR series of

3

A hint/solution would be appreciated. Following are the sample df1 and df2.

df1 <- structure(list(W = c(15550L, 13450L, 12300L, 11590L, 10516L, 
10201L, 9050L, 8025L, 29550L, 23450L, 21590L, 20270L, 19516L, 
19201L, 19050L, 18025L, 1550L, 1450L, 1290L, 1170L, 951L, 801L, 
750L, 625L, 555L, 425L), X = c(1000L, 2000L, 2000L, 2000L, 4000L, 
4000L, 6000L, 6000L, 1500L, 2500L, 2500L, 2500L, 4500L, 4500L, 
6700L, 6700L, 900L, 1200L, 1200L, 1280L, 1346L, 1346L, 1420L, 
1420L, 1490L, 1550L), Y = c(90L, 90L, 80L, 70L, 70L, 60L, 60L, 
50L, 110L, 110L, 100L, 90L, 90L, 80L, 80L, 70L, 130L, 130L, 120L, 
120L, 120L, 110L, 110L, 100L, 100L, 100L), items = structure(c(3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("eml", "net", 
"web"), class = "factor")), class = "data.frame", row.names = c(NA, 
-26L))
df2 <-  structure(list(a_max = c(23.6, 25.6, 27.9, 19.6, 27.76, 29.53, 
16.99, 17.68, 21, 18.2, 19.26, 16.1, 35.72, 21.43, 27.56, 18.88, 
29.17, 28.82, 26.89, 17.26), a_min = c(17.6, 19.3, 20.4, 11.5, 
25.18, 26.44, 13.72, 13.24, 18, 15.2, 16.08, 11.3, 31.76, 16.84, 
21.68, 12.64, 26.26, 25.76, 22.12, 12.58), b_max = c(55.83, 48.08, 
56.5, 48.42, 50.9, 70.9, 45.74, 66.6, 54.85, 62.09, 49.29, 84.36, 
44.83, 47.37, 45.87, 54.33, 62.5, 52.9, 49.25, 65.39), b_min = c(50.64, 
43.64, 50.5, 39.36, 48.8, 68.8, 43.52, 60.6, 49.3, 57.02, 43.32, 
73.38, 41.74, 44.16, 42.06, 47.34, 60.1, 49.6, 44.9, 56.72), 
    category = structure(c(19L, 14L, 4L, 9L, 18L, 13L, 3L, 8L, 
    20L, 15L, 5L, 10L, 16L, 11L, 1L, 6L, 17L, 12L, 2L, 7L), .Label = c("A > BC", 
    "A > CW", "A > NH", "A > NJ", "A > OM", "S > BC", "S > CW", 
    "S > NH", "S > NJ", "S > OM", "T > BC", "T > CW", "T > NH", 
    "T > NJ", "T > OM", "V > BC", "V > CW", "V > NH", "V > NJ", 
    "V > OM"), class = "factor")), class = "data.frame", row.names = c(NA, 
-20L))

Viewing all articles
Browse latest Browse all 201943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>