How to calculate relative risk in R language?

0 votes

How to calculate relative risk in R?

This is the input:

names(DS)
Tab<-table(DS[,5],DS[,11],DS[,3])

      No Yes
  No   4  16
  Yes  40 168

I'm new to R language, any help would be appreciated.

Feb 20 in Data Analytics by Tyrion anex
• 8,280 points
11 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

The risk can be calculated by using this formula (pos1/total1)/(pos2/total2) where pos1 denotes the number of cases in the first group, pos2 in the second group, and the total variables are the group totals

However, the epitab function of the epitools package, is needed for your problem:

## maybe:
##   install.packages("epitools")
library("epitools")

For input formats, try this:

tab <- matrix(c(4,16,40,168),byrow=TRUE,nrow=2)
epitab(tab,method="riskratio")
## $tab
##           Outcome
## Predictor  Disease1        p0 Disease2        p1 riskratio     lower    upper
##   Exposed1        4 0.2000000       16 0.8000000  1.000000        NA       NA
##   Exposed2       40 0.1923077      168 0.8076923  1.009615 0.8030206 1.269361
##           Outcome
## Predictor  p.value
##   Exposed1      NA
##   Exposed2       1

answered Feb 20 by Sophie may
• 9,050 points

Related Questions In Data Analytics

0 votes
1 answer

How to calculate group mean and assign it to new data in R

You can use something like this: df$grp.mean.values <- ...READ MORE

answered Jun 27, 2018 in Data Analytics by darklord
• 6,140 points
36 views
0 votes
1 answer

How to change y axis max in time series using R?

The axis limits are being set using ...READ MORE

answered Apr 3, 2018 in Data Analytics by darklord
• 6,140 points
41 views
0 votes
1 answer
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
60 views
0 votes
1 answer

How to sort a data frame by columns in R?

You can just use the order function ...READ MORE

answered Apr 10, 2018 in Data Analytics by darklord
• 6,140 points
49 views
0 votes
1 answer

How can I perform word stemming in R

The tm package in R provides the stemDocument() function to stem the ...READ MORE

answered Aug 20, 2018 in Data Analytics by ANMOL
• 3,620 points
35 views
0 votes
1 answer

How to know the type of an object?

To find the type of an object ...READ MORE

answered Sep 19, 2018 in Data Analytics by ANMOL
• 3,620 points
20 views
0 votes
1 answer

How do I import document files in R programming

Try the following: read.table("~/SMSSpamCollection", header=TRUE, sep="\t") Change "~/" to the "ptah/to/your/file/" Mess around ...READ MORE

answered Nov 5, 2018 in Data Analytics by Kalgi
• 35,720 points
14 views
0 votes
1 answer

How to convert JSON into CSV in R programming?

Use the jsonlite::fromJSON to read the data into ...READ MORE

answered Jan 24 in Data Analytics by Sophie may
• 9,050 points
63 views
0 votes
1 answer

How to remove HTML tags from string in R Programming?

Try this simple code to remove the <br ...READ MORE

answered Feb 1 in Data Analytics by Sophie may
• 9,050 points
55 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.