'Object not found by r whenever I try to graph


library(lattice) 
data = read.csv("Conductivity.csv", header = T) 
View(data) 
Salinity = as.factor(Salinity) 
xyplot(Electroconductivity ~ Salinity)

enter image description here

I am trying to graph Electroductivity vs Salinity using a dot plot but r keep saying that:

Error in is.factor(x) : object 'Salinity' not found
object 'Electroconductivity' not found

I have used the right syntax as far as I am concerned, I have correctly set my working directory so that r can access the csv file. I have already checked the file name and the variable names, they are all correct. Why is this happening? Edit: And I have also ran the code from top to bottom.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source