When I use correlation function in RstudioThis I get below error message:

The dataset that I have imported is show below and V1,V2 are given by default to the columns:

When I use correlation function in RstudioThis I get below error message:

The dataset that I have imported is show below and V1,V2 are given by default to the columns:

So, if I got you correctly, you want to find correlation between variables V1 and V2 in the dataframe data1. To refer to the column in the dataframe a $ sign is used. Then your code will look like:
cor(data1$V1,data1$V2)
or, if you want, you can also use with() function, which would narrow down the namespace to particular dataframe data1:
with(data1, cor(V1, V2))
 
    
    There are two ways:
1) Attaching the data:
attach(data1)
And then this code should work:
cor(V1, V2)
2) Using $ for accesing columns in a dataframe
cor(data1$V1, data1$V2)
