I have a basic R problem, and hopefully someone can help me.
I want to analyse a dataset, but won't use all of the columns.
So I tried to short the columns:
We do not know what dataset or packages you're using, so it's difficult to help you. You'll get more helpful answers, if you ask questions in form of a reproducible example.
Most probably you're using aac_intakes_outcomes.csv as your dataset which is available here. Also, what is the select function you're using? There are many in different packages. I'm not sure about this one, so I'm using subset provided in the base package.
I'm giving you two ways to tackle this, but probably the one using readr can be improved.
dataset_1 <- read.csv(file = "aac_intakes_outcomes.csv")
# the name is changed automatically, which can be checked using names(x = dataset_1)
dataset_1 <- subset(x = dataset_1,
select = c(dob_year,
animal_type,
sex_upon_outcome,
outcome_year,
time_in_shelter_days,
age_upon_intake_.years.))
library(package = "readr")
dataset_2 <- read_csv(file = "aac_intakes_outcomes.csv")
# here, the original name will be retained
# note the use of `...` in names(x = dataset_2)
# also, it'll be displayed in console
dataset_2 <- subset(x = dataset_2,
select = c(dob_year,
animal_type,
sex_upon_outcome,
outcome_year,
time_in_shelter_days,
`age_upon_intake_(years)`))
If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it: