Why am I receiving a map_lgl error using dplyr for filtering my data?

dplyr
#1

Hi, I am trying to work with acs data.

I am trying to filter the data, however I am receiving an error
Error in map_lgl(.x, .p, ...) : object 'NameE' not found

Please find below the data and the repex


acsdata <- read.csv("Compiled_Project1.csv",header=T)
attach(acsdata)
colnames(acsdata) <- c("GISJOIN","Year","ZCTA5A","NAmeE","Total_Population","Median_Income","NameM",'PopM','IncomeM','City','State')
head(acsdata)
library(dplyr)
filteredacs <- select(filter(acsdata, State == 'OH'),c(Year,NameE,Total_Population,Median_Income,NameE,City,State))
filteredacs
GISJOIN Year ZCTA5A       NAmeE Total Population Median Income       NameM PopM IncomeM
1  G00601 2014    601 ZCTA5 00601            18088         10833 ZCTA5 00601  295    1531
2  G00602 2014    602 ZCTA5 00602            40859         16353 ZCTA5 00602  154     977
3  G00603 2014    603 ZCTA5 00603            53162         16323 ZCTA5 00603  657     872
4  G00606 2014    606 ZCTA5 00606             6415         14138 ZCTA5 00606  264    2157
5  G00610 2014    610 ZCTA5 00610            28805         17265 ZCTA5 00610  163    1065
6  G00612 2014    612 ZCTA5 00612            66251         17752 ZCTA5 00612 1289     783
       City State
1  Adjuntas    PR
2    Aguada    PR
3 Aguadilla    PR
4   Maricao    PR
5    Anasco    PR
6   Arecibo    PR
0 Likes

#2

Variable names are case sensitive so "NAmeE" is not equal to "NameE", I can't tell for sure if that is the only problem since, your code is not actually reproducible and your sample data is not on a copy/paste friendly format, please try to make a proper REPRoducible EXample (reprex).

If you've never heard of a reprex before, you might want to start by reading this FAQ:

2 Likes

#3

Based on the code snippet you posted, it looks like there isn't a column NameE:

colnames(acsdata) <- c("GISJOIN","Year","ZCTA5A","NAmeE","Total_Population","Median_Income","NameM",'PopM','IncomeM','City','State')

You have "NAmeE" and "NameM", but, as @andresrcs mentioned, R is case-sensitive, so neither of those match NameE.

0 Likes

closed #4

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

0 Likes