0

This is my first post and I not very familiar with R and just trying to help my wife.

We have an issue where we need a data set in Matrix format for a certain package (rain) that finds significance in circadian data sets.

When looking at the example data set given it is in a Matrix format and looks like this:

      T1 T2 T3
GENEA 12 13 15
GENEB 4  6  7
GENEC 3  8  9

Our data is in a CSV file when import it and try to get it looking like a matrix it looks like this:

      X1   T1 T2 T3
   1 GENEA 12 15 15
   2 GENEB 4  7  7
   3 GENEC 3  8  9

R fills in the A1 with X1 and also adds row numbers in front. So once we run the package it errors out and says the matrix has a non binary object in the list. When we skip the column X1 the package succeeds, but now we're missing the genes. I have tried several ways to convert our data to a matrix (as.matrix) or to rename the first column to an empty space but it hasn't worked so far.

Thank you for your help!

  • 1
    When reading the CSV file, try with `read.csv(..., row.names = 1)`. – Maurits Evers Mar 19 '18 at 12:17
  • 1
    After reading the CSV-file you (normally) have a dataframe, e.g. `df`. If you want to change the structure (to somewhat similar to the matrix you mentioned first) you can do: `rownames(df) <- df$X1; df$X1 <- NULL` – jogo Mar 19 '18 at 12:20
  • I went ahead and ran rownames(df) <- df$X1; df$X1 <- NULL, it does create a matrix but it looks now has ` V1 V2 V3` as row names and also the first one with numbering 1,2,3.. is still there. – omuelle1 Mar 19 '18 at 15:06
  • So, make your example [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), i.e. edit your question. – jogo Mar 19 '18 at 19:57

0 Answers0