Hướng dẫn convert excel to matrix in r - chuyển đổi excel thành ma trận trong r

David L Carlson Dcarlson tại Tamu.edu Mon tháng 7 23 17:47:50 CEST 2012 DCARLSON tại Tamu.edu Mon 23 17:47:50 CEST 2012
DCARLSON tại Tamu.edu Mon 23 17:47:50 CEST 2012
  • Thông báo trước: [R] Nhập tệp Excel - Định dạng Ma trận
  • Thông báo tiếp theo: [R] Kích thước bộ nhớ
  • Tin nhắn được sắp xếp bởi: [Ngày] [Chủ đề] [Chủ đề] [Tác giả] [ date ] [ thread ] [ subject ] [ author ]
Use read.table[] with the row.names= argument set to the column number that
represents the row.names [presumably 1] and then convert the data.frame to a
matrix:

A  From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of arun
> Sent: Saturday, July 21, 2012 8:16 PM
> To: biostat1
> Cc: R help
> Subject: Re: [R] Excel file Import - to Matrix format
> 
> Hello,
> 
> Try this:
> 
> You can use the read.table with sep="," if it is comma separated to
> read the file.
> 
> test1  #Read data
> test1
>  #   V1    V2    V3
> #1 0.141 0.242 0.342
> #2 0.224 0.342 0.334
> #3 0.652 0.682 0.182
> 
> 
> #Convert to matrix as it is that you wanted
> test2 colnames[test2] genelist rownames[test2] test2
> #      [,1]  [,2]  [,3]
> #Fkh2 0.141 0.242 0.342
> #Swi5 0.224 0.342 0.334
> #Sic1 0.652 0.682 0.182
> 
> #2nd case: As in your example,
> test1 
> test2 colnames[test2] genelist rownames[test2] test2
> #      [,1]  [,2]  [,3]
> #Fkh2 0.141 0.242 0.342
> #Swi5 0.224 0.342 0.334
> #Sic1 0.652 0.682 0.182
> 
> A.K.
> 
> 
> ----- Original Message -----
> From: biostat1 
> To: r-help at r-project.org
> Cc:
> Sent: Saturday, July 21, 2012 7:29 PM
> Subject: [R] Excel file Import - to Matrix format
> 
> Hi,
> 
> New to R. Need a bit of help. Thanks
> 
> I am trying to import data from Excel file. The package I am trying to
> use
> requires data in Matrix format.
> 
> Excel -> R Matrix with the constraint that the very first column in
> Excel
> file should became the names for rows of the matrix.
> 
> Example. Data has 1000 rows and 11 columns.
> 1st column is the names of Genes
> 10 coulmns of numerical data.
> 
> I need to read this into R.
> it should be a 1000 [row] X 10 Column [Matrix]
> 1st column of Excel file becomes name of the rows.
> 
> I am experimenting with reading as data frame [as I am unable to
> find any info on reading into matrix]  split the data frame, etc.
> 
> Thanks truly appreciate your help.
> 
> What I need: //r.789695.n4.nabble.com/file/n4637332/thisWorks2.png
> 
> //r.789695.n4.nabble.com/file/n4637332/doesNotWork1.png
> 
> 
> 
> --
> View this message in context: //r.789695.n4.nabble.com/Excel-file-
> Import-to-Matrix-format-tp4637332.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> //stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide //www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> //stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide //www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

  • Thông báo trước: [R] Nhập tệp Excel - Định dạng Ma trận
  • Thông báo tiếp theo: [R] Kích thước bộ nhớ
  • Tin nhắn được sắp xếp bởi: [Ngày] [Chủ đề] [Chủ đề] [Tác giả] [ date ] [ thread ] [ subject ] [ author ]
Thêm thông tin về danh sách gửi thư R-Help

Tôi có một tệp Excel với dữ liệu sau

Tôi muốn tạo một bảng ma trận ra khỏi vấn đề này, một cách nhanh chóng để thực hiện nó là gõ thủ công mã sau

table

Bài Viết Liên Quan

Chủ Đề