1 / 13

BÁO CÁO KHAI KHOÁNG DỮ LIỆU Chủ đề : NHẬP XUẤT DỮ LIỆU TRONG R

BÁO CÁO KHAI KHOÁNG DỮ LIỆU Chủ đề : NHẬP XUẤT DỮ LIỆU TRONG R. Giáo viên giảng dạy : Phạm Gia Tiến Sinh viên thực hiện : Hồ Như Thủy MSSV: LT11778. Nội dung báo cáo. Nhập dữ liệu trong R 1.1 Nhập dữ liệu bằng dòng lệnh: c() 1.2 Nhập dữ liệu trực tiếp: edit(data.frame())

meir
Télécharger la présentation

BÁO CÁO KHAI KHOÁNG DỮ LIỆU Chủ đề : NHẬP XUẤT DỮ LIỆU TRONG R

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BÁO CÁO KHAI KHOÁNG DỮ LIỆUChủđề:NHẬP XUẤT DỮ LIỆU TRONG R Giáoviêngiảngdạy: PhạmGiaTiến Sinhviênthựchiện: HồNhưThủy MSSV: LT11778

  2. Nội dung báo cáo • Nhập dữ liệu trong R 1.1 Nhập dữ liệu bằng dòng lệnh: c() 1.2 Nhập dữ liệu trực tiếp: edit(data.frame()) 1.3 Nhập dữ liệu từ 1 textfile: read.table 1.4 Nhập dữ liệu từ Excel: read.csv Package RODBC 1.5 Nhập dữ liệu từ 1 SPSS: read.spss • Xuất dữ liệu trong R

  3. 1. 1 Nhập dữ liệu bằng dòng lệnh: c() • Cúpháp: Tênbiếnlưudữliệu <-c(phầntử 1, phầntử 2, …, phầntử n) Tênbiếnlưutrữ <-data.frame(thamsố 1, thamsố 2, …, thamsố n) setwd(“đườngdẫnlưu file”) save(tênbiến 2 , tênfile.rda) • Vídụ: chúng ta có số liệu về độ tuổi và insulin cho 10 bệnh nhân và muốn nhập vào R

  4. 1. 1 Nhậpdữliệubằngdònglệnh: c()

  5. 1.2 Nhậpdữliệutrựctiếp: edit(data.frame())Cúpháp: Tênbiến<-edit(data.frame())Vídụ: r<-edit(data.frame())

  6. 1.3 Nhậpdữliệutừ 1 textfile: read.table

  7. 1.4 Nhậpdữliệutừ Excel: read.csvLưu file excel dướidạngcsvVídụ: nhậpsốliệucủa file excel.csv

  8. 1.4 Nhậpdữliệutừ Excel:Cáchkhác:

  9. Package RODBC • Gói RODBC cung cấp một giao diện để các nguồn cơ sở dữ liệu hỗ trợ một giao diện ODBC. • RODBC chạy trên Unix / Linux, Windows và OS X, và gần như tất cả các hệ thống cơ sở dữ liệu cung cấp hỗ trợ cho ODBC: Microsoft SQL Server, Access, MySQL, PostgreSQL, Oracle và IBM DB2 trên Windows và MySQL, Oracle, PostgreSQL và SQLite trên Linux.

  10. 1.5 Nhập dữ liệu từ 1 SPSS: read.spss •  Phần mềm thống kê SPSS lưu dữ liệu dưới dạng “sav”. • Sử dụng library(foreign) • Ví dụ: Nhập số liệu từ file testo.sav library(foreign) setwd(“d:/giaotrinh/r/data”) testo<-read.spss(“testo.sav”,to.data.frame=TRUE)

  11. 2. Xuấtdữliệutrong R • Xuấtradạng file text write.table(tập tin, “đườngdẫnlưu”, sep=“\t”) • Xuấtradạng file excel library(xlsReadWrite) write.xls(tập tin, “D:/taptin.xls”) • Xuấtradạng file spss library(foreign) write.foreign(taptin,”D:/taptin1.txt”, “E:/taptin.sps”, package=“SPSS”)

  12. TÀI LIỆU THAM KHẢO • http://vietsciences.free.fr/khaocuu/nguyenvantuan/bieudoR/ch3-nhapdulieu.htm • http://cran.r-project.org/doc/manuals/r-release/R-data.html

  13. CẢM ƠN THẦY VÀ CÁC BẠN ĐÃ CHÚ Ý LẮNG NGHE

More Related