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

  How is the kyoto protocol being addressed and implemented

Resorting to published literature or other media resources Investigate and explain in a short essay, how is the Kyoto protocol being addressed and implemented in practice in the KSA, name the designated national authority for the Clean Development..

  Compute z to cover the entire cycle

Compute Zi for enough Values of  i>=1 to cover the entire cycle

  Evaluate the time interval required to empty

(a) Show that the time interval required to empty the tank is given by (b) Evaluate the time interval required to empty the tank if it is a cube 0.500 m on each edge, if A = 2.00 cm2, and d = 10.0 m.

  Application area-specific best practices success factors

Best practices, Application area-specific best practices/critical success factors?

  The cut-off frequency of a filter occurs

Question 6.6. You are to select a window function to limit the number of samples of an infinite impulse response and the filter specifications are the same, regardless of which window function you select.

  The desired frequency from the band of frequencies present

In many circuits, different frequencies are present which are encountered during the operation. Some frequencies are desired while some others are not. The non desired frequencies can be rejected with special circuits called filters. Filters can b..

  Determine user equilibrium travel times and flows

If population declines reduce the number of travelers at the origin, and the total origin-destination flow is reduced to 7000 veh/h, determine user equilibrium travel times and flows.

  What is the acceleration

A 15 kg steel container has 1.75 kilo moles of liquid propane inside. A force of 2 kN now accelerates this system. What is the acceleration?

  Differences between chiral

Explain the differences between chiral, zig-zag and armchair carbon nanotubes. How may these structures be described mathematically? What are the predicted electronic properties of (10, 0), (21, -3) and (8, 8) SWNTs?

  List the different types of antennas and their applications

List the different antenna types, shapes and sizes, and their applications. List the different types of antennas and their applications. Find images to help describe the different antennas.

  How does this affect the amount of induced voltage

Assume that a conductor being cut by the flux of an expanding magnetic field has 10 V induced with the top end positive. Now analyze the effect of the following changes: The magnetic flux continues to expand, but at a slower rate. How does this affec..

  Support vector machine this is a homework based on kernel

this is a homework based on kernel methods and support vector machines. ltbrgtsolution should legible well-organized

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