R programming: Data Categorization

0 votes

This wine data set was collected from kaggle. It has a variable called quality that ranges between 1 to 8. I tried to categorize wine based on quality. 

This is my code:

wineData$taste <- NA
wineData$taste[which(wineData$quality< 6)] <- bad
wineData$taste[which(wineData$quality>6)] <- excellent
wineData$taste[which(wineData$quality=6)] <- normal
wineData$taste <- factor(wineData$taste)
wineData`

This is the error I'm getting:

wineData$taste[which(wineData$quality>6)] <- excellent Error: object 'excellent' not found wineData$taste[which(wineData$quality==6)] <- normal Error: object 'normal' not found
Jun 28 in Data Analytics by Sophie may
• 9,850 points
18 views

1 answer to this question.

0 votes

Try this:

wineData$taste <- NA
    wineData$taste[which(wineData$quality< 6)] <- "bad"
    wineData$taste[which(wineData$quality>6)] <- "excellent"
    wineData$taste[which(wineData$quality==6)] <- "normal"
    wineData$taste <- factor(wineData$taste)
    wineData
answered Jun 28 by Zulaikha
• 870 points

Related Questions In Data Analytics

0 votes
1 answer

Data segmentation using R programming

I tried solving your problem, try the ...READ MORE

answered Jan 4 in Data Analytics by Sophie may
• 9,850 points
47 views
0 votes
1 answer

Data slicing using R programming

You can perform data slicing by splitting the ...READ MORE

answered Jan 9 in Data Analytics by Tyrion anex
• 8,270 points
52 views
0 votes
2 answers
0 votes
1 answer

R programming: How to subset data and plot graphs in R?

You can create a grouping variable depending ...READ MORE

answered Feb 18 in Data Analytics by Tyrion anex
• 8,270 points
65 views
0 votes
1 answer

R programming: Unexpected symbol error

Format your code this way: myfunction <- function() ...READ MORE

answered Dec 17, 2018 in Data Analytics by Sophie may
• 9,850 points
298 views
0 votes
1 answer

R programming error

Alright, you can either use gsub to match the ...READ MORE

answered Dec 18, 2018 in Data Analytics by Tyrion anex
• 8,270 points
28 views
0 votes
1 answer

R Programming error in 'fert'

You're using a factor: fert <- factor(c(50,20,10,10,20,50)) levels(fert) #[1] ...READ MORE

answered Dec 27, 2018 in Data Analytics by Sophie may
• 9,850 points
49 views
0 votes
1 answer

R Programming: Market Basket Analysis Error

The basket.sorted() has less than 5 rules. Refer ...READ MORE

answered Feb 11 in Data Analytics by Sophie may
• 9,850 points
146 views
0 votes
1 answer

Changing variable values using R programming

This should work: df$symbol <- as.character(df$symbol) df$symbol[df$symbol == "ABCD.BO"] ...READ MORE

answered May 27 in Data Analytics by Zulaikha
• 870 points
26 views
0 votes
1 answer

Probabilities in R programming

This should work: poker_face <- replicate(1000, sample(poker, size ...READ MORE

answered May 27 in Data Analytics by Zulaikha
• 870 points
72 views