Difference between revisions of "R: Export"

From OnnoWiki
Jump to navigation Jump to search
(Created page with " # Loading mtcars data data("mtcars") # Write data to txt file: tab separated values # sep = "\t" write.table(mtcars, file = "mtcars.txt", sep = "\t", row.nam...")
 
Line 11: Line 11:
 
  # decimal point = comma (",") and value separators = semicolon (";")
 
  # decimal point = comma (",") and value separators = semicolon (";")
 
  write.csv2(mtcars, file = "mtcars.csv")
 
  write.csv2(mtcars, file = "mtcars.csv")
 +
 +
 +
 +
# Loading mtcars data
 +
data("mtcars")
 +
library("readr")
 +
# Writing mtcars data to a tsv file
 +
write_tsv(mtcars, path = "mtcars.txt")
 +
# Writing mtcars data to a csv file
 +
write_csv(mtcars, path = "mtcars.csv")
 +
 +
  
  

Revision as of 10:32, 28 November 2019

# Loading mtcars data
data("mtcars")
# Write data to txt file: tab separated values
# sep = "\t"
write.table(mtcars, file = "mtcars.txt", sep = "\t",
            row.names = TRUE, col.names = NA)
# Write data to csv files:  
# decimal point = "." and value separators = comma (",")
write.csv(mtcars, file = "mtcars.csv")
# Write data to csv files: 
# decimal point = comma (",") and value separators = semicolon (";")
write.csv2(mtcars, file = "mtcars.csv")


# Loading mtcars data
data("mtcars")
library("readr")
# Writing mtcars data to a tsv file
write_tsv(mtcars, path = "mtcars.txt")
# Writing mtcars data to a csv file
write_csv(mtcars, path = "mtcars.csv")



Pranala Menarik