How to implement an algorithm using R

This is an example for calculating Body Mass Index using height and weight.

The first line sets the working directory in which the CSV file is located.

setwd("C:/Users/123/Documents/R")

temp <- read.csv(file="practice_data.csv",header=TRUE,sep=",")

bmi=temp$weight/temp$height

bmi

 

This is the CSV file, practice_data.csv.

Name,height,weight
John,1.6,50
Mary,1.7,55
Ed,1.5,44
David,1.3,65

Leave a Reply