Write an r function to calculate body mass index

Assignment Help Other Engineering
Reference no: EM131470169

Introduction

This is a short analysis assignment to be undertaken individually.

This assignment involves three tasks, involving a file of simple patient data (the data are fictional and do not refer to real people).

The first task is to check the integrity of a data file (check for the presence of data errors and problems) by writing simple R code. The file contains a number of errors and potential problems. Some of the errors are obvious if you inspect the data by eye. However, marks will not be awarded for simply stating what the errors or problems are. Marks will be awarded for R code that demonstrates the presence (or absence) of errors and problems in the given data. The R code that you will submit does not need to be the most elegant or ‘clever' code possible: we are seeking a demonstration of basic R usage in this assignment. It should still be clear, concise, commented and correct.

The second task involves writing R code to perform some descriptive analysis of the data.

The third task requires you to write an R function to calculate a derived value: Body Mass Index (BMI). You will then use that function to add a column for BMI to the data. You will then need to use R to draw a histogram of the distribution of BMI.

Marking

There are 3 tasks. Task 1 is worth 30 marks. Task 2 is worth 20 marks. Task 3 is worth 10 marks. This assignment is out of 60 and contributes 30% of your final assessment mark.

Recommendations

You should prepare all your work using RStudio. Create a project called ‘assignment-2' and a script file within that project called ‘solution.R'. Put all your code in ‘solution.R' and we will run this file (and only this file) when marking your assignment.

This assignment is not difficult but will take time to complete so don't leave it until the last minute. The time available to you before this is due is more than adequate to complete the assignment.

A description of the data file ‘diabetes1.csv'

A study is underway to determine how many people presenting to an Emergency Department (ED) in a hospital with ear infections have diagnosed diabetes. The file diabetes1.csv is provided to you supposedly with the following specifications.

The file ‘diabetes1.csv' contains data on 1000 patients presenting to the ED with otitis externa (outer ear infection) in CSV format.1

Table T1 describes the data in the file column by column. Each row of the file contains one record with the column in the order as given on the first header line.2 In the table:

- A column marked as mandatory means the data in that column are required in all records

- A column marked as optional means that the data in that column may be missing for some records

Table T1:

 

Column name

 

Required?

 

Type

 

Comments

 

ID

 

mandatory

 

integer

 

unique for each patient

 

surname

 

mandatory

 

character string

 

patient's surname in upper case

 

middle.name

 

optional

 

character string

 

patient's middle name (if they have one) in mixed case

 

first.name

 

mandatory

 

character string

 

patient's first or given name in mixed case

 

gender

 

mandatory

 

character string

 

"Female" or "Male" only

 

systolic_bp

 

mandatory

 

integer

 

pressure reading in mmHg in the range 60- 220 mmHg

 

diastolic_bp

 

mandatory

 

integer

 

pressure reading in mmHg in the range 50- 150 mmHg

 

Age

 

mandatory

 

integer

 

age in whole years, only patients 18 years and older have been enrolled in the study

 

Height(cm)

 

mandatory

 

decimal number

 

measured height of the patient in cm

 

Column name

 

Required?

 

Type

 

Comments

 

weight

 

mandatory

 

integer

 

measured weight of the patient, fully clothed and with shoes on, in kg

 

RandomBSL

 

optional

 

decimal

 

blood sugar level (BSL), measured in millimole per litre (mmol/L), ≥ 2.2 mmol/L

 

HbA1c

 

optional

 

decimal

 

haemoglobin A1c measurement, as a percentage

 

DiabetesDiagnosis

 

optional

 

logical

(TRUE or FALSE)

 

whether the patient had been previously diagnosed as suffering from diabetes

Task 1

Remember: you will be submitting R code that calculates/demonstrates answers to the following questions not just a printed output. We will not be marking the printed output of your programme. We need to be able to run your programme to mark it.

Read the file ‘diabetes1.csv' into an R data frame.

You will want to use StringsAsFactors=FALSE as an optional argument to the read.csv() function to prevent character variables being automatically converted to factors.

Check that the data file conforms to the specifications for it:

- Does it have the correct number of rows?

- Does it contain all the columns it is supposed to contain

- Does it contain no additional columns?

- For each column, calculate the number and proportion (percentage) of records for which the data are missing.

