Joining 2 vectors into 1 variable - R

0 votes
How to join 2 vector variables with each element in 2nd vector?. In other words, I want to have a cross join of both vectors into a new variable.
Jul 2 in Data Analytics by riti
10 views

1 answer to this question.

0 votes

A small trick that you can do is to create a matrix of either of those 2 vectors and then paste the matrices like below.

Just a small trick, 

Suppose the matrices where letters = c ("a","b","c","d") and  numbers = c (1,2,3,4,5).

Now create a matrix of any 1 vector and then paste matrix with the vector this will fetch you combined vector as you wanted.

Pasting 2 vectors directly will give result as below

answered Jul 4 by anonymous
• 17,870 points

Related Questions In Data Analytics

0 votes
1 answer

Error in source("myfunction.R") : myfunction.R:2:3: unexpected symbol 1: 2: R version

Try formatting your code like this: myfunction <- ...READ MORE

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,040 points
132 views
0 votes
1 answer

R programming: Finding the difference between 2 vectors

Try this function, it worked for me: f ...READ MORE

answered Dec 27, 2018 in Data Analytics by Sophie may
• 9,430 points
32 views
0 votes
0 answers
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
46 views
0 votes
1 answer

Appending values to a vector - R

This is actually quite easy, all you ...READ MORE

answered May 15, 2018 in Data Analytics by Bharani
• 4,550 points
32 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
64 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
78 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,700 points
60 views
0 votes
1 answer

Difference between [[1]] and [1] in R Programming

Hey Latha, The difference between them is that ...READ MORE

answered Jun 28 in Data Analytics by anonymous
• 17,870 points
22 views
0 votes
1 answer

Replace columns containing row id into a constant value - R

Create a vector of the list of ...READ MORE

answered Jul 4 in Data Analytics by Cherukuri
• 17,870 points
9 views