Skip to content

Instantly share code, notes, and snippets.

@Aphellirus
Created July 19, 2021 22:49
Show Gist options
  • Save Aphellirus/d2f378c7844f38719b782cc6e200a094 to your computer and use it in GitHub Desktop.
Save Aphellirus/d2f378c7844f38719b782cc6e200a094 to your computer and use it in GitHub Desktop.
Handling CSV with R
# Write csv in R
df <- data.frame(name = c("Jon", "Winston", "Suzy"),
age = c(23, 41, 32))
write.csv(df,"C:\\Users\\Matheus\\Desktop\\MyData.csv", row.names = FALSE)
# Read csv with R
data <- read.csv("input.csv")
print(data)
# Write to csv with R
write.csv(Your DataFrame,"Path where you'd like to export the DataFrame\\File Name.csv", row.names = FALSE)
#Import csv file with R
read.csv("yourdata.csv", sep = ';')
#Read csv with R
library(readr)
data <- read_csv("input.csv")
# Parse csv with R
planetsDistance <- read.csv(file = 'data/planets-distances.csv')
head(planetsDistance)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment