fomi
August 31, 2019, 11:50pm
1
Let's say I have this sample data:
Month
Spend
Sales
1
1000
9914
2
4000
40487
3
5000
54324
If I want to build a model I would do something like this:
dataset = read.csv("data-marketing-budget-12mo.csv", header=T)
simple.fit = lm(Sales~Spend, data=dataset)
summary(simple.fit)
but I want to be able to do it like this:
dataset = read.csv("data-marketing-budget-12mo.csv", header=T)
simple.fit = lm(dataset[3]~dataset[2], data=dataset)
summary(simple.fit)
FJCC
September 1, 2019, 12:07am
2
All you have to do is use [[ to call the column you want and there is no need to set the data parameter.
1 Like
jcblum
September 6, 2019, 3:40pm
4
If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:
If your question has been answered, don't forget to mark the solution!
How do I mark a solution?
Find the reply you want to mark as the solution and look for the row of small gray icons at the bottom of that reply. Click the one that looks like a box with a checkmark in it:
[image]
Hovering over the mark solution button shows the label, "Select if this reply solves the problem". If you don't see the mark solution button, try clicking the three dots button ( ••• ) to expand the full set of options.
When a solution is chosen, the icon turns green and the hover label changes to: "Unselect if this reply no longer solves the problem". Success!
[solution_reply_author]
…
system
Closed
September 27, 2019, 3:40pm
5
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.