Calculating relative risks in R

+1 vote

I am new to R programming language. This is the input:

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

      No Yes
  No   4  16
  Yes  40 168

Mar 15, 2019 in Data Analytics by Sophie may
• 10,100 points
63 views

1 answer to this question.

0 votes

You can calculate the relative risk as  (pos1/total1)/(pos2/total2) 

here, pos1 is the samples in the first group, 

pos2 in the second group.

Use the epitab function of the epitools package:


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

After installing, 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

I hope this helped.

answered Mar 15, 2019 by Tyrion anex
• 8,560 points

Related Questions In Data Analytics

+1 vote
1 answer

How to calculate relative risk in R language?

The risk can be calculated by using ...READ MORE

answered Feb 20, 2019 in Data Analytics by Sophie may
• 10,100 points
630 views
+2 votes
1 answer

Need a hadoop engine in backend to run r server

Dear Koushik, Hope you are doing great. The hadoop ...READ MORE

answered Dec 17, 2017 in Data Analytics by Sudhir
• 1,610 points
170 views
0 votes
2 answers

Installing MXNet for R in Windows System

You can install it for python in ...READ MORE

answered Dec 3, 2018 in Data Analytics by Kalgi
• 51,970 points
805 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,580 points
258 views
+1 vote
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 32,490 points
499 views
+10 votes
3 answers

Which is a better initiative to learn data science: Python or R?

Well it truly depends on your requirement, If ...READ MORE

answered Aug 8, 2018 in Data Analytics by Abhi
• 3,720 points
223 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 Abhi
• 3,720 points
397 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 Abhi
• 3,720 points
77 views
0 votes
1 answer

Calculating quantiles in R.

You can follow this code: y <- rnorm(100) ...READ MORE

answered May 2, 2019 in Data Analytics by Tyrion anex
• 8,560 points
153 views
0 votes
1 answer

Check if a matrix is diagonalizable in R Programming Language

On a given matrix, a, the first way ...READ MORE

answered Dec 24, 2018 in Data Analytics by Tyrion anex
• 8,560 points
203 views