logo
down
shadow

R QUESTIONS

R - How to use sum and group_by inside apply?
R - How to use sum and group_by inside apply?
wish helps you You can do this very quickly using data.table.Creating Dummy Data:
TAG : r
Date : November 23 2020, 04:01 AM , By : Talal Belal
For Each Loop to convert into numeric values
For Each Loop to convert into numeric values
this one helps. If it is already a factor variable, then simply convert to integer,i.e.
TAG : r
Date : November 23 2020, 04:01 AM , By : Conrex
How to summarise taking a random value from a categorical column?
How to summarise taking a random value from a categorical column?
like below fixes the issue Since you are using dplyr you can also take advantage of sample_n function, i.e.
TAG : r
Date : November 23 2020, 04:01 AM , By : user2185976
Predictions in SageMaker ::: Writing Function To Split Big Data-frame Into Batches For Predictions
Predictions in SageMaker ::: Writing Function To Split Big Data-frame Into Batches For Predictions
Hope that helps Have you considered using SageMaker Batch Transform instead for your use-case above? It takes care of streaming your data from S3 to the inference container and supports a few ways to split up your data. Please see https://docs.aws.am
TAG : r
Date : November 23 2020, 04:01 AM , By : yusufertekin
ggplot: How to keep marker colours in legend but hide text colours?
ggplot: How to keep marker colours in legend but hide text colours?
help you fix your problem You may specify the breaks manually too by the replacing the last line with
TAG : r
Date : November 23 2020, 04:01 AM , By : user2185832
Removing character elements from a vector
Removing character elements from a vector
it should still fix some issue The period is a meta character (see here), so try escaping it like so-
TAG : r
Date : November 22 2020, 04:01 AM , By : cytrax
Cumulative sum based on factor on R
Cumulative sum based on factor on R
help you fix your problem I have the following dataset, and I need to acumulate the value and sum, if the factor is 0, and then put the cummulated sum when I found the factor != 0. , If you want to stick with the for-loop, you can try this code :
TAG : r
Date : November 22 2020, 04:01 AM , By : Torbjörn Seiger
expand colnames to match the last known one
expand colnames to match the last known one
it helps some times Assuming you want to rename columns that start with "X", we could replace them with NA and then use na.locf to get previous names of the column.
TAG : r
Date : November 22 2020, 04:01 AM , By : Sai Sandeep
`testthat::expect_silent()` does not seem to notice ggplot2 errors
`testthat::expect_silent()` does not seem to notice ggplot2 errors
With these it helps Try capturing the output from ggplot and then testing if it can be printed:
TAG : r
Date : November 22 2020, 04:01 AM , By : user2185581
Parse Factor in R
Parse Factor in R
help you fix your problem I have a column of ID data (class factor) in the following format: 01-001 etc. , Looks like you want substr:
TAG : r
Date : November 22 2020, 04:01 AM , By : Babu110
Exit from Command prompt after running r script
Exit from Command prompt after running r script
this one helps. Yes, you have double quoted ONLY cd C:\ABCD; you had to double quote the whole sequence of the commands. Also, I would use operator, so your script will fail if path C:\ABCD doesn't exist. Also, if you want to terminate cmd after com
TAG : r
Date : November 21 2020, 04:01 AM , By : user2185431
R: write function with optional arguments
R: write function with optional arguments
will be helpful for those in need I m trying to write a function that build an API request. The difficulty: I want to use optinal arguments inside the function, and build the API request according to the presence of these optional arguments. Example:
TAG : r
Date : November 21 2020, 04:01 AM , By : user2185420
After full_join() how to replace NAs in one source with data from other source
After full_join() how to replace NAs in one source with data from other source
I wish this help you When joining two dataframes, how can I replace missing values in one dataset with values from the other dataset? , you could also do it in three lines with dplyr and the zoo package.
TAG : r
Date : November 20 2020, 04:01 AM , By : user2184848
Use reactive "if" statements in R Shiny
Use reactive "if" statements in R Shiny
around this issue Below are the headers of my dataframe (appliance) along with it's structure. , This is a shot, not fully tested:
TAG : r
Date : November 19 2020, 04:01 AM , By : Christian Cruz
Nested loop to find most recent comment
Nested loop to find most recent comment
Hope that helps Reverse the dataframe, then get the first non-NA value using dplyr::coalesce:
TAG : r
Date : November 19 2020, 04:01 AM , By : Dito
How to calculate common values across different groups?
How to calculate common values across different groups?
I wish did fix the issue. Another possible solution via dplyr is to create a list with all the combos for each customer, unnest that list, count and merge with a data frame with all the combinations, i.e.
TAG : r
Date : November 19 2020, 04:01 AM , By : Napster100
RStudio + Knitr + mind mapping
RStudio + Knitr + mind mapping
Hope that helps As your post does not contain valid TikZ/mindmap code, here is a reproducible example based on code examples found on TeXample.net.RMarkdown code
TAG : r
Date : November 18 2020, 04:01 AM , By : mdpdance
Filter a dataframe between two dates
Filter a dataframe between two dates
help you fix your problem I have a dataframe with dates column and some other column. I need to filter based on dates. , We can use grep to get row indices and then subset the dataframe.
TAG : r
Date : November 18 2020, 04:01 AM , By : Daniel Lucia García
Filter rows with earlier date than a row specified by another variable
Filter rows with earlier date than a row specified by another variable
may help you . With dplyr, you can group_by ID, arrange by date and select the rows before Med == 1
TAG : r
Date : November 18 2020, 04:01 AM , By : Nevena Menković
generate a vector between 0 and 1, with certain length and certain number of 1
generate a vector between 0 and 1, with certain length and certain number of 1
I wish this help you You can give two values for prob argument but this doesn't guarantee the distribution to be equal
TAG : r
Date : November 18 2020, 04:01 AM , By : Nikki Aiello
Looping multiple listed data frames into a single function
Looping multiple listed data frames into a single function
may help you . You were close, but I'll explain a bit how lapply (and mclapply) work, because it feels like you're mixing up what the role of x is. First, this should work:
TAG : r
Date : November 17 2020, 04:01 AM , By : user2184108
Problems importing .csv file due to presence of \ symbol
Problems importing .csv file due to presence of \ symbol
I hope this helps you . It looks like the csv-files you are trying to read don't comply with the official csv-standard (RFC-4180), so I think it's easiest if we brute-force our way through it.We can use readLines to read the raw data, gsub to edit th
TAG : r
Date : November 17 2020, 04:01 AM , By : Jm77345
R: filter/subset range of rows based on cells containing specific value
R: filter/subset range of rows based on cells containing specific value
I hope this helps . As there is only a single instance of 'identifier' that specifies the 'start/stop', use grep to get the row index that matches the pattern, get a sequence between the start and end (:) and subset the 'X2' values
TAG : r
Date : November 17 2020, 04:01 AM , By : TheYak
merging by common value in R
merging by common value in R
Does that help OK, I think I got it. I added these options: header = T, strip.white = T, na.strings = c(""), stringsAsFactors = FALSE and now data contains 181 observations. Strings were being imported as factors and the factors didn't match. Also, t
TAG : r
Date : November 17 2020, 04:01 AM , By : esraa
R - Conditionally select within duplicate IDs and index
R - Conditionally select within duplicate IDs and index
wish of those help We arrange the 'ID', 'fruit' based on the levels specified in the 'OP's post, and 'X' in 'descending' order, then grouped by 'ID', slice the first row
TAG : r
Date : November 17 2020, 04:01 AM , By : Sebastian Nassutti
Generate sequences of anniversary dates between 2 dates
Generate sequences of anniversary dates between 2 dates
I wish did fix the issue. I tried to generate a sequence of dates between two dates. By search all the old posts, I found very nice solution using seq.Date. , Here's an approach that also works in other cases:
TAG : r
Date : November 17 2020, 04:01 AM , By : Andres Teeääre
Have trouble creating a bar graph with ggplot with having both x and y variables
Have trouble creating a bar graph with ggplot with having both x and y variables
I hope this helps you . Well, you don't provide sample data but like the error says you need to set your stat to "identity" not "count". You can always use geom_col() as suggested by some of the comments. You would do something like:
TAG : r
Date : November 17 2020, 04:01 AM , By : Trung Nguyen
Function to remove near close proximity geolocations geometry in R
Function to remove near close proximity geolocations geometry in R
To fix the issue you can do edit4: it's working now :Dthis code probably looks pretty bad but it works decently for my use case and it's not too slow
TAG : r
Date : November 17 2020, 04:01 AM , By : user2183901
How to add legend and table with data value into a chart with different lines using ggplot2
How to add legend and table with data value into a chart with different lines using ggplot2
Hope this helps Part 1 - Fixing the legend Concerning the legend, this is not the ggplot-way. Convert your data from wide to long, and then map the what keys to the colour as an aesthetic mapping.
TAG : r
Date : November 17 2020, 04:01 AM , By : Jason Perlman
Adding non-numeric values to a histogram in SAS or R
Adding non-numeric values to a histogram in SAS or R
To fix the issue you can do SGPANEL can create output for each variable but will require some data manipulation to get the data columns needed for statements such as PANELBY and INSET. A histogram chart ignores missing values, and computes the histog
TAG : r
Date : November 17 2020, 04:01 AM , By : Bernard Christopher
Add variable labels within mutate
Add variable labels within mutate
wish help you to fix your issue I am in the process of reworking some old code in order to facilitate learning the tidyverse. In the previous code I would make new variables derrived from present variables, and I would give these new variables a labe
TAG : r
Date : November 16 2020, 04:01 AM , By : Quindo
Collapse matrix to vector and replace values with column names
Collapse matrix to vector and replace values with column names
may help you . Using the input matrix m defined reproducibly in the Note at the end if we matrix multiply it by 1:2 which is the same as multiplying each row by 1:2 which gives a vector with the same length as the number of rows such that each elemen
TAG : r
Date : November 15 2020, 04:01 AM , By : Arpit
Merge returning matrix of size x^2
Merge returning matrix of size x^2
seems to work fine I have two sf objects, one with 7 columns and 1273 rows, the other with 2 columns and 1273 rows that is returned from a function applied to the first object. , If you are merging by index try this:
TAG : r
Date : November 15 2020, 04:01 AM , By : Bill Poser
Fuzzy compare and aggregate similar records within a single single column data-frame
Fuzzy compare and aggregate similar records within a single single column data-frame
wish of those help The current requirement is to aggregate a single column and supply a count with the per row. There are a couple of issues that I am encountering that I need assistance with: , data.table solution
TAG : r
Date : November 15 2020, 04:01 AM , By : user2183298
Collapsing consecutive dates into a single row
Collapsing consecutive dates into a single row
may help you . I saw many threads about how to merge consecutive dates into a single row, and tried few of them (including this and using lead from dplyr), but so far didn't find thread that specifically answers my question. , You could go for someth
TAG : r
Date : November 15 2020, 04:01 AM , By : Matthew Doyle
How to change default color scheme in ggplot2?
How to change default color scheme in ggplot2?
it should still fix some issue I would like to change the default color scheme in ggplot2. That is, I would like to define a color scheme (say: viridis) at the one point in the script so that all subsequent ggplot diagrams will use this color scheme
TAG : r
Date : November 15 2020, 04:01 AM , By : user2183052
Color values in boxplot based on x-axis variable in ggplot
Color values in boxplot based on x-axis variable in ggplot
may help you . There are few (minor) syntax errors in your data. Nevertheless, you are probably looking for this:
TAG : r
Date : November 14 2020, 04:01 AM , By : rnm20
Loop in R, extracting the last line of the output
Loop in R, extracting the last line of the output
will be helpful for those in need Just include a return(Calculus2) at the end and have a break inside the if statement.
TAG : r
Date : November 14 2020, 04:01 AM , By : user2182937
Remove records matching a value on a single column occurring within a 5 minute window of a different value on the same c
Remove records matching a value on a single column occurring within a 5 minute window of a different value on the same c
this one helps. The beauty of R is that almost all operations are vectorized, so you can compare multiple things at the same time, and you don't need for loops.In this case you have to compare all values with the one directly before, which can be don
TAG : r
Date : November 14 2020, 04:01 AM , By : vani
How to efficiently apply a function on a number of matrices - mean of columns
How to efficiently apply a function on a number of matrices - mean of columns
I think the issue was by ths following , We keep the matrices in a list, use vapply to loop through the list and get the colMeans
TAG : r
Date : November 14 2020, 04:01 AM , By : Ashok Bhayal
Error when trying to build Rmarkdown site
Error when trying to build Rmarkdown site
With these it helps I had to delete the package and then reinstall it with the following contingencies. install.packages("stringi",type="mac.binary")
TAG : r
Date : November 14 2020, 04:01 AM , By : Magic
Different function output and print option in r
Different function output and print option in r
like below fixes the issue I have a data frame x and subject function. , No need to save output in a list at first place
TAG : r
Date : November 14 2020, 04:01 AM , By : user2182872
How to extract specific intervals of the dataset?
How to extract specific intervals of the dataset?
may help you . I have a big dataset (More than 200 thousand lines and a thousand of trials) with four columns with follow information: , As a first step, you want to split the data.frame, per Trial:
TAG : r
Date : November 14 2020, 04:01 AM , By : user2182835
Using Group by and Slope with dplyr to get new column
Using Group by and Slope with dplyr to get new column
This might help you Not sure you'd consider this any cleaner than what you had, but by using nest you don't need to group_by
TAG : r
Date : November 14 2020, 04:01 AM , By : Sd Ds
A better way to map data to a column in a dataframe?
A better way to map data to a column in a dataframe?
To fix this issue I have several large data frames that I need to merge, and sometimes add a unique identifiable column in order to merge them. I use this approach which works, but seems to take a long time. Basically, using dplyr, I grab the distinc
TAG : r
Date : November 14 2020, 04:01 AM , By : m1k3p
Creating initialise method for reference class in R
Creating initialise method for reference class in R
I hope this helps you . You need to actually modify the object and call your initialize method.
TAG : r
Date : November 14 2020, 04:01 AM , By : Oscar Armando Lozano
How to make all plots in gridarrange the same size. Some with labels on axes and others none?
How to make all plots in gridarrange the same size. Some with labels on axes and others none?
wish help you to fix your issue try the patchwork library:https://github.com/thomasp85/patchwork
TAG : r
Date : November 13 2020, 04:01 AM , By : shimon123123
Data perturbation - How to perform it?
Data perturbation - How to perform it?
hop of those help? Perturbing just means adding a small, noisy shift to a number. Your code might look something like this.
TAG : r
Date : November 13 2020, 04:01 AM , By : Lexxus080
r - getting vectors from rows in data.table
r - getting vectors from rows in data.table
Hope this helps I've got a big data.table that's been read in from a csv file (essentially the results of an SQL query). Each record has several sets of 20 fields which are the annual figures for a particular thing (eg, a particular type of payment).
TAG : r
Date : November 13 2020, 04:01 AM , By : dvz
Append column names as a row value
Append column names as a row value
To fix the issue you can do We can loop through the rows with apply, subset the names where the column values are 1, paste it together to create the 'cols' column in the new data.frame 'db2'. If needed, change the blanks ("") to -
TAG : r
Date : November 13 2020, 04:01 AM , By : Niraj Bhagchandani
How to replace strings with the matching string from a list?
How to replace strings with the matching string from a list?
wish help you to fix your issue Say I have a column df1$z with some "dirty" strings within , You may use the following sub solution:
TAG : r
Date : November 13 2020, 04:01 AM , By : user2182416
Comparison of single values in xts and data frame fails
Comparison of single values in xts and data frame fails
hope this fix your issue Got it! It's an R-version problem, not an xts-version problem.This is a known "infelicity" in isTRUE(), described here and fixed after version 3.5.
TAG : r
Date : November 13 2020, 04:01 AM , By : user2182392
How to use 2 columns in one function(t.test) after group by
How to use 2 columns in one function(t.test) after group by
I think the issue was by ths following , You didn't provide a clear input or expected output, but it looks like, e.g.,
TAG : r
Date : November 13 2020, 04:01 AM , By : shaggybutsmooth
using lapply and filter to subset dataframes with a pattern in the filtered columname
using lapply and filter to subset dataframes with a pattern in the filtered columname
I hope this helps you . Working with R * , You could do this...
TAG : r
Date : November 13 2020, 04:01 AM , By : X infinity
Why wont it let me add a legend to my graph on ggplot2 in R?
Why wont it let me add a legend to my graph on ggplot2 in R?
will be helpful for those in need The easiest way to do what you want is to merge your data. But you can also do a manual color mapping. I'll show you both below.Without merging your data
TAG : r
Date : November 12 2020, 04:01 AM , By : Sai Kumar
Avoid datatable greying out when recalculating
Avoid datatable greying out when recalculating
To fix the issue you can do I have a very simple Shiny app to show the CPU usage and available memory of the shiny server : , Try adding
TAG : r
Date : November 12 2020, 04:01 AM , By : user2182336
R: read strings in a data frame and record position of a specific letter
R: read strings in a data frame and record position of a specific letter
hope this fix your issue I have a data frame with a column containing strings and their scores. Is there a way to create a new data frame with position of a specific letter in each string and their scores. Here is a sample data frame , Another tidyve
TAG : r
Date : November 12 2020, 04:01 AM , By : Jashwa Lopez
sum up results of a recursive function within the same recursive function
sum up results of a recursive function within the same recursive function
like below fixes the issue The following returns the factor of n in its first component and the cumulative sum of all factorials to n in its second argument.
TAG : r
Date : November 12 2020, 04:01 AM , By : Nachi D
split dataframe by factor and name new df by the factor and addidtional description like "new_dataframe(factor)&quo
split dataframe by factor and name new df by the factor and addidtional description like "new_dataframe(factor)&quo
hope this fix your issue cluster_list
TAG : r
Date : November 12 2020, 04:01 AM , By : user2182087
Replace data from dataframe using other threshold table in R
Replace data from dataframe using other threshold table in R
hop of those help? I have 2 dataframes, the first has data for many months, and the second has threshold values (minimum and maximum, different for every month). Now I want to replace any values outside the thresholds with NA. , With base R:
TAG : r
Date : November 12 2020, 04:01 AM , By : user2182045

shadow
Privacy Policy - Terms - Contact Us © bighow.org