Data in RStudio import

SPSS, text files or spreadsheets as the data source Data in RStudio import

Who processed using the R programming language, data, can create records directly. In most cases, but the data will be imported from other sources. We show the procedure and the ways.

Companies

Successfully to RStudio imported data.Successfully to RStudio imported data.

(Image: RStudio / Joos)

There are several ways to import data into R. In many cases, a CSV or XLS files are used for the Import. In General, it is recommended that the source to the save files for Import into a directory on the computer that belongs to the corresponding R-project. The ability to verify the data base at any time, or re-read if necessary.

Packages for function calls to prepare

Data with R as a function call import, wherein the Package “readr” is required. Various functions are available:

Pictures gallery

Photo gallery with 8 pictures

Thus, the commands may be used from this Package, it must first be integrated and loaded. The explicit Installation of readr can be done via the following command.

install.packages("readr")

A better starting point is to install the complete Data Science package Tidyverse, this is achieved similarly with the command:

install.packages("tidyverse")

The functions are then loaded within the R Session, by means of a “library(tidyverse)” or “library(readr). Data can be imported via the graphical user interface, detects RStudio the missing packages and allows for their Installation on the GUI. Also the two mentioned Packages include.

RStudio can Excel spreadsheets (*.xls, *.xlsx) without an existing Excel-Installation open and view. When Excel tables are imported, must be the Package “readxl” loaded. The Code for Importing data from an Excel spreadsheet, for example, looks as follows:

library(readxl)
Einnahmen_Ausgaben_Tabelle <- read_excel("C:/Users/User /Desktop/Einnahmen-Ausgaben Tabelle.xlsx")
View(Einnahmen_Ausgaben_Tabelle)

Import data into RStudio using the graphical interface

In most cases, it is the one-time Import of data easier and more effective when the graphical interface is used by RStudio to import data. The advantage is that the data will be imported but previously also displayed. Who need to import data more frequently, is operated with a script, of course, better, because of the processes can be automated.

The Import options in RStudio can be found via the menu item “FileImport Dataset” to. Here, custom menu, you can find points for the Import from Excel spreadsheets, Text files, or other source data. On the tab “Environment” can also be imported. Here, the same options are available from the button of “Import Dataset” available, as is the case with “FileImport Dataset”.

In part, the current versions of the required Packages for the Import of data is still needed, for example, “haven” and “Rcpp”. These are not installed, the RStudio this and also enables the Installation.

Import taxes and run

If the data are selected for Import, shows RStudio the scanned data in the “Data Preview”. In the lower area of the settings can be selected for the import process. On the right side of the source code, you can see that the data will be imported.

An Option is changed, you’ll see the effects in the “Data Preview”. In addition, the RStudio shows “Code Preview” of the relevant Code. For example, if the Option “use First Row as Names”, it reads in R the data of the first row is not active.

What are the options for the RStudio to Import displays depends on which data is to be imported. When you Import SPSS data sets (Statistical Package for Social Science) can be selected, for example, only the Name. Depending on the imported data set, the data obtained are also different attributes.

On the “Import” button will read the data to be loaded. On the tab “Environment” is in “Data” to see the name of the Data Frames. This is the newly imported data. The Name is specified as an Option when you Import the data. For the Import, the Code is used, which were displayed in the “Code Preview” before.

SPSS-data import

Who wants to work in the field of SPSS with the Open-Source Software, can work to Create the import file using GNU PSPP. GNU PSPP is a Open Source program for statistical analysis of data. The Tool is SPSS is a free replacement for the proprietary program IBM. GNU PSPP is available for Windows, Linux and macOS available.

With the Tool SAV files that can be imported by R via RStudio. As a result, designers have the option of customizing data before they can be imported into RStudio. For the Import SPSS files, you will need the Package “haven”. This is not available on your Computer, you can clear it using the following command in RStudio imported downloaded:

install.packages("haven")

SPSS-files can be imported, for example, with the following Code:

library(haven)
DatenAusSPSS_spss <- read_sav("data/spss-daten.sav")

Data store and import

With RStudio, it is also possible to edit data from a Data Frame and then save as a RData file. These files can be in the RStudio reloaded. The data is stored in a frame with the function “save()” The Syntax for this is:

save(<Name des Frames>, file = "<Pfad zur RDA-Datei>")

Example:

save(Einnahmen_Ausgaben_Tabelle, file = "daten.rda")

The files, in turn, can be used with the function “load()” is loaded. The Syntax in this example:

load(file = "daten.Rda")

(ID:47067341)

Ready to see us in action:

More To Explore

IWanta.tech
Logo
Enable registration in settings - general
Have any project in mind?

Contact us:

small_c_popup.png