How to write a csv through R?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

How to write a csv through R?

How to write a csv through R?

This recipe helps you write a csv through R

0

Recipe Objective

CSV stands for Comma Separated Value. .csv is a text file which is used to store tabular data where usually text is separated by comma. It is quite widely used as a data source where each line is a data record.

R gives you the platform to read, write and edit data that are stored in any external environment.

In this recipe we will discuss how to write a CSV file in R.

Step 1: Creating a Dataframe

We use data.frame() function to create a dataframe using vectors.

data = data.frame(Name = c("Nikhil", "Fredo", "Sam"), AGE = c("15", "34", "45"), Hobbies = c("Football", "Reading", "Swimming")) ​
data
Nikhil	15	Football
Fredo	34	Reading
Sam	45	Swimming

Step 2: Writing a CSV file

We use write.csv() function to write csv file.

Syntax: write.csv(x, file, row.names, quote)

where:

  1. x = dataframe that you want to write;
  2. file = name along with the extension .csv;
  3. row.names = (Optional) Input FALSE if you don't want row labels in your CSV file. By default, it's TRUE
  4. quote = (Optional) Input FALSE if you don't want double quotes in text content. By default, it's TRUE
write.csv(data, "dftocsv.csv", quote = FALSE)

Relevant Projects

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Sequence Classification with LSTM RNN in Python with Keras
In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset​ using Keras in Python.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

Customer Market Basket Analysis using Apriori and Fpgrowth algorithms
In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.