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

How to write a text file through R?

How to write a text file through R?

This recipe helps you write a text file through R

Recipe Objective

How to write a text file through R? Creating a new file or any format say.csv , etc and writing the data generated inside that file is nothing but writing a text file in R. For instance, we create a 4*5 matrix in our example. We then pass this matrix through a dataframe. Using the write () function this matrix is written/displayed inside a new.csv file is stored inside the files folder. This recipe demonstrates an example of how to write a file.

Step 1 -Creating a 4*5 matrix in a vector m

m <- matrix(c(1:10), nrow = 4, ncol = 5, byrow = TRUE) print(m)

Step 2 -Create a dataframe for the matrix

df <- data.frame(m)

Step 3 -Write a text file

Using the write.csv() function the matrix created gets written/displayed in the new csv file named'example file.csv'. This file can be accessed from the files folder. syntax - write.csv(data,filename) where, data - the created data filename - the name of the file in which you wish to save your data

write.csv(df,"example file.csv")

Relevant Projects

Machine Learning Project to Forecast Rossmann Store Sales
In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

Machine learning for Retail Price Recommendation with Python
Use the Mercari Dataset with dynamic pricing to build a price recommendation algorithm using machine learning in Python to automatically suggest the right product prices.

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Avocado Machine Learning Project Python for Price Prediction
In this ML Project, you will use the Avocado dataset to build a machine learning model to predict the average price of avocado which is continuous in nature based on region and varieties of avocado.

Data Science Project - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.

Predict Macro Economic Trends using Kaggle Financial Dataset
In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.

Build OCR from Scratch Python using YOLO and Tesseract
In this deep learning project, you will learn how to build your custom OCR (optical character recognition) from scratch by using Google Tesseract and YOLO to read the text from any images.

Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

Loan Eligibility Prediction in Python using H2O.ai
In this loan prediction project you will build predictive models in Python using H2O.ai to predict if an applicant is able to repay the loan or not.

Inventory Demand Forecasting using Machine Learning in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.