Manipulating strings with `stringr` package in R - R Tutorial
Автор: Phan Thi Xuan
Загружено: 2020-10-31
Просмотров: 32
Описание:
Manipulating strings with `stringr` package in R is a free tutorial by Selva Prabhakaran from R course
Link to this course(Special Discount):
https://www.udemy.com/course/learn-r-...
This is the best R Course
Course summary:
Do any sort of data manipulation
Create and master the manipulation of vectors, lists, dataframes, and matrices
Write conditional control structures, debug and efficiently handle errors
Confidently write apply() functions and design any logic within the apply function.
Handle dates using lubridate and manipulate strings with stringr package
Melt, reshape, aggregate, and make pivot tables from dataframes
English [Auto]
Mannum blurting strings is a very useful skill to have especially when we are walking with some mining project or if we wanted to create some new variables with similar names or if you want to have a dynamic text in which you may have a sentence with a number that keeps sending every time like a number of page views or a certain base like that. There are so many applications of doing manipulations really and one of the common operations that we frequently use when it comes to string manipulations is concatenating two or more strings by concatenation. I mean joining two or more strings with specific separators of the choice and if needed you may want to collapse multiple strings into one string. The main function that we will use for this purpose is called best we can pass multiple arguments it is multiple strings as arguments into this based. For example I can pass a and b like this just plainly and let me run this. So that joined the string and the string be together but leaving a space between them. A space character. If I don't want this base I need to specify what separator you should use. So the separate is to double quotes without any spaces between them. In this case there is no space. There is no separation between A and B A Both. If they wanted a common between them. I could mention the separator as just. And if we wanted to add a space after the comma is a comma space and then B. Now this is not all of the functionalities that best function can do it is much more but actually that Michelle. I had one before and then five to eight. If I run this it joins the first elements of the spec two vectors actually have passed two vectors as arguments to past the first the first vector will join the second and the second vector will join and so on. And when joining it leaves a space in between them. If I want more space I will just mention it like this and 15:26 37 and so on come now you can imagine that a lot of my ideas from this like I can convert this to a numeric I'll do it at the console directly if I will get four different numbers. All right. Now watch this close. Can they specify this separate argument. Inserter they separate that that be mentioned here between the corresponding elements of the two vectors. Right. What happens if we include a collapse argument. What will happen is in the previous statement and you've just said you've created four different numbers as characters. Now when we use collapse all the four numbers will collapse and form into one just one number. Let me run this. All right. Is the difference between separate and collapse separate dimensions. Why should be the separator between the elements of the vector and collapse mentions large should be the separator. When we join the output of the already joined elements if we had wanted to place a common between the numbers I would just mention a data call mind collapse argument and Dunning this we have just one vector a character but actually and that's a comma followed by a space placed between all those elements. Now let's try out the challenge. Let me clear the screen. What I would like you to try for this challenge is to create the following string using the best function that we just learned just one thing I wanted to remind before attempting this challenges so far and the basic functions we have just pass two arguments as things but actually we can pass multiple arguments as many strings as possible into the function asdis. So keeping that in mind I will pause the video for a few seconds for it to pause and give this a shot. Good luck hope that went well. If you got that correct congratulations here's how I would solve this. Imagine this thing to be consisting of four parts that get separated by a hyphen in between. And each of the four POC has three numbers in them. So that gives me the clue that my best arguments should take three arguments by arguments. I mean these vectors. There's going to be a separate vector separate argument and then that's going to be a collapse. Right now the numbers that will go into the first vector is the first numbers in each of the four p
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: