logo
down
shadow

NSE in tidyverse with select()


NSE in tidyverse with select()

By : nicolai
Date : November 20 2020, 07:00 PM
fixed the issue. Will look into that further I have read a few stackoverflow questions on NSE with dplyr (here, here and here), but I am still struggling to apply it to my use.
code :
yup <- yo %>% select(!!newnames[i] := meh)

> yup
# A tibble: 10 x 1
     ABX
   <int>
 1    11
 2    12
 3    13
 4    14
 5    15
 6    16
 7    17
 8    18
 9    19
10    20


Share : facebook icon twitter icon
conditionally transpose select rows using tidyverse

conditionally transpose select rows using tidyverse


By : user3236042
Date : March 29 2020, 07:55 AM
seems to work fine We can replace the multiple 't's in the 'type' column to make it same, then use unite specify the remove = FALSE to keep the initial columns as well and spread
code :
library(dplyr)
library(tidyr)
library(stringr)
df %>% 
   mutate(type = str_replace(type, "t{2,}", "t")) %>%
   unite(new_name, Name, eval, test, remove = FALSE) %>% 
   spread(type, score)
#       new_name Name   eval test postest pretest
#1  Jane_first_1 Jane  first    1      20      40
#2  Jane_first_2 Jane  first    2      20      10
#3  John_first_1 John  first    1      15      10
#4  John_first_2 John  first    2      30      20
#5 John_second_1 John second    1      50      35
#6 John_second_2 John second    2      10       5
 ...%>%
    pivot_wider(names_from = type, values_from = score)
I am trying to select certain measurements that were taken at Noon using Lubridate and Tidyverse

I am trying to select certain measurements that were taken at Noon using Lubridate and Tidyverse


By : user3355689
Date : March 29 2020, 07:55 AM
this one helps. So I load in my data into R and load the libraries that I believe I will be needed: , This is probably not the best way to do it, but you could try:
code :
library(dplyr)
filter(data, substr(Date, 12, 20) == "12:00:00")
Pasting into tidyverse's select()

Pasting into tidyverse's select()


By : Bruno Cortez
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The dataset I am working on looks like this , You should use select_at rather than select
Data
code :
df <- data.frame(a=100, b=120, vara_1="a", vara_2 = "b", vara_3 = "c",
            varb_1 = "d", varb_2 = "e", varb_3 = "f")

    # a   b vara_1 vara_2 vara_3 varb_1 varb_2 varb_3
# 1 100 120      a      b      c      d      e      f
thesecols <- c("a", "b", paste0(c("vara_", "varb_"),rep(1:3, each=2)))
library(dplyr)
df %>%
    select_at(vars(thesecols))

    # a   b vara_1 varb_1 vara_2 varb_2 vara_3 varb_3
# 1 100 120      a      d      b      e      c      f
Error in library(tidyverse) : there is no package called ‘tidyverse’

Error in library(tidyverse) : there is no package called ‘tidyverse’


By : John Moody
Date : March 29 2020, 07:55 AM
like below fixes the issue I'd put this in a comment as well but it doesn't work in that format. I'm kinda hoping the actual comment has the solution so this question can be marked as a duplicate.
The output actually did give instructions, but it's all smushed together and somewhat foreboding (which is somewhat appropriate given the proximity to Halloween).
code :
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
 * deb: libxml2-dev (Debian, Ubuntu, etc)
 * rpm: libxml2-devel (Fedora, CentOS, RHEL)
 * csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
tidyverse problems when loading tidyverse in .Rprofile

tidyverse problems when loading tidyverse in .Rprofile


By : Soumya Kar
Date : March 29 2020, 07:55 AM
may help you . Did you try using dplyr::filter? There is a filter function by default in R, so you need to specify that is the dplyr's filter. Try with tibble(a = 1:5) %>% dplyr::filter(a > 4)
Related Posts Related Posts :
  • How do I interpret rpart splits on factor variables when building classification trees in R?
  • How to better create stacked bar graphs with multiple variables from ggplot2?
  • Building all combinations of a vector - looking for a nicer way
  • Fetching comments from tweets of a single user in R
  • Replace space between two words with an underscore in a vector
  • Alternate tick labels in grouped ggplot to avoid overlap in R
  • How to split a table by one column in R?
  • writing to a dataframe from a for-loop in R
  • How to create a data.frame with a unknown number of columns?
  • R dplyr's group_by consider empty groups as well
  • injection from R^d to [0,1]^d
  • Parsing a vector in R
  • What is 'n' column in the below output?
  • Lattice: multiple plots in one window?
  • R - If statement function to set value of new column
  • Avoiding seasonality assumption for stl() or decompose() in R
  • Cannot add new library path to .libPaths()
  • What's the higher-performance alternative to for-loops for subsetting data by group-id?
  • package ‘fpc’ is not available (for R version 3.5.3)
  • R - Convert CHR to Date
  • Get characters after and before a pattern match in R
  • Subtract even columns from odd ones in a data frame
  • Changing numbers in a string
  • Using && for character vectors in r
  • Why am I getting this New York output alone?
  • Saving H2o data frame
  • In R, when using named rows, can a sparse matrix column be added (concatenated) to another sparse matrix?
  • How to convert hourly data to 6/12/24 hourly data
  • Crosstab with multiple items
  • count words with for loop in R
  • Replace cos^..(...) by (cos(...))^
  • Is there a Pair-Wise PostHoc Comparisons for the Chi-Square Test in R?
  • How do I specify random factors in R?
  • ANOVA with 3 fixed factors in R
  • convert numbers written in words to numbers using R programming
  • In R, how can I look up a value in one column based on an interval in adjoining columns that includes values I want to m
  • Convert Date in YYYYMM to YYYY-MM-DD
  • grep does not show all the indices, only [1]1
  • Normalizing a dataframe having several conditions, R
  • What is the equivalent of "everything()" operator in "data.table"?
  • The colors in ggplot do not correspond to the colors in the legend
  • How to add to each column of dataframe value from named vector?
  • Losing data while saving csv character file
  • How to target arbitrary HTML attribute containing space in R?
  • Iterate over a column and find the sum
  • reference another column with tidyeval in filter
  • How to create a new variable by comparing two other variables
  • Retrieving elements that are occurring after adding a fixed number from a start element in a vector
  • Get total mean for variables nested in a list of lists of lists
  • Render Xaringan Rmd when using _site.yml file
  • Regex: matching multiple patterns and getting middle of string
  • removing for loop with sample function
  • R: scraping additional data after POST only works for first page
  • R - Add ticks on top of plot with levels in variable?
  • How to avoid factors in R when reading csv data
  • Meaning of :: syntax
  • How to get month and week of the month from year and week no in R?
  • Can you save R code files with .RData objects for version control?
  • How to connect points of two different plots to each other using ggplot in R?
  • Is there an R function for finding the value below specific value
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk