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, 2019 in Data Analytics by riti
40 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, 2019 by anonymous
• 32,420 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,800 points
374 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,900 points
58 views
0 votes
0 answers

how does 1=1 helps when joining 2 tables in sql?

Mar 28, 2019 in Data Analytics by anonymous
33 views
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, 2019 in Data Analytics by rajeev
48 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,560 points
58 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
148 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
214 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
97 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, 2019 in Data Analytics by Cherukuri
• 32,420 points
13,801 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, 2019 in Data Analytics by anonymous
• 32,420 points
1,553 views