Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
25 views

I'm using the following to generate a column plot of my data. But despite converting the variable Recommendations into a leveled factor, the Y-axis labels still are NOT ordered the way they are listed ...
Simon Harmel's user avatar
  • 1,489
1 vote
2 answers
153 views

I have the following function to read a CSV file from Azure: read_csv_from_azure <- function(file_path, container) { # Try to download the file and handle potential errors tryCatch({ # ...
Enes's user avatar
  • 149
0 votes
2 answers
63 views

I have a dataframe with two columns in R. One of the columns (column1) has three possible values (A, A and B, B). The rows are patients. I want to transpose column1, so I'd have binary columns (Yes, ...
roybatty's user avatar
  • 105
0 votes
1 answer
47 views

By using tidyverse, I want to calculate standard deviation of alt_freq column grouping by rsid in a data frame. In each group, I want to consider only those rows which have at least 100 samples. I ...
Ömer A.'s user avatar
  • 677
4 votes
2 answers
3k views

Curious why the following produces an "NAs introduced by coercion" warning # Example dataframe df <- tibble( session = c("a",2), ) df %>% mutate(sessionNum = case_when( ...
Alex Holcombe's user avatar
0 votes
1 answer
35 views

I have two dataframes with different columns and different row sizes library(tidyverse) tb1 <- tibble(id= 1:10, a= 1:10, b=11:20) tb2 <- tibble(id= 1:5, ...
mr.T's user avatar
  • 634
4 votes
2 answers
156 views

Hello, The problem First, let me try to illustrate the problem. Assume I want to apply the following cipher to encode the string, "abc". library(tidyverse) cipher <- tibble( byte = c(...
jatx50's user avatar
  • 127
0 votes
0 answers
50 views

I import, clean, and merge two different data sets that are created from Qualtrics surveys. I use read.csv to load the data, and I have strip.white=TRUE to remove leading and trailing spaces. If I ...
Cam McM's user avatar
0 votes
3 answers
135 views

I'm trying to create new dataframes with the top three values for each column across a dataframe. probUnweighted <- data.frame( Sample1 = c(0.9, 0.2, 0.03, 0.1, 0.5, 0.09), Sample2 = c(0.045, 0.11,...
Chris Stantis's user avatar
1 vote
2 answers
66 views

I would like to remove a string from one column across a group of rows in another column. In the below reprex, I would like to remove the string in snippet from the string in text in any row in the ...
maia-sh's user avatar
  • 641
1 vote
2 answers
319 views

I am trying to select or subset multiple data frames with different number of columns. They all contain the same columns of interest, so I am trying to make them all contain the same columns so I can ...
Victor Shin's user avatar
1 vote
2 answers
50 views

Problem: I have a survey dataset which includes intra-household relationships. I had to subdivide household into tax-unit, which means I need to redefine the relationship matrices based on the new tax-...
ravinglooper's user avatar
0 votes
1 answer
52 views

I'm using the purrr::map function to iterate over several columns and tidy the result. for a short example, I provide the following code: library(tidymodels) library(broom) > penguins %>% + ...
user23485480's user avatar
3 votes
2 answers
71 views

I am trying to create a bar chart that has the number of each species grouped into years. I want each year represented on the x axis with the number of each of the 3 species grouped next to one ...
Anna's user avatar
  • 61
0 votes
1 answer
51 views

I'm expanding this post -- answered by @edwards (Thanks). I'm working with panel data. We assessed children in 2019, 2020, 2021 and 2022. Therefore, I have four datasets (2019, 2020, 2021, and 2022). ...
Luis's user avatar
  • 1,574
0 votes
1 answer
50 views

This is my code library(tidyverse) # Criar um dataframe de exemplo com dados de futebol dat <- tibble( continent = rep(c("Asia", "Europe", "Africa", "Americas&...
Laura's user avatar
  • 759
0 votes
1 answer
73 views

I'm working with panel data. We assessed children in 2019 and 2020. Therefore, I have two datasets (2019 and 2020) and I want to create a third dataset matching the data from the second dataset (2020) ...
Luis's user avatar
  • 1,574
5 votes
5 answers
150 views

I would like to convert a list like this into a tibble. lst <- list( "A"=list( "Category"="A", "Team"=c("x"), "City"="...
mindlessgreen's user avatar
0 votes
2 answers
74 views

This feels like it should be easier than it is but here we go. I have a data frame that looks like this: to.csv = structure(list(geography = c("030223131022122122", "030223131220201023&...
Priya Patel's user avatar
1 vote
3 answers
81 views

I'm a reasonably experienced R user who has often struggled to use the apply family. I have very slow-moving iterative code whose performance I'm hoping to improve through the use of this family, but ...
St4096's user avatar
  • 87
2 votes
2 answers
104 views

Context: I have a dataframe of individual people grouped by household, which includes relationship parameters for each individual describing their relationship to every other individual in the ...
ravinglooper's user avatar
0 votes
1 answer
100 views

I have the following dataset in R crude_data <- structure(list(date = structure(c(19570, 19601, 19631, 19662, 19692, 19723, 19754, 19783, 19814, 19844, 19875, 19905, 19936, 19967, 19997, 20028, ...
Tanga94's user avatar
  • 867
3 votes
4 answers
117 views

Let's say I have a regular latitude/longitude grid and data at irregular locations, like this: grid = tidyr::crossing(lon = seq(0, 1, 0.25), lat = seq(0, 1, 0.25)) data = tibble::tibble(lon = runif(4),...
sieste's user avatar
  • 9,177
0 votes
1 answer
52 views

I'm trying to find a way to sample N whole groups from a dataframe. For example, if we had the below dataframe: group value 1 a 1 2 a 2 3 a 3 4 b 4 5 b ...
ravinglooper's user avatar
1 vote
2 answers
72 views

I have the following dataset (below). I am trying to get the latest SEnd value for each individual tag (see Desired output) where I have the Tag, Owner and the latest SEnd date only. Essentially I am ...
pat's user avatar
  • 105
0 votes
1 answer
63 views

Here is my code : plan(multisession,workers=detectCores()-2) future_map_dfr(.x= Liste_model[1:2],.f = summaryModel, df = DF_MODEL_TRAIN, df_test = DF_MODEL_TEST, df_global = DF_MODEL_GLOBAL, .id = &...
Rgrvkfer's user avatar
  • 417
1 vote
2 answers
90 views

Please consider the following data frame: df <- structure(list(oID = c(37751L, 30978L, 33498L), peId = c(12L, 13L, 14L), last_Name = c("ABC", &...
deschen's user avatar
  • 11.6k
1 vote
1 answer
127 views

I just want to add some text of real means and sd to my plots when I'm working with one outcome or multiple outcomes. see the pictures below for reference. Code is below. If any updated package ...
Luis's user avatar
  • 1,574
0 votes
0 answers
88 views

I have a question about an issue that's similar to this older question about the dplyr::filter() function, except that my example is a bit more complicated because dplyr::mutate() needs to process ...
stachyra's user avatar
  • 4,613
1 vote
1 answer
30 views

I wonder if there is a way for my DATA to be reformatted to my Desired_output below? Specifically, for each unique study, we stick together a pair of pre and postNUMBER together, separately for T and ...
Simon Harmel's user avatar
  • 1,489
1 vote
2 answers
72 views

My goal is to create a binary variable (k) that turns 1 if in any column between mpg and wt the values 3.90 and/or 160.0 appears. Code library(tidyverse) mtcars<-mtcars%>% mutate(k=ifelse(mpg:...
Amc's user avatar
  • 159
0 votes
1 answer
34 views

I am conducting some survival analysis and an attempting to turn my wide table into long format for analysis using dplyR. I want to turn the value of 'dead flies' into rows with a binary status for ...
Dan Pritchard's user avatar
0 votes
0 answers
72 views

Using the iris dataset, we can make a boxplot and customise the legend when plotting using ggplot like so: ggplot(data = iris, aes(x=Species, y=Sepal.Length, fill=Species))+ geom_boxplot()+ ...
Ginko-Mitten's user avatar
0 votes
1 answer
71 views

I have a dataframe with a column indicating choices (of a survey) as well as a column indicating the index of the choice made in each row. e.g., df <- tibble( record_id = 1:9, choices = c(rep(&...
sometimes_sci's user avatar
4 votes
1 answer
81 views

When I apply a facet_grid, sometimes the labels are quite wide, sometimes so wide that they don't fit, and I have to rotate them. This isn't a problem unless I want to facet by multiple different ...
Dan's user avatar
  • 286
0 votes
1 answer
96 views

By running the following function, the output would be: library(pmsampsize) pmsampsize(type = "s", csrsquared = 0.5, parameters = 10, rate = 0.065, timepoint = 2, meanfup = 2.07) NB: ...
elisa's user avatar
  • 105
0 votes
1 answer
72 views

I have files from ERA5 that have extent from 0 to 360 (lon) and -90 to 90 (lat) Example: > era5_sr class : SpatRaster dimensions : 721, 1440, 744 (nrow, ncol, nlyr) resolution : 0.25, 0....
herakles_1950's user avatar
1 vote
2 answers
45 views

This seemed really simple to me at first, but is unexpectedly giving me trouble. Let's say my dataset looked like this: mock <- tribble(~case_id, ~characteristic, 1, "A&...
daltoncito5034's user avatar
1 vote
2 answers
71 views

I'm dealing with dates and I wanted to group some rows together but I can't find how. In my data, one row is an individual in a time interval and in a place. Something like that : ind place ...
jrdavalos's user avatar
3 votes
4 answers
81 views

the below example is to obtain the min value among 3 columns, we can use the pmin(V1, V2, V3). if we have lots of columns, how to get the minimal value among all numeric variables especially using the ...
ynsec37's user avatar
  • 91
1 vote
1 answer
72 views

I wonder how to dplyr::filter() my DATA to catch the rows for IDs whose Language value when 'Type!=5F' and when 'Type==5F' changes from other languages to "English"? For example, ID==1 has ...
Simon Harmel's user avatar
  • 1,489
2 votes
2 answers
41 views

I've tried to wide-format my DATA into my Desired_output using: pivot_wider(DATA, names_from = Year, values_from = c(Type, Language)) without success. Is there a way to achieve my Desired_output? ...
Simon Harmel's user avatar
  • 1,489
-2 votes
1 answer
260 views

I need to utlize the named sentiment dictionary for my sentiment analysis in R studio. Unfortunately I have problems at that. The dictionary comes within a zip archive and specifically (as I assume) ...
user23820003's user avatar
5 votes
3 answers
103 views

I have the first paragraph of Wikipedia articles from the wikifacts package (only for people). I like to extract birth year and year of death. library(wikifacts) library(tidyverse) politicians <- ...
Marco's user avatar
  • 2,887
1 vote
1 answer
1k views

I have already tried the previous solutions displayed by some users. I have tried removing and reinstalling Matrix and lme4 packages. To make matters worse, now R is unable to install lme4 or Matrix ...
Ramanpreet Kaur's user avatar
1 vote
3 answers
192 views

I wrote an R function to classify rows (individuals) based on the columns output in an incidence matrix M5 for the following requirements: M5 <- structure(c(1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1,...
MYaseen208's user avatar
  • 24.1k
1 vote
1 answer
59 views

I've spent most of the day on this and finally calling in some help. There are multiple entries here on related questions, but none that quite get at what I'm trying to do. Below is an example df. x &...
Scott Davidson's user avatar
1 vote
1 answer
108 views

In Tidyverse there are limitations concerning the row number resulting from some data processing. Most prominent, mutate expects that the row number equals to the original data set. For example, if we ...
LulY's user avatar
  • 1,385
-2 votes
2 answers
195 views

In the book R for Data Science, there is an operator %$%, as in the example code below. But when I run that code, I get the error message "there is no such operator". Can anyone help with ...
anderwyang's user avatar
  • 2,547
0 votes
1 answer
107 views

The name of my variables looks like this: df <- data.frame(var_NA = 1:10, var = 11:20, var_Level = 21:30, var_Total = 31:40) Except I have lots of variables. The key feature is that for every &...
luchonacho's user avatar
  • 7,295

1
3 4
5
6 7
206