Našimi kurzy prošlo více než 10 000+ účastníků
2 392 ověřených referencí účastníků našich kurzů. Přesvědčte se sami
Author: Žaneta Vaníčková
This article describes how to simply load data from Excel table to R script environment.
We´re going to use these two commands:
data <- readClipboard() data <- read.table(file = 'clipboard', sep = "\t", header = TRUE, stringsAsFactors = FALSE)
We are getting the data for R analysis very often in .xlsx files. There are many packages enabling us to export / import to / from Excel to R. But, anyway, getting data from Excel isn´t too easy usually. Some users are saving the data from Excel to .csv and importing after.
So in this tutorial, we will show how to get the data from Excel easily – using the Windows clipboard.
Open R studio. Now you need to paste. This can be done by this command, importing data from Windows clipboard:
data <- readClipboard() head(data)
Head() function shows first few rows only.
> data <- readClipboard() > > head(data) [1] "Brand\tModel\tPrice\tColor\tOn Stock from:" "Alfa Romeo\tSpider\t 207 000 Kč \tSilver\t08.10.2017" [3] "Fiat\tCoupe\t 187 000 Kč \tBlue\t08.10.2017" "Citroen\tPluriel\t 44 000 Kč \tSilver\t09.10.2017" [5] "Citroen\tPluriel\t 208 000 Kč \tSilver\t10.10.2017" "Alfa Romeo\t156\t 280 000 Kč \tSilver\t10.10.2017"
To see complete data, write this instead:
data <- readClipboard() data
Columns in Excel are separated by tab (\t). The readClipboard() function itself can´t work with delimiter, it is mostly mused for quick import of row data. So to load of data the read.table() function should be used.
data <- read.table(file = 'clipboard', sep = "\t", header = TRUE, stringsAsFactors = FALSE) head(data)
Brand Model Price Color On.Stock.from. 1 Alfa Romeo Spider 207 000 Kč Silver 08.10.2017 2 Fiat Coupe 187 000 Kč Blue 08.10.2017 3 Citroen Pluriel 44 000 Kč Silver 09.10.2017 4 Citroen Pluriel 208 000 Kč Silver 10.10.2017 5 Alfa Romeo 156 280 000 Kč Silver 10.10.2017 6 Skoda Favorit 30 000 Kč Red 11.10.2017
Explanation of input parameters of read.table() function:
Comments are closed.
2 392 ověřených referencí účastníků našich kurzů. Přesvědčte se sami
Pište kdykoliv. Odpovíme do 24h
© exceltown.com / 2006 - 2023 Vyrobilo studio bARTvisions s.r.o.
Democrats Ready Impeachment Charge Against Trump for Inciting Capitol Mob
Speaker Nancy Pelosi threatened decisive action against the president for his role in the insurrection against Congress if he refused to resign.