The variable hosp1 has 2 columns: Latitude and Longitude. We want to see if the pairs of data share a correlation, i.e. is there a relationship between Latitude and Longitude? Does increasing the first variable affect the second variable? So the function is And hosp1$Latitude is the Latitude column and hosp1$Longitude is the Longitude column

# Category: R

## Removing missing data in R

I was playing around with the Latitude and Longitude of hospitals in the UK. When I went to try correlation I got NA because of missing data. To get round this I created a new variable. This basically omits all NA (missing values). So use the simple function na.omit to create a new dataset without…

## Import a csv into R

This can be done with this coderead.csv(“#file url here “) # You need to make sure to have a double backslash in the file path So on my computer I went to the file location and then right-clicked and chose copy path. That gave I then modified it to C:\\Users\\caleb\\Desktop\\Stats\\location.csv #not double backslashes and so…

## Drawing a ball from a bag

I am learning to program. Here is an example in R of simulating the problem of drawing 1 ball from a bucket of 200 balls, and repeating this a total of 300 times. How many times does the same ball come up in succession? Obviously depends. Simulate the drawing of the balls Next search through…