J. Joe
J. Joe

Reputation: 31

Can I see object itself that I defined in R?

For example, I defined a model:

Model <- lm(Sales~(a + b + c, data))

At this point, if I input Model in R, I get a result of regression analysis.

But at here, I want to have that the object itself, in other words, I want to see Model <- lm(Sales~(a + b + c, data)) in the result screen. Isn't there some way to do this?

Upvotes: 0

Views: 103

Answers (2)

astrofunkswag
astrofunkswag

Reputation: 2688

lm objects have a field call which you could get with Model$call

That would give you lm(Sales~a+b+c, data)

Upvotes: 1

morgan121
morgan121

Reputation: 2253

If you want to just print it use print("Model<-lm(Sales~(a+b+c,data)") as dshkol suggested, or cat("Model<-lm(Sales~(a+b+c,data)") if you don't want quotes.

If you need to use the output in another function you can use substitute("Model<-lm(Sales~(a+b+c,data)")

If you need the result to be a character then you can always wrap it in as.character(substitute("Model<-lm(Sales~(a+b+c,data)")).

Does that help?

Upvotes: 1

Related Questions