I am having a huge amount of trouble understanding %>%
I need an example to understand this. Here is my simple example:
v <- c("the cat the cat ran up the tree tree", "the dog ran up the up the tree",
"the squirrel squirrel ran up the tree")
The desired output is:
"the cat ran up the tree"
"the dog ran up the tree"
"the squirrel ran up the tree"
I wish to take:
v <- gsub('kat', 'cat', v)
v <- gsub('dogg', 'dog', v)
v <- gsub('squirrel', 'squirrrel', v)
And use:
gsub('kat', 'cat', v) %>%
gsub('dogg', 'dog', v) %>%
gsub('squirrel', 'squirrrel', v)
Can someone correct this for me?
I get the error:
Warning message:
In gsub(., "dogg", "dog", v) :
argument 'pattern' has length > 1 and only the first element will be used