-2

In R studio I have imported one .csv file which has two columns X and Y. But when I try to use plot(X,Y), I get the error message:

"Object X not found"
BSMP
  • 4,596
  • 8
  • 33
  • 44
Ashish Das
  • 3
  • 1
  • 1
  • 2
  • 1
    Hey Ashish! Could you post some sample code? – Bensstats May 06 '19 at 21:01
  • 2
    Your data is most probably stored as a data.frame. Try `plot(Y ~ X, data = name_of_dataframe)`. – Alex May 06 '19 at 21:02
  • 3
    Possible duplicate: https://stackoverflow.com/questions/27886839/what-does-error-object-myvariable-not-found-mean (there's no additional useful information here). 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 May 06 '19 at 21:02

1 Answers1

0

I believe Alex's answer above is correct. The plot() function is complaining that X is not a variable, and you've already said it was a column instead. The "data" parameter tells plot not to try and interpret X and Y as variables, but as columns of a dataframe.

It would also work to use

plot(<name_of_dataframe>$X ~ <name_of_dataframe>$Y)

Where you replace <name_of_dataframe> with the actual name of the object that you imported the .csv into.

bbiasi
  • 1,549
  • 2
  • 15
  • 31