Predict weight and height of a person based on his nationality in R

+2 votes

I know how to predict weight with given height from the observation but in this case there is a little modification. I need to predict the weight based on nationality. As far as I remember regression method is not applicable with categorical values in R.

How do i go about this?

Dec 12, 2018 in Data Analytics by Hannah
• 14,080 points
67 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+1 vote

One of the way by which you can achieve this is by representing categorical variables as binary vectors. Transform categorical variable to a format that works better with classification and regression algorithm. 

Something like this:

id height weight nationality nationality.us nationality.uk nationality.in nationality.nz nationality.aus
1 169 53 uk 0 1 0 0 0
2 145 67 us 1 0 0 0 0
3 125 45 in 0 0 1 0 0
4 156 76 aus 0 0 0 0

And then carry on with the usual method.

answered Dec 12, 2018 by Kalgi
• 36,220 points

Related Questions In Data Analytics

0 votes
1 answer

How to create dummy variables based on a categorical variable of lists in R?

You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE

answered Apr 13, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
337 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to convert a list of dataframes in to a single dataframe using R?

You can use the plyr function: data <- ...READ MORE

answered Apr 13, 2018 in Data Analytics by darklord
• 6,140 points
67 views
+4 votes
2 answers
0 votes
1 answer

R programming: Linear programming problems

The documentation for the lp package provides ...READ MORE

answered Feb 4 in Data Analytics by Tyrion anex
• 8,280 points
50 views
0 votes
1 answer

R programming: Linear Equation

Use expand.grid to get all possible combinations ...READ MORE

answered Apr 30 in Data Analytics by Sophie may
• 9,250 points
10 views
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
• 36,220 points
23 views
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
31 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.