text: user1369: I downloaded c5: gene ontology gene sets file from http://software.broadinstitute.org/gsea/downloads.jsp
  I opened the "c5.all.v6.2.symbols.gmt" file in csv format and It looks like below:
  
  I want to convert the .gmt file into a dataframe. And it should look like below:
  
  can anyone say how I can do that. Thanq
  
  user3119: You can import the csv file as a table. This does not require further libraries:
  #you're reading a csv file, using tab as field separator and considering the first line as the headers of the data table
  data <- read.csv(filename, sep="\t", header=TRUE)
  
  then what you need are just two columns of your data:
  colnames(data) #will give you the names of the columns that can be accessed
  #to access two columns and merge them into a selectedColumns table
  selectedColumns <- cbind(data$colName1, data$colName2)
  
  
  user1194: You can use GSA.read.gmt function from GSA package. The following code can be used to convert the file to a dataframe. Just ignore the warnings.
  Original_response
  library(GSA)
  data <-  GSA.read.gmt("c5.all.v6.2.symbols.gmt")
  gene_names <- unlist(data$genesets, use.names=FALSE)
  your_dataframe <- cbind(data$geneset.names,gene_names)
  colnames(your_dataframe) <- c("Pathways","Genes")
  mydataframe <- as.data.frame(your_dataframe)
  head(mydataframe)
                                                 Pathway   Gene
  1            GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION POLR2C
  2                           GO_CARDIAC_CHAMBER_DEVELOPMENT POLR2J
  3 GO_DNA_DEPENDENT_DNA_REPLICATION_MAINTENANCE_OF_FIDELITY  CTDP1
  4                                      GO_CIRCADIAN_RHYTHM   RDBP
  5              GO_PHOSPHATIDYLSERINE_ACYL_CHAIN_REMODELING COBRA1
  6                               GO_SPINAL_CORD_DEVELOPMENT   RSF1
  
  Edited_response
  You can use the code given below to achieve your desired output:
  library(GSA)
  data <-  GSA.read.gmt("c5.all.v6.2.symbols.gmt")
  len_vec=c()           # Now create a vector for containing the length of genes at each position
  len_vec[1] = 3
  for(i in 1:length(data$genesets)){len_vec[i] <- c(length(data$genesets[[i]]))}
  pathway_vec <- unlist(Vectorize(rep.int)(data$geneset.names, len_vec),use.names = FALSE) # Now create a vector for all the pathways in the data 
  desired_df <- as.data.frame(cbind(pathway_vec,unlist(data$genesets,use.names = FALSE))) # This gives your desired dataframe
  head(desired_df)
                                      Pathway      Gene
  1 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION POLR2C
  2 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION POLR2J
  3 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION  CTDP1
  4 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION   RDBP
  5 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION COBRA1
  6 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION   RSF1
  
  
  user1369: Ok. Answering my own question.
  I did this way. And I got the output I want.
  install.packages("msigdbr")
  library(msigdbr)
  
  m_df = msigdbr(species = "Homo sapiens", category = "C5")
  head(m_df)
  
  Output:
  gs_name gs_id gs_cat gs_subcat human_gene_symb~ species_name entrez_gene
    <chr>   <chr> <chr>  <chr>     <chr>            <chr>              <int>
  1 GO_14_~ M184~ C5     MF        AANAT            Homo sapiens          15
  2 GO_14_~ M184~ C5     MF        AKT1             Homo sapiens         207
  3 GO_14_~ M184~ C5     MF        ARRB2            Homo sapiens         409
  4 GO_14_~ M184~ C5     MF        BAD              Homo sapiens         572
  5 GO_14_~ M184~ C5     MF        DAB2IP           Homo sapiens      153090
  6 GO_14_~ M184~ C5     MF        DDIT4            Homo sapiens       54541
  # ... with 2 more variables: gene_symbol <chr>, sources <chr>
  
  found this solution from here https://cran.r-project.org/web/packages/msigdbr/vignettes/msigdbr-intro.html
  
