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
• 18,060 points
252 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
• 51,890 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,710 points
922 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, 2019 in Data Analytics by Gups_1985
87 views
0 votes
1 answer

Shiny r ,I'm doing a dashboard and I can not replace in the table below the name of the column by choosing the selectinput.

Hi, When you want to change any input ...READ MORE

answered Aug 19, 2019 in Data Analytics by anonymous
• 32,460 points
93 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, 2019 in Data Analytics by Tyrion anex
• 8,380 points
140 views
0 votes
1 answer

R programming: Linear Equation

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

answered Apr 30, 2019 in Data Analytics by Sophie may
• 9,940 points
217 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
• 51,890 points
161 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,560 points
184 views