I am just beginning to learn R and I have a very basic question. I have imported my dataset into R Studio based on an Excel file and have assigned a variable to a column of the data. The variable is named myJFG. Then, I have created a very basic If statement to determine if the list myJFG == "Sales"
. I have received the results in the console (TRUE, FALSE, FALSE, etc.). Could you explain how to write the results to a blank outer column in my dataset? Or is there a better way to hold this data in memory so that I can use it later on? Later, I will create more complex If statements and will return the results to the dataset.
Asked
Active
Viewed 28 times
0

Chris2015
- 1,030
- 7
- 28
- 42
-
1Please take a moment to read about how to post R examples: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – YOLO Jan 13 '20 at 20:22
-
Do you mean `mydat$newcolumn <- (mydat$myJFG == "Sales")`? – r2evans Jan 13 '20 at 20:24
-
It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jan 13 '20 at 20:27
-
Yes. mydat$newcolumn<- (mydat$myJFG=="Sales") is what I was looking for. It is so simple, but since I am new to this I really wasn't sure. Thank you r2evans! – Chris2015 Jan 13 '20 at 20:28