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, 2019 in Data Analytics by Sophie may
• 10,620 points
871 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


Hope this helps!

To know more, join R programming course today.

Thanks.

answered Jun 28, 2019 by Zulaikha
• 910 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 5, 2019 in Data Analytics by Sophie may
• 10,620 points
609 views
0 votes
1 answer

Data slicing using R programming

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

answered Jan 9, 2019 in Data Analytics by Tyrion anex
• 8,700 points
964 views
+1 vote
3 answers

How to change the value of a variable using R programming in a data frame?

Try this: df$symbol <- as.character(df$symbol) df$symbol[df$sym ...READ MORE

answered Jan 11, 2019 in Data Analytics by Tyrion anex
• 8,700 points
35,684 views
+1 vote
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, 2019 in Data Analytics by Tyrion anex
• 8,700 points
904 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
• 10,620 points
3,161 views
+1 vote
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,700 points
618 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 28, 2018 in Data Analytics by Sophie may
• 10,620 points
653 views
+1 vote
1 answer

R Programming: Market Basket Analysis Error

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

answered Feb 12, 2019 in Data Analytics by Sophie may
• 10,620 points
1,419 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, 2019 in Data Analytics by Zulaikha
• 910 points
883 views
0 votes
1 answer

Probabilities in R programming

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

answered May 27, 2019 in Data Analytics by Zulaikha
• 910 points
1,645 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP