Question: Excel file Import to R
0
gravatar for Edalat
3.0 years ago by
Edalat30
Edalat30 wrote:

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 modified 3.0 years ago • written 3.0 years ago by Edalat30

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 written 3.0 years ago by WouterDeCoster41k
2
gravatar for TriS
3.0 years ago by
TriS3.9k
United States, Buffalo
TriS3.9k wrote:

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 written 3.0 years ago by TriS3.9k
2
gravatar for Antonio R. Franco
3.0 years ago by
Spain. Universidad de Córdoba
Antonio R. Franco4.2k wrote:

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 modified 3.0 years ago • written 3.0 years ago by Antonio R. Franco4.2k
1

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

ADD REPLYlink written 3.0 years ago by ddiez1.8k
1
gravatar for ddiez
3.0 years ago by
ddiez1.8k
Japan
ddiez1.8k wrote:

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 modified 3.0 years ago • written 3.0 years ago by ddiez1.8k
0
gravatar for Brice Sarver
3.0 years ago by
Brice Sarver3.1k
United States
Brice Sarver3.1k wrote:

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 modified 3.0 years ago • written 3.0 years ago by Brice Sarver3.1k
0
gravatar for Sparrow_kop
3.0 years ago by
Sparrow_kop210
China
Sparrow_kop210 wrote:
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 written 3.0 years ago by Sparrow_kop210
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 3571 users visited in the last hour