User Tools

Site Tools


en:data_import_examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
en:data_import_examples [2019/01/21 00:15]
David Zelený [Import directly from *.xls and *.xlsx file]
en:data_import_examples [2019/01/21 00:29]
David Zelený [Import directly from Excel (*.xls or *.xlsx) file]
Line 100: Line 100:
  
 The library ''​readxl''​ is a part of the ''​tidyverse''​ packages, and as such it does not use standard ''​data.frame''​ format for data frames, but unique ''​tibble''​ (as discussed above). One feature of ''​tibble''​ is that **it does not have rownames, and rownames are therefore imported as the first column of the data frame**. This may or may not be handy for future analysis since most of the functions we will use for numerical analysis here use data in standard ''​data.frame''​ format with rownames indicating plot IDs. To convert ''​tibble''​ into standard ''​data.frame'',​ use the function ''​as.data.frame'',​ and move the first column into the rownames of the newly created data frame (see above). Alternatively,​ there are functions like ''​[[https://​www.rdocumentation.org/​packages/​tibble/​versions/​1.4.2/​topics/​rownames|column_to_rownames]]''​ in the package ''​tibble''​ which can help you with that. The library ''​readxl''​ is a part of the ''​tidyverse''​ packages, and as such it does not use standard ''​data.frame''​ format for data frames, but unique ''​tibble''​ (as discussed above). One feature of ''​tibble''​ is that **it does not have rownames, and rownames are therefore imported as the first column of the data frame**. This may or may not be handy for future analysis since most of the functions we will use for numerical analysis here use data in standard ''​data.frame''​ format with rownames indicating plot IDs. To convert ''​tibble''​ into standard ''​data.frame'',​ use the function ''​as.data.frame'',​ and move the first column into the rownames of the newly created data frame (see above). Alternatively,​ there are functions like ''​[[https://​www.rdocumentation.org/​packages/​tibble/​versions/​1.4.2/​topics/​rownames|column_to_rownames]]''​ in the package ''​tibble''​ which can help you with that.
 +
 +==== Import *.RData file ====
 +Binary data storing the R object can be loaded into R using function ''​load''​. Download data {{https://​raw.githubusercontent.com/​zdealveindy/​anadat-r/​master/​data/​vltava.RData|vltava.RData}} to your computer and use:
 +
 +<code rsplus>
 +load ('​c:/​path/​to/​data/​folder/​vltava.RData'​)
 +</​code>​
 +
 +This should create the variable ''​vltava''​ in your Global environment (it will appear among variables), which is  alist of variables (see details [[en:​data:​vltava#​all_vltava_dataset_matrices_as_a_single_r_object_list_vltava|here]]). Do not assign the result to a new variable, it will not work (if you use ''​vltava.spe <- load ('​vltava.RData'​)'',​ the object ''​vltava.spe''​ will be assigned the character string ''​vltava'',​ not the data).
 +
 +Alternatively,​ ''​load''​ function can read directly data from website, if the URL link is wrapped by function ''​url'':​
 +<code rsplus>
 +load (url ('​https://​raw.githubusercontent.com/​zdealveindy/​anadat-r/​master/​data/​vltava.RData'​))
 +</​code>​
  
 ===== Import from cc! (cep) format ===== ===== Import from cc! (cep) format =====
en/data_import_examples.txt · Last modified: 2019/02/03 16:21 by David Zelený