How to create a weighted data set

0 votes
How to create a weighted data set?
Oct 21, 2019 in Data Analytics by ch
• 3,450 points
573 views

1 answer to this question.

0 votes

HI @ch,

Create a list of elements and weights separately as below. Then use rep() function to replicate the list and create weighted data.

Example:

> el = c(1,6,2,6,2)
> wt = c(1,6,1,3,8)
> wt_df = rep(el,wt)
> el
[1] 1 6 2 6 2
> wt
[1] 1 6 1 3 8
> wt_df
 [1] 1 6 6 6 6 6 6 2 6 6 6 2 2 2 2 2 2 2 2
answered Oct 21, 2019 by Cherukuri
• 33,030 points

Related Questions In Data Analytics

0 votes
1 answer
0 votes
2 answers

How to arrange a data set in ascending order based on a variable?

In your case it'll be, orderedviews = arrange(movie_views, ...READ MORE

answered Nov 27, 2018 in Data Analytics by Kalgi
• 52,350 points
1,099 views
0 votes
0 answers

How to create a data summary function?

I'm trying to create a function that ...READ MORE

Jun 9, 2022 in Data Analytics by Avinash
• 1,260 points
337 views
+1 vote
1 answer

How to convert a list of vectors with various length into a Data.Frame?

We can easily use this command as.data.frame(lapply(d1, "length< ...READ MORE

answered Apr 4, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,661 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
2,249 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
1,919 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

edited Jun 9, 2020 by Gitika 1,182 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,339 views
+1 vote
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
1,812 views
+1 vote
3 answers

How to change column names of a Data frame?

Hi, To change the name of a column ...READ MORE

answered Oct 30, 2020 in Data Analytics by MD
• 95,460 points
1,715 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP