am looking at the data which i want to see the children how have never gotten every vaccination and i on want to select the row with variable "no" in 26 columns how can i go about it
If the columns are all next to one another you can use something like: filter(dataframe, across(10:36, ~ . == "no")) Where 10 is the column number of the first column in the block and 36 is the number of the last column in the block. If they aren't all grouped together you can still use across, but you have to name the columns: df_filtered % filter(across(c(col1, col2, col3, col4, ... col26), ~ . == "no"))
You can do this by combing dplyr with the stringr package. E.g.,: library(dplyr) library(stringr) df = data.frame(species = c("DM", "DO", "PP"), count = c(1, 2, 3)) filter(df, str_detect(species, "^D")) The ^D means "starts with D"
OK, so just to check. SUBSET is a a data frame, it has a column named Comuna, and there is at least one row in that column where the value is “Graneros”?
The most common cause of zero rows returned is either a typo in the value given in “” or a difference in the capitalization, since either of these can result in no matches
These classes are just great. Really helpful! Thanks a lot!
Thanks! So glad they are helpful!
great content! Thank you :)
thanks a lot!
am looking at the data which i want to see the children how have never gotten every vaccination and i on want to select the row with variable "no" in 26 columns how can i go about it
If the columns are all next to one another you can use something like:
filter(dataframe, across(10:36, ~ . == "no"))
Where 10 is the column number of the first column in the block and 36 is the number of the last column in the block.
If they aren't all grouped together you can still use across, but you have to name the columns:
df_filtered %
filter(across(c(col1, col2, col3, col4, ... col26), ~ . == "no"))
Hi, can we filter species_id all start with "D" with *? thanks.
You can do this by combing dplyr with the stringr package. E.g.,:
library(dplyr)
library(stringr)
df = data.frame(species = c("DM", "DO", "PP"), count = c(1, 2, 3))
filter(df, str_detect(species, "^D"))
The ^D means "starts with D"
@@weecology Many thanks. "filter(grepl("D", species,)) " works as well.😀
This code always return to me 0 observations and 12 variables, I don't know why, I don't know what to do
Can you paste the specific code here that isn’t working the way you expect?
@@weecology SampleRancagua = filter(SUBSET, Comuna == "Graneros")
Thank youuu :(
OK, so just to check. SUBSET is a a data frame, it has a column named Comuna, and there is at least one row in that column where the value is “Graneros”?
The most common cause of zero rows returned is either a typo in the value given in “” or a difference in the capitalization, since either of these can result in no matches
Yes, exaclty :(@@weecology