SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Importing Files in R
Codes are in Blue.
For Feedback Mail me: sharmakarishma91@gmail.com
Importing files
• To import different types of files in R, we must install and load
a foreign package. So, first you install and load foreign
package into R console window
• library(foreign)
For Feedback Mail me: sharmakarishma91@gmail.com
Excel File (XLS file)
• library(gdata) # load the gdata package
• help(read.xls) # documentation
• mydata = read.xls("mydata.xls") # read from first sheet
For Feedback Mail me: sharmakarishma91@gmail.com
Excel File (XLSX file)
• We have to first install the packages XLSX and XLSXJARS to
import XLSX file to R
Example Code:
• library(xlsx)
• library(xlsxjars)
• data1<-read.xlsx(“D:data1.xlsx”,1)
For Feedback Mail me: sharmakarishma91@gmail.com
CSV File
• One good trick to import CSV file
• file=read.csv(file.choose())
• You can directly import file using browse.
• Syntax:
read.csv(file, header = TRUE, sep = ",", quote=""", dec=".", fill
= TRUE, comment.char="", ...)
• mydata = read.csv("mydata.csv")
# read csv file
• mydata # print data frame
For Feedback Mail me: sharmakarishma91@gmail.com
SPSS FILE
• SPSS can be opened with the read.spss function from the
foreign package
• library(foreign) # load the foreign package
• help(read.spss) # documentation
• mydata=read.spss("myfile", to.data.frame=TRUE)
For Feedback Mail me: sharmakarishma91@gmail.com
Table File or TXT File
• mydata = read.table("mydata.txt") # read text file
• mydata # print data frame
For Feedback Mail me: sharmakarishma91@gmail.com
Package Selection
• It is always good to check the PDF file of the package and in
the packages PDF file check the dependencies of the Package
with other packages so that we can easily know which
packages will be required to call.
• Some commonly used packages
• Foreign- to import file
• Gdata- to import XLS file
• Xlsx, xlsxjars- to import XLSX file
• Attach()- to attach file before doing Regression.
For Feedback Mail me: sharmakarishma91@gmail.com
THANK YOU.
Reference: http://cran.r-project.org/
For Feedback Mail me: sharmakarishma91@gmail.com

Weitere ähnliche Inhalte

Andere mochten auch

Workshop for ss who own grades apr 11
Workshop for ss who own grades apr 11Workshop for ss who own grades apr 11
Workshop for ss who own grades apr 11poseidom123
 
Www.Power Point.Ro 753 Zafiri Cupidon
Www.Power Point.Ro 753 Zafiri CupidonWww.Power Point.Ro 753 Zafiri Cupidon
Www.Power Point.Ro 753 Zafiri Cupidonrumaniago
 
Jari Halonen WSOY
Jari Halonen WSOYJari Halonen WSOY
Jari Halonen WSOYVerkkosemma
 
инструкция перфект мани
инструкция перфект маниинструкция перфект мани
инструкция перфект маниtmty999
 
certificate_236 -Online Selling
certificate_236 -Online Sellingcertificate_236 -Online Selling
certificate_236 -Online SellingMuhammad Umair
 
Panada isi Sayuran
Panada isi SayuranPanada isi Sayuran
Panada isi Sayurandefidi
 

Andere mochten auch (12)

La web 2
La web 2La web 2
La web 2
 
Workshop for ss who own grades apr 11
Workshop for ss who own grades apr 11Workshop for ss who own grades apr 11
Workshop for ss who own grades apr 11
 
Mis datos
Mis datosMis datos
Mis datos
 
Www.Power Point.Ro 753 Zafiri Cupidon
Www.Power Point.Ro 753 Zafiri CupidonWww.Power Point.Ro 753 Zafiri Cupidon
Www.Power Point.Ro 753 Zafiri Cupidon
 
Jari Halonen WSOY
Jari Halonen WSOYJari Halonen WSOY
Jari Halonen WSOY
 
инструкция перфект мани
инструкция перфект маниинструкция перфект мани
инструкция перфект мани
 
Keila (gestion)
Keila (gestion)Keila (gestion)
Keila (gestion)
 
EUVeKACG
EUVeKACGEUVeKACG
EUVeKACG
 
certificate_236 -Online Selling
certificate_236 -Online Sellingcertificate_236 -Online Selling
certificate_236 -Online Selling
 
Panada isi Sayuran
Panada isi SayuranPanada isi Sayuran
Panada isi Sayuran
 
Sysadmin delight
Sysadmin delightSysadmin delight
Sysadmin delight
 
Catilina
CatilinaCatilina
Catilina
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Kürzlich hochgeladen (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Import files in r

  • 1. Importing Files in R Codes are in Blue. For Feedback Mail me: sharmakarishma91@gmail.com
  • 2. Importing files • To import different types of files in R, we must install and load a foreign package. So, first you install and load foreign package into R console window • library(foreign) For Feedback Mail me: sharmakarishma91@gmail.com
  • 3. Excel File (XLS file) • library(gdata) # load the gdata package • help(read.xls) # documentation • mydata = read.xls("mydata.xls") # read from first sheet For Feedback Mail me: sharmakarishma91@gmail.com
  • 4. Excel File (XLSX file) • We have to first install the packages XLSX and XLSXJARS to import XLSX file to R Example Code: • library(xlsx) • library(xlsxjars) • data1<-read.xlsx(“D:data1.xlsx”,1) For Feedback Mail me: sharmakarishma91@gmail.com
  • 5. CSV File • One good trick to import CSV file • file=read.csv(file.choose()) • You can directly import file using browse. • Syntax: read.csv(file, header = TRUE, sep = ",", quote=""", dec=".", fill = TRUE, comment.char="", ...) • mydata = read.csv("mydata.csv") # read csv file • mydata # print data frame For Feedback Mail me: sharmakarishma91@gmail.com
  • 6. SPSS FILE • SPSS can be opened with the read.spss function from the foreign package • library(foreign) # load the foreign package • help(read.spss) # documentation • mydata=read.spss("myfile", to.data.frame=TRUE) For Feedback Mail me: sharmakarishma91@gmail.com
  • 7. Table File or TXT File • mydata = read.table("mydata.txt") # read text file • mydata # print data frame For Feedback Mail me: sharmakarishma91@gmail.com
  • 8. Package Selection • It is always good to check the PDF file of the package and in the packages PDF file check the dependencies of the Package with other packages so that we can easily know which packages will be required to call. • Some commonly used packages • Foreign- to import file • Gdata- to import XLS file • Xlsx, xlsxjars- to import XLSX file • Attach()- to attach file before doing Regression. For Feedback Mail me: sharmakarishma91@gmail.com
  • 9. THANK YOU. Reference: http://cran.r-project.org/ For Feedback Mail me: sharmakarishma91@gmail.com