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
25 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
• 31,840 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
284 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,870 points
47 views
0 votes
0 answers
0 votes
1 answer

Difference between list(1:5) and list(1,2 ...5) in R.

It's very simple. list(1:4) creates a single element(vector) whereas ...READ MORE

answered Oct 14 in Data Analytics by rajeev
31 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
51 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,720 points
116 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,720 points
160 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,720 points
87 views
0 votes
2 answers

How to sum a variable by group in R?

You can also try this way, x_new = ...READ MORE

answered Jul 31 in Data Analytics by Cherukuri
• 31,840 points
10,476 views
0 votes
2 answers

Splitting the data into training and testing sets - R

Hi, Try like this. train = sample(x = ...READ MORE

answered Aug 20 in Data Analytics by anonymous
• 31,840 points
1,247 views