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
en:data_import_examples [2019/01/21 00:29]
David Zelený [Import directly from Excel (*.xls or *.xlsx) file]
en:data_import_examples [2019/02/03 16:21]
David Zelený [Import directly from Excel (*.xls or *.xlsx) file]
Line 99: Line 99:
 Note that in the function ''​download.file''​ it is important to specify the argument ''​mode = '​wb'''​ (on Windows, if the argument ''​mode''​ is not set up, the type of the file will be determined from the file extension; in case of *.xls and *.xlsx files R would attempt to download these files as plain text, but in fact these files need to be downloaded as binaries). Note that in the function ''​download.file''​ it is important to specify the argument ''​mode = '​wb'''​ (on Windows, if the argument ''​mode''​ is not set up, the type of the file will be determined from the file extension; in case of *.xls and *.xlsx files R would attempt to download these files as plain text, but in fact these files need to be downloaded as binaries).
  
-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 is often not handy for analysis ​of community ecology data since most of the functions ​used for numerical analysis here use data in standard ''​data.frame''​ format with rownames indicating ​plots ID. 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 (it creates ''​tibble''​ with rownames, which can be used in (most) functions accepting data.frame)
  
 ==== Import *.RData file ==== ==== Import *.RData file ====
en/data_import_examples.txt · Last modified: 2019/02/03 16:21 by David Zelený