library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
data1 <- read.csv("foodreview.csv")
library(tidyverse) # Load the essential library for data manipulationWarning: package 'stringr' was built under R version 4.5.3
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ forcats 1.0.0 ✔ readr 2.1.5
✔ ggplot2 3.5.2 ✔ stringr 1.6.0
✔ lubridate 1.9.4 ✔ tibble 3.2.1
✔ purrr 1.0.4 ✔ tidyr 1.3.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
# Create a data frame
df <- data.frame(data1)
# --- 1. SETUP & INITIAL INSPECTION ---
# 1. Load the library
library(tidyverse)
# 2. View data structure
str(df) 'data.frame': 368459 obs. of 10 variables:
$ Id : chr "1" "2" "3" "4" ...
$ ProductId : chr "B001E4KFG0" "B00813GRG4" "B000LQOCH0" "B000UA0QIQ" ...
$ UserId : chr "A3SGXH7AUHU8GW" "A1D87F6ZCVE5NK" "ABXLMWJIXXAIN" "A395BORC6FGVXV" ...
$ ProfileName : chr "delmartian" "dll pa" "Natalia Corres \"Natalia Corres\"" "Karl" ...
$ HelpfulnessNumerator : chr "1" "0" "1" "3" ...
$ HelpfulnessDenominator: chr "1" "0" "1" "3" ...
$ Score : chr "5" "1" "4" "2" ...
$ Time : chr "1303862400" "1346976000" "1219017600" "1307923200" ...
$ Summary : chr "Good Quality Dog Food" "Not as Advertised" "\"Delight\" says it all" "Cough Medicine" ...
$ Text : chr "I have bought several of the Vitality canned dog food products and have found them all to be of good quality. T"| __truncated__ "Product arrived labeled as Jumbo Salted Peanuts...the peanuts were actually small sized unsalted. Not sure if t"| __truncated__ "This is a confection that has been around a few centuries. It is a light, pillowy citrus gelatin with nuts - i"| __truncated__ "If you are looking for the secret ingredient in Robitussin I believe I have found it. I got this in addition t"| __truncated__ ...
# 3. View statistical summary
summary(df) Id ProductId UserId ProfileName
Length:368459 Length:368459 Length:368459 Length:368459
Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character
HelpfulnessNumerator HelpfulnessDenominator Score
Length:368459 Length:368459 Length:368459
Class :character Class :character Class :character
Mode :character Mode :character Mode :character
Time Summary Text
Length:368459 Length:368459 Length:368459
Class :character Class :character Class :character
Mode :character Mode :character Mode :character
# 4. View first 6 rows
head(df) Id ProductId UserId ProfileName
1 1 B001E4KFG0 A3SGXH7AUHU8GW delmartian
2 2 B00813GRG4 A1D87F6ZCVE5NK dll pa
3 3 B000LQOCH0 ABXLMWJIXXAIN Natalia Corres "Natalia Corres"
4 4 B000UA0QIQ A395BORC6FGVXV Karl
5 5 B006K2ZZ7K A1UQRSCLF8GW1T Michael D. Bigham "M. Wassir"
6 6 B006K2ZZ7K ADT0SRK1MGOEU Twoapennything
HelpfulnessNumerator HelpfulnessDenominator Score Time
1 1 1 5 1303862400
2 0 0 1 1346976000
3 1 1 4 1219017600
4 3 3 2 1307923200
5 0 0 5 1350777600
6 0 0 4 1342051200
Summary
1 Good Quality Dog Food
2 Not as Advertised
3 "Delight" says it all
4 Cough Medicine
5 Great taffy
6 Nice Taffy
Text
1 I have bought several of the Vitality canned dog food products and have found them all to be of good quality. The product looks more like a stew than a processed meat and it smells better. My Labrador is finicky and she appreciates this product better than most.
2 Product arrived labeled as Jumbo Salted Peanuts...the peanuts were actually small sized unsalted. Not sure if this was an error or if the vendor intended to represent the product as "Jumbo".
3 This is a confection that has been around a few centuries. It is a light, pillowy citrus gelatin with nuts - in this case Filberts. And it is cut into tiny squares and then liberally coated with powdered sugar. And it is a tiny mouthful of heaven. Not too chewy, and very flavorful. I highly recommend this yummy treat. If you are familiar with the story of C.S. Lewis' "The Lion, The Witch, and The Wardrobe" - this is the treat that seduces Edmund into selling out his Brother and Sisters to the Witch.
4 If you are looking for the secret ingredient in Robitussin I believe I have found it. I got this in addition to the Root Beer Extract I ordered (which was good) and made some cherry soda. The flavor is very medicinal.
5 Great taffy at a great price. There was a wide assortment of yummy taffy. Delivery was very quick. If your a taffy lover, this is a deal.
6 I got a wild hair for taffy and ordered this five pound bag. The taffy was all very enjoyable with many flavors: watermelon, root beer, melon, peppermint, grape, etc. My only complaint is there was a bit too much red/black licorice-flavored pieces (just not my particular favorites). Between me, my kids, and my husband, this lasted only two weeks! I would recommend this brand of taffy -- it was a delightful treat.
# 5. View dimensions (Rows, Columns)
dim(df) [1] 368459 10
# 6. View all column names
colnames(df) [1] "Id" "ProductId" "UserId"
[4] "ProfileName" "HelpfulnessNumerator" "HelpfulnessDenominator"
[7] "Score" "Time" "Summary"
[10] "Text"