similar to: any and all

Displaying 20 results from an estimated 10000 matches similar to: "any and all"

2024 Apr 13
1
any and all
Hi Avi, As D?nes T?th has rightly diagnosed, you are building an "all or nothing" filter. However, you do not need to explicitly spell out all columns that you want to filter for; the "tidy" way would be to use a helper function like `if_all()` or `if_any()`. Consider this example (I hope I understand your intentions correctly): ``` library(dplyr) data <- tribble(
2024 Apr 12
1
any and all
On 12/04/2024 3:52 p.m., avi.e.gross at gmail.com wrote: > Base R has generic functions called any() and all() that I am having trouble > using. > > It works fine when I play with it in a base R context as in: > >> all(any(TRUE, TRUE), any(TRUE, FALSE)) > [1] TRUE >> all(any(TRUE, TRUE), any(FALSE, FALSE)) > [1] FALSE > > But in a tidyverse/dplyr
2024 Apr 12
1
any and all
Hi Avi, As Duncan already mentioned, a reproducible example would be helpful to assist you better. Having said that, I think you misunderstand how `dplyr::filter` works: it performs row-wise filtering, so the filtering expression shall return a logical vector of the same length as the data.frame, or must be a single boolean value meaning "keep all" (TRUE) or "drop all"
2024 May 25
1
dplyr, group_by and selective action according to each group
Although there may well be many ways to do what is being asked for with the tidyverse, sometimes things are simple enough to do the old-fashioned way. The request seems to have been to do something to all rows in ONE specific group but was phrased in the sense of wanting to know which group your functionality is being called in. What grouping gains you is more worthwhile if you are interested in
2018 Mar 22
1
Calculate weighted proportions for several factors at once
Hi, I have a grouped data set and would like to calculate weighted proportions for a large number of factor variables within each group member. Rather than using dplyr::count() on each of these factors individually, the idea would be to do it for all factors at once. Does anyone know how this would work? Here is a reproducible example: ############################################################
2024 May 24
1
dplyr, group_by and selective action according to each group
Laurent: As I don't use dplyr, this won't help you, but I hope you and others may find it entertaining anyway. If I understand you correctly (and ignore this if I have not), there are a ton of ways to do this in base R, including using switch() along the lines you noted in your post. However, when the functions get sufficiently complicated or numerous, it may be useful to store them in a
2017 Nov 29
0
dplyr - add/expand rows
Hi Martin, On 11/29/2017 10:46 PM, Martin Morgan wrote: > On 11/29/2017 04:15 PM, T?th D?nes wrote: >> Hi, >> >> A benchmarking study with an additional (data.table-based) solution. > > I don't think speed is the right benchmark (I do agree that correctness > is!). Well, agree, and sorry for the wording. It was really just an exercise and not a full
2018 May 30
2
Filtering using multiple rows in dplyr
Hi Folks, I have just started using dplyr and could use some help getting unstuck. It could well be that dplyr is not the package to be using, but let me just pose the question and seek your advice. Here is my basic data frame. head(h) subject ageGrp ear hearingGrp sex freq L2 Ldp Phidp NF SNR 1 HALAF032 A L A F 2 0 -23.54459 55.56005 -43.08282
2023 Nov 07
1
make a lattice dotplot with symbol size proportional to a variable in the plotted dataframe
Hello. My question is in the subject line. Using R 4.1.3 on Windows 10. Commented MWE below. Thanks. --Chris Ryan library(dplyr) library(lattice) ## fabricate a dataframe dd <- data.frame(agency = sample(LETTERS, size = 5), total = sample(100:200, size = 5), las = sample(20:40, size = 5)) dd <- dd %>% mutate(proportion = las/total, bubble = total/100) ## attempt to make a dotplot
2017 Nov 29
2
dplyr - add/expand rows
On 11/29/2017 04:15 PM, T?th D?nes wrote: > Hi, > > A benchmarking study with an additional (data.table-based) solution. I don't think speed is the right benchmark (I do agree that correctness is!). For the R-help list, maybe something about least specialized R knowledge required would be appropriate? I'd say there were some 'hard' solutions -- Michael (deep
2020 Oct 30
3
Error: variable not found
Hello I have a question. I made an r-script and did a few commands needed to make some new variables. They all work out well, and when I run the commands, the new variables appear in the dataset. I can also work with these new variables to make other new variables from them. Also, when I use summary(dataset), those new variables appear in the summary of the dataset. But, when I do summary(new
2018 Jan 08
2
Replace NAs in split lists
Thank you Jeff. Your code works, as usual , perfectly. I am just wondering why if i put the whole code in one line, i get an error message. sdf2 <- lapply( sdf, function(z){z$Value <-ifelse(is.na(z$Value),z$Value[!is.na(z$Value)][1],z$Value)z}) error. unexpected symbol in sdf2 Thanks again EK On Mon, Jan 8, 2018 at 3:12 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: >
2017 Aug 07
1
tidyquant error downloading symbols for Index
Hi R Helpers, I recently tried to take advantage of the ability to download all the tickers in the S&P 500 using the functionality of tidyquant, but it threw an error. For summary, the set of commands that I ran was library(tidyquant) tq_index_options() tq_index("SP500") sessionInfo() R feedback including error message and sessionInfo are provided below. Guidance would be
2023 Apr 04
1
Simple Stacking of Two Columns
Just to repeat: you have NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly")) and you want NamesLong<-data.frame(Names=c("Tom","Dick","Larry","Curly")) There must be something I am missing, because NamesLong <- data.frame(Names = c(NamesWide$Name1, NamesWide$Name2)) appears to
2018 Jan 08
0
Replace NAs in split lists
Upon closer examination I see that you are not using the split version of df1 as I usually would, so here is a reproducible example: #---- df1 <- read.table( text= "ID ID_2 Firist Value 1 a aa TRUE 2 2 a ab FALSE NA 3 a ac FALSE NA 4 b aa TRUE 5 5 b ab FALSE NA ", header=TRUE, as.is=TRUE ) sdf <- split( df1, df1$ID ) # note the extra [ 1 ]
2023 Nov 03
2
Sum data according to date in sequence
Hi, I tried this: # extract date from the time stamp dt1 <- cbind(as.Date(dt$EndDate, format="%m/%d/%Y"), dt$EnergykWh) head(dt1) colnames(dt1) <- c("date", "EnergykWh") and my dt1 becomes these, the dates are replace by numbers. dt1 <- cbind(as.Date(dt$EndDate, format="%m/%d/%Y"), dt$EnergykWh) dput(head(dt1)) colnames(dt1) <-
2016 Apr 20
2
Data reshaping with conditions
Dear All, I am trying to reshape the data with some conditions. A small part of the data looks like below. Like this there will be more data with repeating ID. Count id name type 117 335 sally A 19 335 sally A 167 335 sally B 18 340 susan A 56 340 susan A 22 340 susan B 53 340 susan B 135 351 lee A 114 351 lee A 84 351 lee A 80 351 lee A 19 351 lee A 8 351 lee A 21 351 lee A 88 351 lee B 111 351
2017 Aug 14
2
tidyverse repeating error: "object 'rlang_mut_env_parent' not found"
Thanks for the feedback Jeff. Before I pursue a bug report, let me give a full example: ###### begin console output R version 3.4.1 (2017-06-30) -- "Single Candle" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: i386-w64-mingw32/i386 (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions.
2017 Nov 09
0
weighted average grouped by variables
Hello an update about my question: I worked out the following solution (with the package "dplyr") library(dplyr) mydf%>% mutate(speed_vehicles=n_vehicles*mydf$speed) %>% group_by(date_time,type) %>% summarise( sum_n_times_speed=sum(speed_vehicles), n_vehicles=sum(n_vehicles), vel=sum(speed_vehicles)/sum(n_vehicles) ) In fact I was hoping to manage everything in a
2023 Jan 15
2
Removing variables from data frame with a wile card
I am new to this thread. At the risk of presenting something that has been shown before, below I demonstrate how a column in a data frame can be dropped using a wild card, i.e. a column whose name starts with "th" using nothing more than base r functions and base R syntax. While additions to R such as tidyverse can be very helpful, many things that they do can be accomplished simply