Add Column to Data Frame in R (3 Examples) | Append Vector as New Variable to Table | cbind Function

  Рет қаралды 10,911

Statistics Globe

Statistics Globe

Күн бұрын

Пікірлер: 17
@AHBrietzke
@AHBrietzke 3 жыл бұрын
Your videos are great!! Unlike many other videos, yours are clear and straight forward to the thing. Danke. Grüsse aus Spanien
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Thanks a lot for the nice feedback! That's exactly what I'm trying to do :) Muchos saludos de vuelta a españa (I hope that's correct Spanish :D )
@vanhoot2234
@vanhoot2234 2 жыл бұрын
One question that I have is how to add a new column of data if that column doesn't contain numeric data but contains an letters instead? When I attempt to do this it shifts it away from being a data frame and "coerces it to a list.
@StatisticsGlobe
@StatisticsGlobe 2 жыл бұрын
Hey, this should also be possible with character variables. Could you share the code you have tried so far?
@vanhoot2234
@vanhoot2234 2 жыл бұрын
@@StatisticsGlobe It didn't work with the first example provided but the third example seemed to work. cbind.data.frame(Tpose_peren_decid_DF, Lifespan = vec_peren_decid ) that is what ended up working. I tinkered a bit.
@vanhoot2234
@vanhoot2234 2 жыл бұрын
@@StatisticsGlobe For the vector vec_peren_decid vec_peren_decid
@StatisticsGlobe
@StatisticsGlobe 2 жыл бұрын
Glad you found a solution!
@vanhoot2234
@vanhoot2234 2 жыл бұрын
@@StatisticsGlobe Also wanted to say that I saw that someone was a bit negative about one of your reddit posts. I do think that this is good quality especially for someone who is really just starting to get into R, I have utilized these videos quite a number of times over the past 1-3 months really quickly so I appreciate it. I appreciate that you provide a number of examples. I think having follow up videos on for loops or how to write more efficient code in the future would be great as well. That would be my main piece of feedback. This has been solid. Much appreciated.
@thabi_d
@thabi_d 2 жыл бұрын
But what if the column is very long ?
@StatisticsGlobe
@StatisticsGlobe 2 жыл бұрын
The new column should have the same length as the number of rows in your data frame. If this isn't the case, you might have a look here: statisticsglobe.com/cbind-and-rbind-vectors-with-different-length-in-r
@amilachathuranga5541
@amilachathuranga5541 3 жыл бұрын
can you please explain how to add new column with data type also.
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
Hey Amila, the data type of the new column will be the same as of the vector you are adding. If you want to change the data type, you may have a look here: kzbin.info/www/bejne/laOzlZhjiLV3jKc
@amilachathuranga5541
@amilachathuranga5541 3 жыл бұрын
@@StatisticsGlobe thank you for fast response
@StatisticsGlobe
@StatisticsGlobe 3 жыл бұрын
You are very welcome! :)
@dennice3373
@dennice3373 2 жыл бұрын
what if the column is with a lot of rows?
@StatisticsGlobe
@StatisticsGlobe 2 жыл бұрын
Hey, does your new column have the same number of rows as your data frame? In this case, it does not matter.
If-else statements in R
12:29
Equitable Equations
Рет қаралды 4,5 М.
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 54 МЛН
Lubridate - how to manipulate date and time data in R
18:05
R Programming 101
Рет қаралды 12 М.
Loop Through Column and Rows of a Dataframe in R
9:52
The Data Hall
Рет қаралды 722
Creating Columns in R with mutate()
5:15
Equitable Equations
Рет қаралды 7 М.