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

+3 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,520 points
1,052 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
• 52,350 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,750 points
2,649 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
899 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
• 33,030 points
1,166 views
+5 votes
2 answers
+1 vote
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,700 points
905 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
• 10,620 points
1,267 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
• 52,350 points
1,112 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,660 points
1,221 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