change in the structure and the data types of the data frame after the transposition by R
1
0
Entering edit mode
8.0 years ago
Edalat ▴ 30

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 • 2.2k views
ADD COMMENT
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
1
Entering edit mode
8.0 years ago
berge2015 ▴ 110

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,]
ADD COMMENT

Login before adding your answer.

Traffic: 1631 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6