- For each column, calculate the number and proportion (percentage) of records for which the data are valid (exists and is a legal value).

- Calculate the number and proportion (percentage) of records overall that contain no invalid values in any column. A missing optional value is not invalid.

Task 2

You may need to correct some problems with the data as provided in order to calculate these quantities.

All changes to the data must be made using R code, so that the changes are repeatable. Do not edit

‘diabetes1.csv (or a copy of it) by hand. You will lose marks for editing the input data to correct problems.

If you need to correct or modify the data we suggest you load the ‘raw' data into a dataframe and write a function to correct the dataframe then analyse the corrected data.

Calculate the following descriptive statistics.

- Number of patients in each of the following age brackets:

o 0-17,18-24, 25-44, 45-64, 65-84, 85+

- Number and percentage of patients:

o previously diagnosed with diabetes

o not previously diagnosed with diabetes

- Number of patients in each age group previously diagnosed with diabetes, and not previously diagnosed with diabetes (note: this is 12 values).

- The ID numbers of all patients aged over 64 years who have not previously been diagnosed with diabetes.

- Draw a histogram of RandomBSL. Some proportion of the marks will be given for proper labelling of the histogram and its axes.

Task 3

Write an R function to calculate Body Mass Index (BMI).

BMI is calculated using the following formula:

BMI = weight in kg/(height in m)2

Use your BMI function to add a column containing the calculated BMI for each patient to the data frame containing the patient data.

Draw a histogram of BMI. Some proportion of the marks will be given for proper labelling of the histogram and its axes.

Attachment:- diabetes.rar

Reference no: EM131470169

Questions Cloud

What is the cost of new equity to the firm : What is the cost of new equity to the firm? What are the advantages and disadvantages of issuing new equity in the capital structure?
Math quiz game for school kids : Develop a Java application for a Math Quiz Game for school kids. You quiz game generates random addition problems.
Is culture a factor in personality expression : How does the gene-environment interaction influence personality?Is culture a factor in personality expression?
Evaluate pros and cons of increased regulatory requirement : Evaluate the pros and cons of increased regulatory requirement, indicating the impact to the lender and the buyer. Provide support for your answer.
Write an r function to calculate body mass index : Data Management and Programming for Epidemiology - Write an R function to calculate Body Mass Index Calculate the number and proportion
Which of the specific environmental hr challenges : Which of the specific environmental and organizational HR challenges identified in this chapter will be most important in healthcare in the next 20 years?
How did you become aware of people being treated differently : When and how did you become aware of people being treated differently because of race, culture, or religion? Explain.
Recommend a strategy for financial administrators : Recommend a strategy for financial administrators to balance the tension between having inventory on hand when it is needed versus carry cost to organization.
What is the expected salary of a female : What is the expected salary of a female white employee with 16 years of education and federal experience? Please show the calculation

Reviews

Write a Review

Other Engineering Questions & Answers

  Characterization technology for nanomaterials

Calculate the reciprocal lattice of the body-centred cubic and Show that the reciprocal of the face-centred cubic (fcc) structure is itself a bcc structure.

  Calculate the gasoline savings

How much gasoline do vehicles with the following fuel efficiencies consume in one year? Calculate the gasoline savings, in gallons per year, created by the following two options. Show all your work, and draw boxes around your answers.

  Design and modelling of adsorption chromatography

Design and modelling of adsorption chromatography based on isotherm data

  Application of mechatronics engineering

Write an essay on Application of Mechatronics Engineering

  Growth chracteristics of the organism

To examine the relationship between fermenter design and operating conditions, oxygen transfer capability and microbial growth.

  Block diagram, system performance and responses

Questions based on Block Diagram, System Performance and Responses.

  Explain the difference in a technical performance measure

good understanding of Mil-Std-499 and Mil-Std-499A

  Electrode impedances

How did this procedure affect the signal observed from the electrode and the electrode impedances?

  Write a report on environmental companies

Write a report on environmental companies

  Scanning electron microscopy

Prepare a schematic diagram below of the major parts of the SEM

  Design a pumping and piping system

creating the pumping and piping system to supply cool water to the condenser

  A repulsive potential energy should be a positive one

Using the data provided on the webvista site in the file marked vdw.txt, try to develop a mathematical equation for the vdW potential we discussed in class, U(x), that best fits the data

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd