Skip to content
Prev 369537 / 398503 Next

Data import R: some explanatory variables not showing up correctly in summary

It looks like your printouts are based on the R summary() function? The function lists the number of cases in the 5 largest categories when the variable is coded as a function. Then it indicates how many other categories are present. This is described on the manual page for function summary().

In the first case the duplicates probably represent cases in your source data (a spreadsheet?), where you have inadvertently put a space at the end of the label, e.g. "combination", and "combination ". The answers to both questions are easy to find with the levels() function:

levels(yourdataframe$Position) 

This will list all of the factor levels in variable Position for you. If there are extras spaces and you were using read.csv() to import the data, use the strip.white=TRUE argument to delete leading and trailing spaces. This is also documented on the manual page for function read.csv(). One of the problems with spreadsheets is that these extra spaces are not readily apparent.

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ulrik Stervbo
Sent: Thursday, June 1, 2017 10:50 AM
To: Rui Barradas <ruipbarradas at sapo.pt>; Tara Adcock <taraadcock1 at hotmail.com>; r-help at r-project.org
Subject: Re: [R] Data import R: some explanatory variables not showing up correctly in summary

Hi Tara,

It seems that you categorise and count for each category. Could it be that
the method you use puts everything that doesn't match the predefined
categories in Other?

I'm only guessing because without a minimal  reproducible example it's
difficult to do anything else.

Best wishes
Ulrik

Rui Barradas <ruipbarradas at sapo.pt> schrieb am Do., 1. Juni 2017, 17:30:
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.