Data Structures in R

Most functions and graphs will require information in a data frame structure. However, this differs by package so conversions might be necessary.

1) Data Frame

df <- data.frame(id = letters[1:10], x = 1:10, y = 11:20)

class(df) # "data.frame"


2) Matrix

matrix <- matrix(nrow = 2, ncol = 2)


class(matrix) # "matrix" "array"

3) Lists

list <- list(1, "a", TRUE, 1+4i)


class(list) # "list"

is.list(list) # TRUE

Data Structure Conversions

Convert Dataframe to Matrix

df.matrix <- as.matrix(data.frame)

class(df.matrix) # "matrix" "array"

Convert Matrix to Dataframe

matrix.df <- data.frame(matrix)

class(matrix.df) # "data.frame"

Convert Dataframe to List

Convert List to Dataframe

Convert Matrix to List

Convert List to Matrix


Sabalico Logo
Sabali Mail Logo
Domain Search Logo
Test Speed Logo
Website On Logo
Page Load Logo
Code Editor Logo
Format Code Logo
HTML Validator Logo
CSS Validator Logo
ASCII Table Logo
HTML Symbols Logo
Emoji Symbols Logo
Encode File Logo
Sitemap Generator Logo
Generator Password Logo
QR Code Generator Logo
Barcode Generator Logo
Online Sign Logo
Dictionary Online Logo
Counter Word Logo
Text Convert Logo
Lorem Ipsum Generator Logo
Sprite Sheet Logo
Edit Picture Logo
Resize Image Logo
Image Compress Logo
Image Color Logo
Image Crop Logo
Combine Images Logo
Favicon Generator Logo
Color Palette Logo
Color Picker Logo
Color Mix Logo
Color Convert Logo
CSS Gradient Logo
To-Do List Logo
Calendar Free Logo
Generator Meme Logo
Word Spinner Logo
Phone Country Logo
Sabalytics Logo
Senty Logo
World Map Logo
SEO Guide Logo
Keyword Tool Logo
What is my IP Logo
My Device Logo
My Browser Logo
My Location Logo
Time Zone Logo
Day Map Logo
My Weather Logo
My Galaxy Logo
The Moon Logo
Periodic Table Logo
rStatistics Logo
Unit Convert Logo
Data Convert Logo
Coordinate Converter Logo
Temperature Convert Logo
2020 Election Logo
Sabali Finance Logo
Currency Convert Logo
Free Calculator Logo
Finance Calculator Logo
Loan Calculator Logo
Calculator Mortgage Logo
Stock Calculator Logo
Bond Calculator Logo
Tax Calculator Logo
Tip Calculator Logo
Gas Mileage Logo
History of Humanity - History Archive Logo
History of Humanity - History Mysteries Logo
History of Humanity - Ancient Mesopotamia Logo
History of Humanity - Egypt History Logo
History of Humanity - Persian Empire Logo
History of Humanity - Greek History Logo
History of Humanity - Alexander the Great Logo
History of Humanity - Roman History Logo
History of Humanity - Punic Wars Logo
History of Humanity - Golden Age of Piracy Logo
History of Humanity - Revolutionary War Logo
History of Humanity - Mafia History Logo