Hi everybody , I,m trying to select a set of data but when I executed the filter() don't show any error but when I review the don't show nothing
library(dplyr)
library(stringr)
library(gapminder)
library(tidyverse)
paa_codazzi2 <- paa_codazzi %>%
rename(Entidad = ...1,Codigo = ...2, Descripcion=...3,Fecinicpro = ...4,fecpofer = ...5,plazo = ...6,unidad_plazo = ...7,modalidad = ...8,fuente = ...9,valor =...10,vlrvigactu = ...11)
list_codigos<-c("42203605","4323","81111","81112","81122","81123","81161501")
paa_codazzi3<-mutate(paa_codazzi2,indicador=" ")
filter(paa_codazzi3,paa_codazzi3$Codigo %in% list_codigos)
cesarcruz01:
paa_codazzi
It looks like it should work. Can you provide a reproducible example of paa_codazzi
?
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.…
If you want to keep the result of filter() you should use <- to assign the result to a name that you can call and review later.
Filter in R is one of temporary o/p functions , that's why you you've to assign a variable for filter function ,
df1 <- filter (....,......)
then using df1 in next steps will keep filter results every time.
Thank you William , using the reprex I realized the data type of codigo column is numeric not a string , now I´m trying to convert this column as character. If you can give me any guidance about how make this I appreciate.
This should work.
paa_codazzi3 <- paa_codazzi2 %>%
mutate(indicator = " ",
Codigo = as.character(Codigo)) %>%
filter(Codigo %in% list_codigos)
Thank you William this works very well, I save a lot time. Thank you so much
1 Like
system
Closed
July 22, 2021, 2:08pm
8
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.