Skip to content

ds5110/rdata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rdata

Data converted from R to CSV using write.table() and write.csv()

  • write.table() -- rdocumentation.org
  • write.csv() is also documented at this link. But write.table() makes more sense.
  • write.csv() and write.csv2() are wrappers for write.table() and according to the documentation...
    • "These wrappers are deliberately inflexible:
    • they are designed to ensure that the correct conventions are used to write a valid file.
    • Attempts to change append, col.names, sep, dec or qmethod are ignored, with a warning."

ISLR2 Wage data

Wage is a typical example of an ISLR2 dataset...

conda activate r_env
R
> install.packages("ISLR2")
> library(ISLR2)
> summary(Wage)
> write.csv(Wage, 'wage.csv', row.names=FALSE)
> quit()
conda deactivate

NCI60 dataset

NCI60 microarray data -- expression levels of 6830 genes for 64 cancer cell lines

  • In R, the NCI60 dataset is a list containing two elements: data and labs.
  • NCI60$data is a 64-by-6830 matrix of the gene-expression values
  • NCI60$labs is a 64-element vector of cancer-cell types (labels)
  • These two objects are saved to separate CSV files as follows...
library(ISLR2)
write.table(NCI60$labs, 'NCI60labs.csv', row.names=FALSE, col.names=FALSE)
write.table(NCI60$data, 'NCI60data.csv', sep=",", row.names=FALSE, col.names=FALSE)

Install R & ISLR2

conda create --name r_env
conda activate r_env
conda install -c conda-forge r-base
conda install -c conda-forge r-sjstats
conda deactivate

Jane Austen's books

$ conda activate r_env
$ R
> library(janeaustenr)
> write.csv(austen_books(), 'janeausten.csv', row.names=FALSE)

babynames

I had to gzip the CSV because it was too large for github (57M)

$ R
> install.packages("babynames")
> library(babynames)
> write.csv(babynames, "babynames.csv", row.names=FALSE)
> quit()
gzip babynames.csv

nycflights13 dataset

$ conda activate r_env
$ R
> library(nycflights13)

write.table(airlines, file = "airlines.csv", sep = ",", row.names=FALSE, quote=FALSE, na="", qmethod = "double")
write.table(airports, file = "airports.csv", sep = ",", row.names=FALSE, quote=FALSE, na="", qmethod = "double")
write.table(planes,   file = "planes.csv",   sep = ",", row.names=FALSE, quote=FALSE, na="", qmethod = "double")
write.table(weather,  file = "weather.csv",  sep = ",", row.names=FALSE, quote=FALSE, na="", qmethod = "double")
write.table(flights,  file = "flights.csv",  sep = ",", row.names=FALSE, quote=FALSE, na="", qmethod = "double")

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •