Question

how to rename a row in r studio, for example view(mydata) a b c red 1...

how to rename a row in r studio, for example

view(mydata)

a b c
red 1 4
yellow 2 4
white* 5

6

black 0 6
pink 6 3
purple 10 5

I want to rename the row 4, white* to white. I need to remove the "*"

also I want to add a new column, with repetition values for ex.

new column
1
2
3
1

2

3

please help, how can I write in R-program

Homework Answers

Answer #1

STEP - BY - STEP PROCESS

(1.) Make a data frame ==> 'mydata'

a <- c('red', 'yellow', 'white*', 'black', 'pink', 'purple')
b <- as.numeric(c(1, 2, 5, 0, 6, 10))
mydata <- data.frame(a, b)
mydata

(2.) Remove "*" from white*

mydata$a <-  gsub("[*]", "", mydata$a)
mydata

(3.) A new column with repetition values

new_col <- c(rep(1:3,length.out=nrow(mydata)))
mydata['new_col'] <- new_col
mydata

NOTE: All codes above in the R language. Please use R-studio for better understanding.

Thumbs Up Please !!!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Let's say I have a bag of marbles. There are 5 different colors: white, black, blue,...
Let's say I have a bag of marbles. There are 5 different colors: white, black, blue, yellow and red. The claimed ratio of white to black to blue to yellow to red is 1:3:9:1:1. I want to pick a blue marble with closed eyes. I try seven times and get only one blue marble. Is the claimed ratio of blue marbles to other colors overestimated? Use alpha 0.05. Think if you need a 1 or a 2 tail test here.
how many different ways are there to place 1 blue, 1 yellow, 1 red, 3 black,...
how many different ways are there to place 1 blue, 1 yellow, 1 red, 3 black, 2 green, 1 brown, 1 white, and 3 gray books on the shelf assuming that we cannot distinguish books of the same color.v
In tomatoes, red fruit (R) is dominant to yellow fruit (r). Round fruit (B) is dominant...
In tomatoes, red fruit (R) is dominant to yellow fruit (r). Round fruit (B) is dominant to pear-shaped fruit (b). Cross a heterozygous red, round tomato plant with another plant of the same genotype. Now, answer the following questions based on the above cross done by you: 1. What is the genotype of the first parent? 2. What is the genotype of the second parent? 3. What is the probability of getting heterozygous red and round fruit in the offspring?...
I need a program written in C, not C+ or C++. I have no idea how...
I need a program written in C, not C+ or C++. I have no idea how to go about doing it. Basically, I need it to take in the following information and spit out the following for a number table. The operation should be able to take plus, minus, division or multiplication and the low/high row/column numbers should be able to go up to where ever. But I'm sure the following example is fine. Enter low row number: 1 Enter...
Using the pivot table that you just created, determine which of the color types sold the...
Using the pivot table that you just created, determine which of the color types sold the least amount of yards using =MIN() Using the pivot table that you just created, determine which of the color types sold the largest amount of yards using =MAX() If Saeko wants to expand the colors in both the best selling and the worst selling color type, which two color types should she buy? Least amount sold: 5194 Largest amount sold: 7229 What colors should...
You have been given the following lists of Color and their specific codes: Colors = ['Red','Blue','Green','Black','Yellow',‘Orange’,‘Purple’,‘Nocolor’]...
You have been given the following lists of Color and their specific codes: Colors = ['Red','Blue','Green','Black','Yellow',‘Orange’,‘Purple’,‘Nocolor’] Codes = [97,17,19,128,66,111,231,00] 1. Using codeDict, find the score for 'Nocolor'. 2. Add a code of 333 for 'Nocolor'. 3. Create a sorted list of all the codes in codeDict. 4. Update the name for 'Nocolor' to be ‘white’ 5. White was not a part of original colors list so, just Delete it and its code from codeDict. USE PYTHON CONSOLE AND SUBMIT THE...
There are 15 marbles in a bag. 3 are red, 5 are blue, 2 are green,...
There are 15 marbles in a bag. 3 are red, 5 are blue, 2 are green, 1 is yellow, and 4 are purple. a. If a single marble is drawn, the odds for drawing a blue marble are:  1:21:32:13:14:114:1511:415:4 b. If a single marble is drawn, the odds against drawing a red or yellow marble are:  1:21:32:13:14:114:1511:415:4 4 points    QUESTION 15 The odds against Alex's team losing their next basketball game are 12:4. Determine the probability that Alex's team wins their...
A special deck of cards has 6 red cards, and 5 black cards. The red cards...
A special deck of cards has 6 red cards, and 5 black cards. The red cards are numbered 1, 2, 3, 4, 5, and 6. The black cards are numbered 1, 2, 3, 4 and 5. The cards are well shuffled and you randomly draw one card. R = card drawn is red E = card drawn is even-numbered a. How many elements are there in the sample space? b. P(E) =   Round your answer to two decimal places.
How many ways are there in which 2 purple stones, 1 yellow stone, 2 orange stones,...
How many ways are there in which 2 purple stones, 1 yellow stone, 2 orange stones, and 2 red stones can be placed on a 10x10 chessboard so that no two stones are in the same row and no two stones are in the same column. Please ignore symmetries, so that there are 4 ways of placing a stone on a corner of the chessboard, not 1 way. Show all work and write down the final expression (with explanations) whose...
A special deck of cards has 5 green cards , and 3 yellow cards. The green...
A special deck of cards has 5 green cards , and 3 yellow cards. The green cards are numbered 1, 2, 3, 4, and 5. The yellow cards are numbered 1, 2, and 3. The cards are well shuffled and you randomly draw one card. G = card drawn is green E = card drawn is even-numbered a. How many elements are there in the sample space?    _____ b. P(E) =_____  (Round to 4 decimal places) 2. A special deck of cards...