This is a test version of Biostars. For the public version, visit https://www.biostars.org.
change in the structure and the data types of the data frame after the transposition by R

Hi,

I have a large gene expression dataset in Excel/CSV file, I transposed it by R function (switched columns and rows):

a <- read.table(file.csv,sep="\t")

b <- t(a)

now how to change in the structure and the data types of the data frame after the transposition?

transpose data

What do you mean by change in the structure and the data types? What happens when you transpose and what would you like to change to?

I want rows become columns and columns become rows,but the output does not have the frame of table(I mean there is not rows and columns),it is only one long row after transposition.

1 answer

If it's a csv file, I think you are importing it wrong.

Try this:

a <- read.csv("file.csv", sep=",", header=T)
b <- as.data.frame(t(a))

a bit of cleanup after the steps above:

names(b) = as.character(unlist(b[1,]))
b = b[-1,]

Log in to answer this question.