I am a novice in R programming and have been trying to work on block randomization using the blockrand package.
The steps required are as follows:
- In an MS-Excel file, we have four columns – Patient ID, Treatment name, Parameter 1 and Parameter 2. Please note: The number of patients, treatments and parameters will vary each time (E.g.: There can be 10 patients in one study with 2 treatments and 50 in the next with 4 treatments). So the code has to be written in such a way that it can accept dynamic input values and would not throw an error as a result.
- This Excel file would be an input into the R script. Using the blockrand package, we plan to randomize these treatments into blocks and also calculate mean and SD.
- This output will have to be written into a new Excel file.
Any help regarding this will be highly appreciated.
Regards,
Eva
This image is an example of the sample data along with the possible data types
Just a very basic example of what I have tried to do. I am aware that most of the data while using a package has to be given by the user as mentioned in the below code case.
library(blockrand)
library(dplyr)
inputfile <- read.csv(filepath = "",sep="")
blk.rnd <- blockrand(9, #since 9 is the number of patients I have currently
num.levels = 3,
block.sizes = 3)
dput()
I am looking for a solution where the package can pick up details on number of patients and the number of level from the Excel input file and can automatically calculate the number of blocks for the treatments. This can with or without using the blockrand package. Even if you are unable to help me with the code, but can tell me how I should be approaching this problem, it would be a great help.
RBR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.