Install Package

ส่วนใหญ่รายชื่อ packages ทั้งหมดใน CRAN R

# install packages
install.packages(c("readr", 
                   "readxl", 
                   "googlesheets4",
                   "jsonlite",
                   "dplyr",
                   "sqldf",
                   "RSQLite"))

# load library
library(readr)
library(readxl)
library(googlesheets4)
library(jsonlite)
library(dplyr)
library(sqldf)
library(RSQLite)

image.png

Read TextFile

id  name
1 ping
2 nut
3 kook
4 tarn

#load lib
library(readr)

studentdf <- read_table("student.txt")

View(studentdf)

Error

เผื่อใครลง R ที่คอมตัวเอง แล้วเจอ Error ตอนลง library(readr) 

error: compilation failed for package 'rlang'
หรือ มันหา rlang.dll ไม่เจอ

เหมือนต้องไปลง Tools <https://cran.r-project.org/bin/windows/Rtools/rtools44/files/> ให้มัน Compile rlang ใหม่

พอเปิด rstudio เดี๋ยวมันจะเด้ง popup ให้ compile rlang 1.1.5 เอง

ปล. ผมเจอบน Windows 11  นะ

Read CSV

#CSV
install.packages("bit64")
library(readr)
read_csv("Student.csv")
student_csv_df <- read_csv("Student.csv")

View(student_csv_df)

image.png