5/10/2023 0 Comments Vector code for fl studio 12![]() Split a character string based on a specific symbol with the strsplit() function: strsplit(c("Rafael Nadal", "Roger Federer", "Novak Djokovic"), Replacement = "BEL", # replace it with BEL Replace a character string by another one if it exists in the vector by using the sub() function: sub( To extract a character string based on the beginning and the end positions, we can use the substr() function: substr(code, To find the positions of the elements containing a given string, use the grep() function: grep("BE", code) # 1 2 5 The argument sep stands for separator and allows to specify the character(s) or symbol(s) used to separate each character strings. ![]() If you need to round a number, you can use the round(), floor() and ceiling() functions: round(cos(x), digits = 3) # 3 decimals # -0.505 0.284 -0.654 0.540 floor(cos(x)) # largest integer not greater than x # -1 0 -1 0 ceiling(cos(x)) # smallest integer not less than x # 0 1 0 1 It is also possible to compute the minimum, maximum, sum, product, cumulative sum and cumulative product of a vector: min(x) # -4 max(x) # 5 sum(x) # 4.1 prod(x) # -42 cumsum(x) # 2.1 7.1 3.1 4.1 cumprod(x) # 2.1 10.5 -42.0 -42.0 ![]() The basic numerical operators such as +, -, *, / and ^ can be applied to vectors: x <- c(2.1, 5, -4, 1) Add new variables from another data frame.Add new observations from another data frame.Categorical variables and labels management.Transform a continuous variable into a categorical variable.
0 Comments
Leave a Reply. |