user8229280
user8229280

Reputation: 25

Modify the code_Plot for multiple outputs in R

I was wondering how I can have this plots for multiple outputs. I want to have a plot () of each output in "a" separately.

b<- lapply(mtcars[-c(4,8,9)], function(x) lm(x ~ vs*am, data=mtcars))
a<- lapply(b,interactionMeans)

mtcars data set is available in R.

Upvotes: 1

Views: 34

Answers (1)

Marco Sandri
Marco Sandri

Reputation: 24262

Maybe this is what you are looking for:

library(phia)
mtcars$vs <- factor(mtcars$vs)
mtcars$am <- factor(mtcars$am)

b <- lapply(mtcars[-c(4,8,9)], function(x) lm(x ~ vs*am, data=mtcars))
a <- lapply(b, interactionMeans)

tmp <- lapply(a, function(x) {windows(); plot(x)})

enter image description here

Upvotes: 1

Related Questions