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
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 REPR oducible EX ample (reprex) .
If you've never heard of a reprex before, you might want to start by reading this FAQ:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
2 Likes
mara
March 11, 2019, 3:54pm
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
.
system
Closed
April 1, 2019, 4:01pm
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.