Solution Review: Handling CSV file

In this review, we provide a detailed analysis of the solution to the problem.

Solution: Input/Output from File

Press + to interact
main.r
data.csv
path <- "data.csv"
csvData = read.csv(path)
items <- csvData$Item
write.csv(items, "output/outData.csv")

Explanation

In the code snippet above, we first fetch the data of the .csv file in csvData.

The data fetched from read.csv() is directly in the format of a data frame. Therefore, csvData is a data frame. Now, we can excess one of the columns Item using the syntax:

csvData$Item

We store this column in the variable items and then write on file output/outData.csv.