Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 679cb6ac rédigé par Simon CHEVOLLEAU's avatar Simon CHEVOLLEAU :computer:
Parcourir les fichiers

Remove the deletion of first column while specifing rnames = TRUE

parent 1e1f40ae
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -10,7 +10,6 @@ readTable <- function(dataName, sepUser = '\t', rnames = TRUE, header = TRUE, nT
dat <- as.data.frame(data.table::fread(dataName, sep = sepUser, header = header, nThread = nThread,dec = dec))
if(rnames){
rownames(dat) <- as.character(dat[,1])
dat <- dat[,-1]
message('row names have been set up')
}else{
message('row names haven\'t been set up')
......@@ -149,13 +148,14 @@ listToDf <- function(li,first_col="modules", second_col="genes"){
#' @description Convert a list to a dataframe where the first column is the
#' names of list repeated and the second column is the elements in the list
res <- data.frame(first_col=rep(names(li)[1], length(li[[1]])), second_col=li[[1]])
colnames(res) <- c(first_col, second_col)
if (length(li) == 1){
colnames(res) <- c(first_col, second_col)
return(res)
}
for (i in 2:length(li)){
res <- rbind(res, data.frame(first_col=rep(names(li)[i], length(li[[i]])), second_col=li[[i]]))
}
colnames(res) <- c(first_col, second_col)
return(res)
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter