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)
More Related Contents:
- Select the first row by group
- How does one reorder columns in a data frame?
- Split violin plot with ggplot2
- Add correct century to dates with year provided as “Year without century”, %y
- Replace missing values with column mean
- Find how many times duplicated rows repeat in R data frame [duplicate]
- How to create an R function programmatically?
- Don’t drop zero count: dodged barplot
- How to filter a data frame
- How to center stacked percent barchart labels
- How to assign the result of the previous expression to a variable?
- Why does unlist() kill dates in R?
- how to insert new line in R shiny string
- R Error in x$ed : $ operator is invalid for atomic vectors
- Use different center than the prime meridian in plotting a world map
- Rtools is not being detected from RStudio
- multiple graphs in one canvas using ggplot2
- Getting a stacked area plot in R
- Error in plot.window(…) : need finite ‘xlim’ values
- multithreading with R?
- How does cut with breaks work in R
- Subsetting data.table by 2nd column only of a 2 column key, using binary search not vector scan
- How to fit a smooth curve to my data in R?
- Force ggplot legend to show all categories when no values are present [duplicate]
- Greek letters, symbols, and line breaks inside a ggplot legend label
- How to listen for more than one event expression within a Shiny observeEvent
- Why I get this error writing data to a file
- Shiny renderUI selectInput returned NULL
- Efficient calculation of matrix cumulative standard deviation in r
- Color points with the color as a column in ggplot2 [duplicate]