Biostar Beta. Not for public use.
Excel file Import to R
0
Entering edit mode
3.1 years ago
Edalat • 30

Hi All, I am trying to import data to R, my data has 28031 rows, I want to change rownames to list of genes, what should I do?

     [,1]  [,2]  [,3]

Fkh2 0.141 0.242 0.342

Swi5 0.224 0.342 0.334

Sic1 0.652 0.682 0.182

I found this function, but it is not possible to use for 28031 genes!!

Convert to matrix as it is that you wanted:

test2<-as.matrix(test1)

colnames(test2)<-NULL

genelist<-c("Fkh2","Swi5","Sic1")

 rownames(test2)<-genelist

test2
R • 1.3k views
ADD COMMENTlink
0
Entering edit mode

Hello ED!

It appears that your post has been cross-posted to another site: https://support.bioconductor.org/p/88866/

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD REPLYlink
2
Entering edit mode
17 months ago
TriS ♦ 3.8k
United States, Buffalo

where is your list of genes right now?

library(gdata)
xls_file <- read.xls("myFIle.xls",sheet=1)
rownames(xls_file) <- myVectorWithGeneNames

you don't need to convert to matrix more info here on r-bloggers

ADD COMMENTlink
2
Entering edit mode
16 months ago
Spain. Universidad de Córdoba

I have found very useful for my novice students to use the integrated functions included in RStudio to import data that ddiez mention

This provides not only a GUI interface to import data, but also a Data preview. It will allow you to convert the data name column into row names automatically. You will be alerted if your numeric data will be converted to character or not

The newest preview version 1.0.44 can import, in addition to the classical csv and excel files, SPSS, SAS and Stata files. This is accessed from the File / Import Dataset menu file

The nice thing is that it also provide the R code to do it, so you can learn from the experience

ADD COMMENTlink
1
Entering edit mode

Good point about the R code used to import the data- its a great way to learn.

ADD REPLYlink
1
Entering edit mode
16 months ago
ddiez ♦ 1.7k
Japan

Another option to read XLS files into R is the readxl package. If you are using the preview version of RStudio this is integrated in the GUI.

ADD COMMENTlink
0
Entering edit mode
16 months ago
Brice Sarver ♦ 2.6k
United States

I'm assuming you know what gene corresponds to each row. If they're in order, do something like:

a <- read.table("your_table_with_values.txt", stringsAsFactors=FALSE)
b <- [this is going to depend on what format your gene names are in. 
perhaps you could read as a table and take a single column, or use scan() to read
a single line]
#all you need to do is cbind() them:
d <- cbind(b, a)
ADD COMMENTlink
0
Entering edit mode
21 months ago
Sparrow_kop • 200
China
library(xlsx)
DT <- read.xlsx(file='you excel file')

you can use this package to read excel file and convert to data frame in R .

ADD COMMENTlink

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.3.1