Beginner level question.
I have data like the image above. I want to find the correlation between Height and Longevity.
Smaller breeds of dogs tend to live longer than larger breeds. Is there a way to establish this correlation and show it in plot (preferably with dog breed names as well) in R?
cor function is giving error because the height and longevity data is in range. Am not sure how exactly this can be done. Please help.
Thank you.
Code below to reproduce:
list(
Breed = c(
"Labrador Retriever",
"German Shepherd",
"Bulldog",
"Poodle",
"Beagle",
"Chihuahua",
"Boxer",
"Golden Retriever",
"Pug",
"Rottweiler"
),
Country.of.Origin = c(
"Canada",
"Germany",
"England",
"France",
"England",
"Mexico",
"Germany",
"Scotland",
"China",
"Germany"
),
Fur.Color = c(
"Yellow, Black, Chocolate",
"Black, Tan",
"White, Red",
"White, Black, Brown, Apricot",
"White, Tan, Red, Lemon",
"Black, Brown, Tan, White",
"Fawn, Brindle",
"Golden",
"Fawn, Black",
"Black, Tan"
),
Height..in. = c(
"21-24",
"22-26",
"12-16",
"10-15",
"13-15",
"6-9",
"21-25",
"21-24",
"10-14",
"22-27"
),
Color.of.Eyes = c(
"Brown",
"Brown",
"Brown",
"Brown, Blue",
"Brown",
"Brown, Blue",
"Brown",
"Brown",
"Brown",
"Brown"
),
Longevity..yrs. = c(
"10-12",
"7-10",
"8-10",
"12-15",
"12-15",
"12-20",
"10-12",
"10-12",
"12-15",
"8-10"
),
Character.Traits = c(
"Loyal, friendly, intelligent, energetic, good-natured",
"Loyal, intelligent, protective, confident, trainable",
"Loyal, calm, gentle, brave",
"Intelligent, active, affectionate, hypoallergenic",
"Curious, friendly, energetic, good-natured",
"Loyal, energetic, confident, sensitive",
"Loyal, energetic, intelligent, playful, protective",
"Intelligent, friendly, kind, loyal, good-natured",
"Loyal, playful, affectionate, social, charming",
"Loyal, protective, confident, strong"
),
common_problem1 = c(
"hip dysplasia",
"hip dysplasia",
"skin allergies",
"hip dysplasia",
"ear infections",
"dental problems",
"hip dysplasia",
"hip dysplasia",
"eye problems",
"hip dysplasia"
),
common_problem2 = c(
"obesity",
"elbow dysplasia",
"respiratory issues",
"epilepsy",
"hip dysplasia",
"eye issues",
"cancer",
"cancer",
"respiratory issues",
"cancer"
),
common_problem3 = c(
"ear infections",
"pancreatitis",
"obesity",
"bladder stones",
"epilepsy",
"respiratory issues",
"heart conditions",
"skin allergies",
"obesity",
"elbow dysplasia"
)
),
row.names = c(NA, 10L),
class = "data.frame"
))
I tried cor(Height..in., Longevity..yrs.). But it is giving me error. Not sure if this is the exact way to try.