0 votes

Hi, I want to rate the feedback from user of options given below as 1 - 4. Can someone help?

 Feedback Good OK Can be Better Very Bad Rating 1 2 3 4
Jun 27, 2019 2,748 views

## 2 answers to this question.

0 votes

Hi Ravi,

You can change the levels in a factor by using factor() and mention explicitly the order of levels in a vector.

Use statement like below,

```feedback = c("Good","OK","Can be Better","Very Bad")

order = factor(feedback, levels = c("Good","OK","Can be Better", "Very Bad"))

print(order)```

Hope it helps!

answered Jun 27, 2019 by
• 33,030 points
0 votes

You can also use relevel() to change the level in a factor.

relevel() takes the factor and the level element and push it to front in the level.

write as below -

```feedback = c("Good","OK","Can be Better","Very Bad")
rating = factor(feedback)
print(rating)
print(as.integer(rating))
rating = relevel(rating,"Can be Better")
rating = relevel(rating,"OK")
rating = relevel(rating,"Good")
print(rating)
print(as.integer(rating))```

answered Jun 27, 2019 by sindhu

0 votes
1 answer

## Change the order of legend values in a plot in R

@prardhana, Use scale_fill/color/size_discrete/contin....(labels = c()). compare both to see ...READ MORE

0 votes
1 answer

## Changing the order of bars in a bar-plot - ggplot2 - R

You can use the scale_x_discrete() function with ...READ MORE

+1 vote
1 answer

## Is it possible to change the column names of the dataset that I'm using in R?

That is definitely possible in R. You ...READ MORE

0 votes
1 answer

## Change the order of multiple legends in ggplot

Hi Radha, You can change the order of ...READ MORE

0 votes
1 answer

## By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

0 votes
1 answer

## How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

0 votes
1 answer

## In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

0 votes
1 answer

## How to create a list of Data frames?

Basically all we have to do is ...READ MORE

+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

0 votes
1 answer

## How to change the datatype of any field in an external dataset in R?

Hi Anand, Try as below - class(dataset/dataframe\$col_name) <- ...READ MORE