original_text: 1369: <p>I downloaded c5: gene ontology gene sets file from <a href="http://software.broadinstitute.org/gsea/downloads.jsp" rel="nofollow noreferrer">http://software.broadinstitute.org/gsea/downloads.jsp</a></p>
  
  <p>I opened the "c5.all.v6.2.symbols.gmt" file in csv format and It looks like below:</p>
  
  <p><a href="https://i.stack.imgur.com/3bkVE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3bkVE.png" alt="enter image description here"></a></p>
  
  <p>I want to convert the .gmt file into a dataframe. And it should look like below:</p>
  
  <p><a href="https://i.stack.imgur.com/4f5qp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4f5qp.png" alt="enter image description here"></a></p>
  
  <p>can anyone say how I can do that. Thanq</p>
   3119: <p>You can import the csv file as a table. This does not require further libraries:</p>
  
  <pre><code>#you're reading a csv file, using tab as field separator and considering the first line as the headers of the data table
  data &lt;- read.csv(filename, sep="\t", header=TRUE)
  </code></pre>
  
  <p>then what you need are just two columns of your <strong>data</strong>:</p>
  
  <pre><code>colnames(data) #will give you the names of the columns that can be accessed
  #to access two columns and merge them into a selectedColumns table
  selectedColumns &lt;- cbind(data<span class="math-container">$colName1, data$</span>colName2)
  </code></pre>
   1194: <p>You can use GSA.read.gmt function from <a href="https://cran.r-project.org/web/packages/GSA/GSA.pdf" rel="nofollow noreferrer">GSA</a> package. The following code can be used to convert the file to a dataframe. Just ignore the warnings.</p>
  
  <p><strong>Original_response</strong></p>
  
  <pre><code>library(GSA)
  data &lt;-  GSA.read.gmt("c5.all.v6.2.symbols.gmt")
  gene_names &lt;- unlist(data<span class="math-container">$genesets, use.names=FALSE)
  your_dataframe &lt;- cbind(data$</span>geneset.names,gene_names)
  colnames(your_dataframe) &lt;- c("Pathways","Genes")
  mydataframe &lt;- as.data.frame(your_dataframe)
  head(mydataframe)
                                                 Pathway   Gene
  1            GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION POLR2C
  2                           GO_CARDIAC_CHAMBER_DEVELOPMENT POLR2J
  3 GO_DNA_DEPENDENT_DNA_REPLICATION_MAINTENANCE_OF_FIDELITY  CTDP1
  4                                      GO_CIRCADIAN_RHYTHM   RDBP
  5              GO_PHOSPHATIDYLSERINE_ACYL_CHAIN_REMODELING COBRA1
  6                               GO_SPINAL_CORD_DEVELOPMENT   RSF1
  </code></pre>
  
  <p><strong>Edited_response</strong></p>
  
  <p>You can use the code given below to achieve your desired output:</p>
  
  <pre><code>library(GSA)
  data &lt;-  GSA.read.gmt("c5.all.v6.2.symbols.gmt")
  len_vec=c()           # Now create a vector for containing the length of genes at each position
  len_vec[1] = 3
  for(i in 1:length(data<span class="math-container">$genesets)){len_vec[i] &lt;- c(length(data$genesets[[i]]))}
  pathway_vec &lt;- unlist(Vectorize(rep.int)(data$</span>geneset.names, len_vec),use.names = FALSE) # Now create a vector for all the pathways in the data 
  desired_df &lt;- as.data.frame(cbind(pathway_vec,unlist(data$genesets,use.names = FALSE))) # This gives your desired dataframe
  head(desired_df)
                                      Pathway      Gene
  1 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION POLR2C
  2 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION POLR2J
  3 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION  CTDP1
  4 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION   RDBP
  5 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION COBRA1
  6 GO_POSITIVE_REGULATION_OF_VIRAL_TRANSCRIPTION   RSF1
  </code></pre>
   1369: <p>Ok. Answering my own question.</p>
  
  <p>I did this way. And I got the output I want.</p>
  
  <pre><code>install.packages("msigdbr")
  library(msigdbr)
  
  m_df = msigdbr(species = "Homo sapiens", category = "C5")
  head(m_df)
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>gs_name gs_id gs_cat gs_subcat human_gene_symb~ species_name entrez_gene
    &lt;chr&gt;   &lt;chr&gt; &lt;chr&gt;  &lt;chr&gt;     &lt;chr&gt;            &lt;chr&gt;              &lt;int&gt;
  1 GO_14_~ M184~ C5     MF        AANAT            Homo sapiens          15
  2 GO_14_~ M184~ C5     MF        AKT1             Homo sapiens         207
  3 GO_14_~ M184~ C5     MF        ARRB2            Homo sapiens         409
  4 GO_14_~ M184~ C5     MF        BAD              Homo sapiens         572
  5 GO_14_~ M184~ C5     MF        DAB2IP           Homo sapiens      153090
  6 GO_14_~ M184~ C5     MF        DDIT4            Homo sapiens       54541
  # ... with 2 more variables: gene_symbol &lt;chr&gt;, sources &lt;chr&gt;
  </code></pre>
  
  <p>found this solution from here <a href="https://cran.r-project.org/web/packages/msigdbr/vignettes/msigdbr-intro.html" rel="nofollow noreferrer">https://cran.r-project.org/web/packages/msigdbr/vignettes/msigdbr-intro.html</a></p>
  