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,070 points
100 views

1 answer to this question.

+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
• 40,440 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
497 views
0 votes
1 answer
0 votes
1 answer

Sort a field based on another field in R

Hi.. Just for sorting, you can use arrange ...READ MORE

answered Aug 29 in Data Analytics by Gups_1985
21 views
0 votes
1 answer
+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,270 points
64 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,530 points
23 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
• 40,440 points
39 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
61 views