R programming help to solve the problem

Hello to everyone. I start to works with R studio 3 months ago. My teacher gave me same code but it didn't work. I tried it a lot of time but I can solve the problems with this code. Help me please.


set.seed(1111111) # 111111 (thr: change) gets crossing KM curve (worse result) < 1111111 (thr:0.5) makes no error, and the seed number affects the result a lot !!

# read my data
data_dir <- "D:/Documents/data"
filename <- "data.csv"
x_total <- read.csv(file.path(data_dir, filename), sep = ",", header = T)
x_total <- Filter(function(x) length(unique(x))>1, x_total)
x_total <- as.matrix(x_total)
dimnames(x_total) <- NULL # MUST remove column names for this package
x <- x_total[,4:ncol(x_total)] 
# x <- scale(x) # MUST remove scale(x) not to make error !!!
x <- t(x) # MUST be pxn matrix, not nxp !!! 
dim(x) # (7546, 50)

Hi @Lena, and welcome!

This is a hard question to provide any useful guidance without a reproducible example, called a reprex. Your code goes a long way, but without sample data, and a description of how that fails to work (preferably an error message), there's not much that can be offered.

An aside, seeds are used to generate pseudo-randomness. Setting a seed allows reproducing a particular pseudo-random use, and it's entirely normal to see different results with different seeds.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.