Re: [R] plot empty when drawing from custom function
FAQ 7.16 Bert On Mar 28, 2017 1:20 AM, "Luigi Marongiu"wrote: Dear all, I have set a function to draw some data using lattice; the drawing works when I use lattice on its own, but if I put it into my custom function, the final plot is empty, yet the terminal reports RStudioGD 1 as normal. What am I missing? regards, Luigi >>> cluster <- c(rep("A", 90), rep("B", 100)) sample <- c( rep(c("cow-01", "cow-02", "cow-03", "cow-04", "cow-05", "cow-06", "cow-07", "cow-08", "cow-09", "cow-10", "cow-11", "cow-12", "cow-13", "cow-14", "cow-15", "cow-16", "cow-17", "blank"), 5), rep(c("cow-26", "cow-35", "cow-36", "cow-37", "cow-38", "cow-39", "cow-40", "cow-41", "cow-42", "cow-43", "cow-44", "cow-45", "cow-46", "cow-47", "cow-48", "cow-49", "cow-50", "cow-51", "cow-59", "blank"), 5) ) type <- c( rep(c("negative", "negative", "negative", "negative", "negative", "negative", "negative", "negative", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "blank"), 5), rep(c("negative", "positive", "negative", "negative", "negative", "negative", "negative", "negative", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "blank"), 5) ) target <- c( c(rep("a", 18), rep("b", 18), rep("c", 18), rep("d", 18), rep("e", 18)), c(rep("a", 20), rep("b", 20), rep("c", 20), rep("d", 20), rep("e", 20)) ) average <- c(88.5, 49, 41, 33, 35, 45, 95, 30, 41, 64, 22, 29, 59, 71, 128, 39, 42, 47, 86, 100, 69, 44, 53, 66, 66, 71, 161, 69, 22.5, 30, 67, 99, 129, 94, 49, 33, 28, 31, 26, 23, 30, 41, 35, 23, 38, 43, 15, 21, 45, 51.5, 34, 26, 43, 32.5, 59, 58.5, 61, 62.5, 58, 59.5, 60.5, 60, 64, 110, 55, 66, 197, 83.5, 155, 76, 125, 90, 73, 84, 95.5, 62, 82, 138, 103.5, 57, 138, 149.5, 57, 54, 245.5, 191, 131, 96, 176, 45, 76, 33, 37, 51, 44, 50, 54, 66, 49, 90, 66.5, 42.5, 67, 56, 54, 50, 45, 99, 50, 51.5, 212, 40, 68, 121, 80, 57, 81.5, 128, 77, 119.5, 126, 184, 101, 103, 88, 100, 140, 186, 297, 32, 184, 36, 45, 45, 44, 86, 65, 61, 76, 62, 136, 84, 80, 56, 109, 116, 54, 59, 79, 34, 74.5, 54, 49, 55, 56, 59, 56, 56, 57, 67, 65, 63, 52, 58, 59, 56, 54, 66, 92, 87, 59, 33, 58, 51, 54, 52, 47, 45, 42, 52, 57, 79, 42, 45.5, 47, 47, 36, 50, 53, 49 ) stdev <- c(17.85, 6.31, 3.42, 1.04, 0.51, 6.04, 38.43, 2.78, 5.55, 26.72, 1.83, 9.92, 4.59, 19, 7.96, 7.5, 1.06, 9.66, 75.94, 36.79, 50.45, 9.79, 1.55, 11.42, 64.12, 0.79, 15.14, 16.15, 8.12, 4.04, 92.57, 35.35, 42.28, 52.96, 7.06, 4.97, 1.15, 4.77, 6.59, 7.27, 0.75, 4.25, 9, 0.1, 1.14, 4.17, 6.73, 3.81, 3.27, 97.44, 9.74, 0.45, 8.14, 5.91, 13.1, 98.22, 8.92, 72.62, 70.26, 59.46, 29.89, 56.35, 91.25, 49.94, 20.65, 62.04, 95.13, 35.89, 99.64, 29.44, 33.12, 45.91, 96.69, 9.05, 38.56, 3.09, 0.6, 8.69, 16.95, 74.03, 84.05, 39.87, 15.52, 27.92, 35.72, 80.26, 71.93, 66.73, 87.8, 5.43, 98.3, 7.41, 9.86, 63.64, 0.36, 5.84, 1.58, 20.1, 4.21, 82.12, 19.29, 9.02, 22.12, 54.08, 74.95, 3.24, 9.67, 67.98, 9.92, 40.69, 6.24, 8.76, 74.25, 46.34, 25.69, 90.63, 83.71, 73.53, 57.88, 15.84, 82.07, 67.45, 47.39, 98.77, 75.1, 64.9, 3.71, 87.44, 61.06, 4.77, 57.54, 7.68, 4.54, 6.15, 3.32, 60.39, 33.78, 66.22, 18.67, 76.53, 63.54, 47.06, 38.47, 88.15, 18.25, 4.26, 67.19, 88.87, 29.65, 7.33, 68.18, 28.03, 6.91, 77.82, 22.23, 73.23, 95.21, 27.11, 37.01, 34.88, 28.15, 11.27, 15.67, 96.08, 89.52, 28.6, 8.22, 23.55, 59.2, 36.38, 41.38, 0.4, 56.82, 32.35, 20.6, 18.13, 8.15, 1.08, 9.85, 1.07, 37.75, 97.6, 7.16, 8.51, 4.42, 0.15, 1.28, 7.42, 71.15, 9.39) ll <- c(70.65, 42.69, 37.58, 31.96, 34.49, 38.96, 56.57, 27.22, 35.45, 37.28, 20.17, 19.08, 54.41, 52, 120.04, 31.5, 40.94, 37.34, 10.06, 63.21, 18.55, 34.21, 51.45, 54.58, 1.88, 70.21, 145.86, 52.85, 14.38, 25.96, -25.57, 63.65, 86.72, 41.04, 41.94, 28.03, 26.85, 26.23, 19.41, 15.73, 29.25, 36.75, 26, 22.9, 36.86, 38.83, 8.27, 17.19, 41.73, -45.94, 24.26, 25.55, 34.86, 26.59, 45.9, -39.72, 52.08, -10.12, -12.26, 0.0391, 30.61, 3.65, -27.25, 60.06, 34.35, 3.96, 101.87, 47.61, 55.36, 46.56, 91.88, 44.09, -23.69, 74.95, 56.94, 58.91, 81.4, 129.31, 86.55, -17.03, 53.95, 109.63, 41.48, 26.08, 209.78, 110.74, 59.07, 29.27, 88.2, 39.57, -22.3, 25.59, 27.14, -12.64, 43.64, 44.16, 52.42, 45.9, 44.79, 7.88, 47.21, 33.48, 44.88, 1.92, -20.95, 46.76, 35.33, 31.02, 40.08, 10.81, 205.76, 31.24, -6.25, 74.66, 54.31, -33.63, -2.20, 54.47, 19.12, 103.66, 43.93, 116.55, 53.61, 4.23, 12.9, 35.1, 136.29, 98.56, 235.94, 27.23, 126.46, 28.32, 40.46, 38.85, 40.68, 25.61, 31.22, -5.22, 57.33, -14.53, 72.46, 36.94, 41.53, -32.15, 90.75,
Re: [R] plot empty when drawing from custom function
Hi, Luigi, you are probably missing a call to print() around the call to the latticeExtra plotting function useOuterStrips() you use inside your function printer(). Hth -- Gerrit - Dr. Gerrit Eichner Mathematical Institute, Room 212 gerrit.eich...@math.uni-giessen.de Justus-Liebig-University Giessen Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany Fax: +49-(0)641-99-32109http://www.uni-giessen.de/eichner - Am 28.03.2017 um 10:19 schrieb Luigi Marongiu: Dear all, I have set a function to draw some data using lattice; the drawing works when I use lattice on its own, but if I put it into my custom function, the final plot is empty, yet the terminal reports RStudioGD 1 as normal. What am I missing? regards, Luigi cluster <- c(rep("A", 90), rep("B", 100)) sample <- c( rep(c("cow-01", "cow-02", "cow-03", "cow-04", "cow-05", "cow-06", "cow-07", "cow-08", "cow-09", "cow-10", "cow-11", "cow-12", "cow-13", "cow-14", "cow-15", "cow-16", "cow-17", "blank"), 5), rep(c("cow-26", "cow-35", "cow-36", "cow-37", "cow-38", "cow-39", "cow-40", "cow-41", "cow-42", "cow-43", "cow-44", "cow-45", "cow-46", "cow-47", "cow-48", "cow-49", "cow-50", "cow-51", "cow-59", "blank"), 5) ) type <- c( rep(c("negative", "negative", "negative", "negative", "negative", "negative", "negative", "negative", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "blank"), 5), rep(c("negative", "positive", "negative", "negative", "negative", "negative", "negative", "negative", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "blank"), 5) ) target <- c( c(rep("a", 18), rep("b", 18), rep("c", 18), rep("d", 18), rep("e", 18)), c(rep("a", 20), rep("b", 20), rep("c", 20), rep("d", 20), rep("e", 20)) ) average <- c(88.5, 49, 41, 33, 35, 45, 95, 30, 41, 64, 22, 29, 59, 71, 128, 39, 42, 47, 86, 100, 69, 44, 53, 66, 66, 71, 161, 69, 22.5, 30, 67, 99, 129, 94, 49, 33, 28, 31, 26, 23, 30, 41, 35, 23, 38, 43, 15, 21, 45, 51.5, 34, 26, 43, 32.5, 59, 58.5, 61, 62.5, 58, 59.5, 60.5, 60, 64, 110, 55, 66, 197, 83.5, 155, 76, 125, 90, 73, 84, 95.5, 62, 82, 138, 103.5, 57, 138, 149.5, 57, 54, 245.5, 191, 131, 96, 176, 45, 76, 33, 37, 51, 44, 50, 54, 66, 49, 90, 66.5, 42.5, 67, 56, 54, 50, 45, 99, 50, 51.5, 212, 40, 68, 121, 80, 57, 81.5, 128, 77, 119.5, 126, 184, 101, 103, 88, 100, 140, 186, 297, 32, 184, 36, 45, 45, 44, 86, 65, 61, 76, 62, 136, 84, 80, 56, 109, 116, 54, 59, 79, 34, 74.5, 54, 49, 55, 56, 59, 56, 56, 57, 67, 65, 63, 52, 58, 59, 56, 54, 66, 92, 87, 59, 33, 58, 51, 54, 52, 47, 45, 42, 52, 57, 79, 42, 45.5, 47, 47, 36, 50, 53, 49 ) stdev <- c(17.85, 6.31, 3.42, 1.04, 0.51, 6.04, 38.43, 2.78, 5.55, 26.72, 1.83, 9.92, 4.59, 19, 7.96, 7.5, 1.06, 9.66, 75.94, 36.79, 50.45, 9.79, 1.55, 11.42, 64.12, 0.79, 15.14, 16.15, 8.12, 4.04, 92.57, 35.35, 42.28, 52.96, 7.06, 4.97, 1.15, 4.77, 6.59, 7.27, 0.75, 4.25, 9, 0.1, 1.14, 4.17, 6.73, 3.81, 3.27, 97.44, 9.74, 0.45, 8.14, 5.91, 13.1, 98.22, 8.92, 72.62, 70.26, 59.46, 29.89, 56.35, 91.25, 49.94, 20.65, 62.04, 95.13, 35.89, 99.64, 29.44, 33.12, 45.91, 96.69, 9.05, 38.56, 3.09, 0.6, 8.69, 16.95, 74.03, 84.05, 39.87, 15.52, 27.92, 35.72, 80.26, 71.93, 66.73, 87.8, 5.43, 98.3, 7.41, 9.86, 63.64, 0.36, 5.84, 1.58, 20.1, 4.21, 82.12, 19.29, 9.02, 22.12, 54.08, 74.95, 3.24, 9.67, 67.98, 9.92, 40.69, 6.24, 8.76, 74.25, 46.34, 25.69, 90.63, 83.71, 73.53, 57.88, 15.84, 82.07, 67.45, 47.39, 98.77, 75.1, 64.9, 3.71, 87.44, 61.06, 4.77, 57.54, 7.68, 4.54, 6.15, 3.32, 60.39, 33.78, 66.22, 18.67, 76.53, 63.54, 47.06, 38.47, 88.15, 18.25, 4.26, 67.19, 88.87, 29.65, 7.33, 68.18, 28.03, 6.91, 77.82, 22.23, 73.23, 95.21, 27.11, 37.01, 34.88, 28.15, 11.27, 15.67, 96.08, 89.52, 28.6, 8.22, 23.55, 59.2, 36.38, 41.38, 0.4, 56.82, 32.35, 20.6, 18.13, 8.15, 1.08, 9.85, 1.07, 37.75, 97.6, 7.16, 8.51, 4.42, 0.15, 1.28, 7.42, 71.15, 9.39) ll <- c(70.65, 42.69, 37.58, 31.96, 34.49, 38.96, 56.57, 27.22, 35.45, 37.28, 20.17, 19.08, 54.41, 52, 120.04, 31.5, 40.94, 37.34, 10.06, 63.21, 18.55, 34.21, 51.45, 54.58, 1.88, 70.21, 145.86, 52.85, 14.38, 25.96, -25.57, 63.65, 86.72, 41.04, 41.94, 28.03, 26.85, 26.23, 19.41, 15.73, 29.25, 36.75, 26, 22.9, 36.86, 38.83, 8.27, 17.19, 41.73, -45.94, 24.26, 25.55, 34.86, 26.59, 45.9, -39.72, 52.08, -10.12, -12.26, 0.0391, 30.61, 3.65, -27.25, 60.06, 34.35, 3.96, 101.87, 47.61, 55.36, 46.56, 91.88, 44.09,
[R] plot empty when drawing from custom function
Dear all, I have set a function to draw some data using lattice; the drawing works when I use lattice on its own, but if I put it into my custom function, the final plot is empty, yet the terminal reports RStudioGD 1 as normal. What am I missing? regards, Luigi >>> cluster <- c(rep("A", 90), rep("B", 100)) sample <- c( rep(c("cow-01", "cow-02", "cow-03", "cow-04", "cow-05", "cow-06", "cow-07", "cow-08", "cow-09", "cow-10", "cow-11", "cow-12", "cow-13", "cow-14", "cow-15", "cow-16", "cow-17", "blank"), 5), rep(c("cow-26", "cow-35", "cow-36", "cow-37", "cow-38", "cow-39", "cow-40", "cow-41", "cow-42", "cow-43", "cow-44", "cow-45", "cow-46", "cow-47", "cow-48", "cow-49", "cow-50", "cow-51", "cow-59", "blank"), 5) ) type <- c( rep(c("negative", "negative", "negative", "negative", "negative", "negative", "negative", "negative", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "blank"), 5), rep(c("negative", "positive", "negative", "negative", "negative", "negative", "negative", "negative", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "positive", "blank"), 5) ) target <- c( c(rep("a", 18), rep("b", 18), rep("c", 18), rep("d", 18), rep("e", 18)), c(rep("a", 20), rep("b", 20), rep("c", 20), rep("d", 20), rep("e", 20)) ) average <- c(88.5, 49, 41, 33, 35, 45, 95, 30, 41, 64, 22, 29, 59, 71, 128, 39, 42, 47, 86, 100, 69, 44, 53, 66, 66, 71, 161, 69, 22.5, 30, 67, 99, 129, 94, 49, 33, 28, 31, 26, 23, 30, 41, 35, 23, 38, 43, 15, 21, 45, 51.5, 34, 26, 43, 32.5, 59, 58.5, 61, 62.5, 58, 59.5, 60.5, 60, 64, 110, 55, 66, 197, 83.5, 155, 76, 125, 90, 73, 84, 95.5, 62, 82, 138, 103.5, 57, 138, 149.5, 57, 54, 245.5, 191, 131, 96, 176, 45, 76, 33, 37, 51, 44, 50, 54, 66, 49, 90, 66.5, 42.5, 67, 56, 54, 50, 45, 99, 50, 51.5, 212, 40, 68, 121, 80, 57, 81.5, 128, 77, 119.5, 126, 184, 101, 103, 88, 100, 140, 186, 297, 32, 184, 36, 45, 45, 44, 86, 65, 61, 76, 62, 136, 84, 80, 56, 109, 116, 54, 59, 79, 34, 74.5, 54, 49, 55, 56, 59, 56, 56, 57, 67, 65, 63, 52, 58, 59, 56, 54, 66, 92, 87, 59, 33, 58, 51, 54, 52, 47, 45, 42, 52, 57, 79, 42, 45.5, 47, 47, 36, 50, 53, 49 ) stdev <- c(17.85, 6.31, 3.42, 1.04, 0.51, 6.04, 38.43, 2.78, 5.55, 26.72, 1.83, 9.92, 4.59, 19, 7.96, 7.5, 1.06, 9.66, 75.94, 36.79, 50.45, 9.79, 1.55, 11.42, 64.12, 0.79, 15.14, 16.15, 8.12, 4.04, 92.57, 35.35, 42.28, 52.96, 7.06, 4.97, 1.15, 4.77, 6.59, 7.27, 0.75, 4.25, 9, 0.1, 1.14, 4.17, 6.73, 3.81, 3.27, 97.44, 9.74, 0.45, 8.14, 5.91, 13.1, 98.22, 8.92, 72.62, 70.26, 59.46, 29.89, 56.35, 91.25, 49.94, 20.65, 62.04, 95.13, 35.89, 99.64, 29.44, 33.12, 45.91, 96.69, 9.05, 38.56, 3.09, 0.6, 8.69, 16.95, 74.03, 84.05, 39.87, 15.52, 27.92, 35.72, 80.26, 71.93, 66.73, 87.8, 5.43, 98.3, 7.41, 9.86, 63.64, 0.36, 5.84, 1.58, 20.1, 4.21, 82.12, 19.29, 9.02, 22.12, 54.08, 74.95, 3.24, 9.67, 67.98, 9.92, 40.69, 6.24, 8.76, 74.25, 46.34, 25.69, 90.63, 83.71, 73.53, 57.88, 15.84, 82.07, 67.45, 47.39, 98.77, 75.1, 64.9, 3.71, 87.44, 61.06, 4.77, 57.54, 7.68, 4.54, 6.15, 3.32, 60.39, 33.78, 66.22, 18.67, 76.53, 63.54, 47.06, 38.47, 88.15, 18.25, 4.26, 67.19, 88.87, 29.65, 7.33, 68.18, 28.03, 6.91, 77.82, 22.23, 73.23, 95.21, 27.11, 37.01, 34.88, 28.15, 11.27, 15.67, 96.08, 89.52, 28.6, 8.22, 23.55, 59.2, 36.38, 41.38, 0.4, 56.82, 32.35, 20.6, 18.13, 8.15, 1.08, 9.85, 1.07, 37.75, 97.6, 7.16, 8.51, 4.42, 0.15, 1.28, 7.42, 71.15, 9.39) ll <- c(70.65, 42.69, 37.58, 31.96, 34.49, 38.96, 56.57, 27.22, 35.45, 37.28, 20.17, 19.08, 54.41, 52, 120.04, 31.5, 40.94, 37.34, 10.06, 63.21, 18.55, 34.21, 51.45, 54.58, 1.88, 70.21, 145.86, 52.85, 14.38, 25.96, -25.57, 63.65, 86.72, 41.04, 41.94, 28.03, 26.85, 26.23, 19.41, 15.73, 29.25, 36.75, 26, 22.9, 36.86, 38.83, 8.27, 17.19, 41.73, -45.94, 24.26, 25.55, 34.86, 26.59, 45.9, -39.72, 52.08, -10.12, -12.26, 0.0391, 30.61, 3.65, -27.25, 60.06, 34.35, 3.96, 101.87, 47.61, 55.36, 46.56, 91.88, 44.09, -23.69, 74.95, 56.94, 58.91, 81.4, 129.31, 86.55, -17.03, 53.95, 109.63, 41.48, 26.08, 209.78, 110.74, 59.07, 29.27, 88.2, 39.57, -22.3, 25.59, 27.14, -12.64, 43.64, 44.16, 52.42, 45.9, 44.79, 7.88, 47.21, 33.48, 44.88, 1.92, -20.95, 46.76, 35.33, 31.02, 40.08, 10.81, 205.76, 31.24, -6.25, 74.66, 54.31, -33.63, -2.20, 54.47, 19.12, 103.66, 43.93, 116.55, 53.61, 4.23, 12.9, 35.1, 136.29, 98.56, 235.94, 27.23, 126.46, 28.32, 40.46, 38.85, 40.68, 25.61, 31.22, -5.22, 57.33, -14.53, 72.46, 36.94, 41.53, -32.15, 90.75, 111.74, -13.19, -29.87, 49.35, 26.67, 6.31, 25.97, 42.09, -22.82, 33.77, -14.23,