Can I download tables for statistic-tutorials and under which link?

Search tables used in R tutorials for data analysis and statistics. Can I download tables somewhere and under which link?

Hi,

Could you provide some more information on what type of data you like to load in R and where you want to find it?

There are several ways people online can provide you with a data set:

Data sets from R or packages
When you install R or certain packages, they come with tutorial data sets incorporated. You can simply load those by using the data() function and provide the name of the data set you want.

#Load the iris data set (comes with R, no package installation needed)
load(iris)
head(iris)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa
6          5.4         3.9          1.7         0.4  setosa

#If the data set comes with a package, you have to load the library first
library(ggplot2)
data(diamonds)
head(diamonds)
  carat cut       color clarity depth table price     x     y     z
  <dbl> <ord>     <ord> <ord>   <dbl> <dbl> <int> <dbl> <dbl> <dbl>
1 0.23  Ideal     E     SI2      61.5    55   326  3.95  3.98  2.43
2 0.21  Premium   E     SI1      59.8    61   326  3.89  3.84  2.31
3 0.23  Good      E     VS1      56.9    65   327  4.05  4.07  2.31
4 0.290 Premium   I     VS2      62.4    58   334  4.2   4.23  2.63
5 0.31  Good      J     SI2      63.3    58   335  4.34  4.35  2.75
6 0.24  Very Good J     VVS2     62.8    57   336  3.94  3.96  2.48

#To get a list of all sets that come with R
data()

#To get a list of all sets that come with packages
data(package = .packages(all.available = TRUE))

#To get a list of all sets from a specific package
data(package = "ggplot2")

Data sets provided for download
These datasets will be provided by the person who writes the tutorial, and come in a format like csv, txt, xlsx, ... You can download them and use the appropriate read function in R to load the data

#Load data you stored in a specific folder
myData = read.csv("pathToData/myData.csv")

Data sets generated in R
People can also provide data as code that you have to copy paste into R and then run it

#Data generated by R code
myData = data.frame(x = 1:10, y = runif(10), z = LETTERS[1:10])

#Or provided in full 
myData = data.frame(
           x = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L),
           y = c(0.762549093691632, 0.225016493583098, 0.833928090520203,
                 0.919807797530666, 0.600916502764449, 0.0585864547174424,
                 0.789303291356191, 0.153551900526509, 0.524553221883252,
                 0.475062759593129),
           z = as.factor(c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"))
)

Hope this helps,
PJ

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.