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

  Create code to solve the problem using explicit formulation

ENGR 4576: Computational Fluid Dynamics. Create a code to solve the problem using explicit formulation. -Perform a grid-refinement study. Start with 41x41 grid and refine until results at least

  Properties of ac circuits-lab alternating voltage-current

atch Week 1 Video Lecture 1: Introduction to Virtual Instruments from the weekly content and the video in this lab assignment on "Introduction to Virtual Breadboarding in MultiSIM"

  Define the aircraft axes and degrees of freedom

Define the aircraft axes and degrees of freedom. Analyse the different maneuvers that can be done by an aircraft.

  Evaluate the online crm system of your bank what are the

what are the motivations for an organization to have a good supply chain management scm system? define scm in your own

  Design the circuit showing all calculations

1. In a processing plant, a chemical tower has a liquid which is vaporized. However, if the vapor in the tower reaches 150°C, an alarm needs to be generated so that safe shutdown of that system of the plant may be initiated. An RTD will be used to..

  Review gartner groups hype cycle for emerging technologies

Review the Gartner Groups hype cycle for emerging technologies.

  Question 1in view of growing number of deaths on the road

question 1in view of growing number of deaths on the road the police department plans to introduce more speeding

  Provide a teaching pedagogy reflective of 21st century

Provides safe Web access to students and staff. It also ensures no student or staff member is exposed to illicit web content.

  Operation of feedback control systems

Save this document and place your answers into it so you can submit it to the appropriate homework drop box. Handwritten solutions should be scanned and saved as a BMP, GIF, or JPG image, or scanned and pasted into this document.

  Output voltage of a noninverting op-amp circuit

1. Design a summing amplifier based on a 741 IC chip. The amplifier has Rf = 1 M 0, RI = 100 KO, R2 = 50 KO, and R;= 10 KO. The input voltages are VI= 100 mV sin (2000 t), and V. = 150 mV sin (3000 t), and l'3 = 200 mV sin (1000 t). Draw the summi..

  Choose another programming language and compare

Choose another programming language and compare that language to what you are learning about C language. What are some of the similarities and differences of the two languages?

  What is the closed-loop voltage gain

The noninverting buffer op-amp configuration shown in Fig. P11.3 provides a direct implementation of the feedback loop of Fig. 11.1. Assuming that the op amp has infinite input resistance and zero output resistance, what is β?

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