R Replace Values in Data Frame Conditionally (4 Examples) | Exchange Value in Column & Entire Matrix

  Рет қаралды 14,606

Statistics Globe

Statistics Globe

Күн бұрын

Пікірлер: 48
@ashisranjanudgata5526
@ashisranjanudgata5526 8 ай бұрын
Thank you for nice video. Kindly mention how to change the whole data frame with some logical condotion.
@StatisticsGlobe
@StatisticsGlobe 8 ай бұрын
Thanks for the kind comment! This is actually what is happening in the last example (i.e. data[data == 3] <- 777). Does this work for you? Regards, Joachim
@vijayarjunwadkar
@vijayarjunwadkar 4 жыл бұрын
Liked it! Concept explained nicely with easy examples and simple manner to help understand! Keep it up!
@StatisticsGlobe
@StatisticsGlobe 4 жыл бұрын
Thanks a lot Vijay, great to get such positive feedback! :)
@danielarotaru3491
@danielarotaru3491 2 жыл бұрын
Hello! Thanks for this video, I finally understood why a bit of the code didn't work for me! I have a question that I don't know if there is even an answer (at least I can't find it anywhere). I want to do this replacement but with two conditions, I don't get any error but the replacement isn't being done. Plus, I already transformed both variables into chr. credit_data$length[credit_data$title == "NA" & credit_data$lenght == "NA"]
@StatisticsGlobe
@StatisticsGlobe 2 жыл бұрын
Hey Daniela, thank you for the kind words, glad this video helped! Regarding your question: You have to select NA values using the is.na function. Does the following code work for your data? credit_data$length[is.na(credit_data$title) & is.na(credit_data$lenght)]
@cristopherdunaway
@cristopherdunaway Жыл бұрын
Thank you!
@matthias.statisticsglobe
@matthias.statisticsglobe Жыл бұрын
Hey Christopher! Thanks for the positive response!
@ProfBoggs
@ProfBoggs 3 жыл бұрын
Do you have a video that explains how to replace a value in one column, given another value in a different column? For instance, my dataframe named data has two columns, NAME and OCCUPATION. In pseudo-code, I want something that does this: if data$NAME = "Marie", then data$occupation = "Statistician" but only for that same row. Optimally, this would be in basic R.
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Hey, does this R code work for you? data$occupation[data$NAME == "Marie"]
@ProfBoggs
@ProfBoggs 3 жыл бұрын
@@StatisticsGlobe Hi Joachim, that works. Thank you kindly.
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
You are very welcome!
@jared1122
@jared1122 3 жыл бұрын
Thanks for vid - nicely explianed!
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Glad you enjoyed it Jared!
@ambroiseyeboua2043
@ambroiseyeboua2043 3 жыл бұрын
thanks you. i want to know, how to replace multiple values in the same column with a corresponding list of values with a single click
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Hey Ambroise, thank you for the kind words, and I'm sorry for the late response. I just came back from holidays and did not have the chance to read your message earlier. Do you still have problems with this?
@ambroiseyeboua2043
@ambroiseyeboua2043 3 жыл бұрын
@@StatisticsGlobe thank you, i was able to solve the problem
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
That's great to hear!
@danhdo1910
@danhdo1910 3 жыл бұрын
How did you do this? :( I am looking for a solution too!
@BOY_NAME_
@BOY_NAME_ 3 жыл бұрын
cool thanks!! worked for my case!!!
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Great, glad to hear that!
@jeremylarcher3981
@jeremylarcher3981 2 жыл бұрын
thank you!
@StatisticsGlobe
@StatisticsGlobe 2 жыл бұрын
You're welcome Jeremy!
@kathrynmalchow3199
@kathrynmalchow3199 3 жыл бұрын
THANK YOU :*
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
You're welcome Kathryn! :)
@apostoloskolovos9815
@apostoloskolovos9815 3 жыл бұрын
thank you very much
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
You are very welcome Apostolos!
@CoachPegasus
@CoachPegasus 2 жыл бұрын
How to change/replace/impute 04-04-2020 to 04/04/2020 in date column ? if Date column is character column
@StatisticsGlobe
@StatisticsGlobe 2 жыл бұрын
Hey, please have a look here: statisticsglobe.com/change-format-of-dates-in-r
@SudhirKumar-ry4gk
@SudhirKumar-ry4gk 4 жыл бұрын
I need your help, actually I have data frame in which duplicate value, I want to add new column and show if any value comes two times then I want againt both result come 2,2 and if repeat three times then it comes 3 againt all repeated values which comes thrice.
@StatisticsGlobe
@StatisticsGlobe 4 жыл бұрын
Hey Sudhir, please check out this thred at Stack Overflow: stackoverflow.com/questions/7450600/count-number-of-rows-per-group-and-add-result-to-original-data-frame I think it's explaining what you are looking for. Regards, Joachim
@SudhirKumar-ry4gk
@SudhirKumar-ry4gk 4 жыл бұрын
@@StatisticsGlobe Thanks for the revert it's very useful.
@StatisticsGlobe
@StatisticsGlobe 4 жыл бұрын
That's nice to hear :)
@abhijeetjahagirdar6117
@abhijeetjahagirdar6117 4 жыл бұрын
Hello Sir your videos are really helpful while solving exercise but I really need your help in one problem I came across data science in R book. Q. For the job field, combine the jobs with less than 5% of the records into a field called other. Above question is from bank_marketing_training data set of 26874 obs of 21 variables, in that job is one of them.How to compute in R I didn't get how to write in R and get it executed.
@StatisticsGlobe
@StatisticsGlobe 4 жыл бұрын
Hey Abhijeet, nice to hear from you again. Is this working? jobs_less_5
@abhijeetjahagirdar6117
@abhijeetjahagirdar6117 4 жыл бұрын
@@StatisticsGlobe yes it worked its really short and sweet execution otherwise i would have complicated it.I need to learn from scratch and revise it,your tutorials are vey helpful and explainatory thanks bro and guide like you is awe-inspiring privilege.
@StatisticsGlobe
@StatisticsGlobe 4 жыл бұрын
Thanks mate, I'm really happy to get such an awesome feedback! Keep me updated about your learning progress :)
@jamesleleji6984
@jamesleleji6984 Жыл бұрын
team code 1 QATAR QA 2 ENGLAND NA 3 SENEGAL SN 4 UNITED STATES US 5 ARGENTINA AR 6 DENMARK DK 7 ENGLAND NA 8 WALES NA 9 WALES NA Given the data frame above, i want to convert the NA for ENGLAND and WALES to their code, EN and WL, respectively while keeping the codes for the other countries unchanged. How do i write the code in R. Thanks
@cansustatisticsglobe
@cansustatisticsglobe Жыл бұрын
Hello James, You can use the method given in the tutorial. Didn't it work for you? Regards, Cansu
@jamesleleji6984
@jamesleleji6984 Жыл бұрын
@@cansustatisticsglobe df |> mutate(code = case_when(team == "ENGLAND" ~ "EN", team == "WALES" ~ "WL", TRUE ~ code)) This code worked for me. It replaced the NA with EN and WL and retained the code values of other countries. Thanks
@cansustatisticsglobe
@cansustatisticsglobe Жыл бұрын
@@jamesleleji6984, your solution is even more advanced, congratulations! When you stick with the tutorial, you should write something like this: data
@jamesleleji6984
@jamesleleji6984 Жыл бұрын
@@cansustatisticsglobe Thanks for always being helpful.
@cansustatisticsglobe
@cansustatisticsglobe Жыл бұрын
@@jamesleleji6984 You are welcome!
@SudhirKumar-ry4gk
@SudhirKumar-ry4gk 4 жыл бұрын
Nicky explained..
@StatisticsGlobe
@StatisticsGlobe 4 жыл бұрын
Thanks a lot Sudhir!
СОБАКА ВЕРНУЛА ТАБАЛАПКИ😱#shorts
00:25
INNA SERG
Рет қаралды 1,7 МЛН
小丑揭穿坏人的阴谋 #小丑 #天使 #shorts
00:35
好人小丑
Рет қаралды 37 МЛН
MAGIC TIME ​⁠@Whoispelagheya
00:28
MasomkaMagic
Рет қаралды 38 МЛН
ЗНАЛИ? ТОЛЬКО ОАЭ 🤫
00:13
Сам себе сушист
Рет қаралды 4 МЛН
Fortran Refresher | Calling C code from Fortran | Lesson 12
30:19
Pawsey Supercomputing Research Centre
Рет қаралды 20
Grouping and Summarizing Data Using dplyr
13:54
weecology
Рет қаралды 10 М.
Lubridate - how to manipulate date and time data in R
18:05
R Programming 101
Рет қаралды 12 М.
СОБАКА ВЕРНУЛА ТАБАЛАПКИ😱#shorts
00:25
INNA SERG
Рет қаралды 1,7 МЛН