logo
down
shadow

R QUESTIONS

Very high CPU usage by Windows Defender when using doParallel's foreach in R
Very high CPU usage by Windows Defender when using doParallel's foreach in R
To fix this issue I think I've figured it out. My code creates thousands of temporary files to R's temp directory (in c:\Users\xxx\Local\Temp) if I have 20-30 threads. I think Windows Defender was going nuts scanning each one, even though it's on an
TAG : r
Date : January 02 2021, 06:48 AM , By : UpperLuck
The way UseMethod works in R
The way UseMethod works in R
hop of those help? , From ?UseMethod
TAG : r
Date : January 02 2021, 06:48 AM , By : jaset
R - count consecutive alphabets in a string
R - count consecutive alphabets in a string
To fix the issue you can do I want to know the length of maximum number of consecutive alphabets in a string (excluding order). for example: , Reduce it to a problem you've already solved:
TAG : r
Date : January 02 2021, 06:48 AM , By : mikhaelrasputin
Coalesce columns based on pattern in R
Coalesce columns based on pattern in R
I wish this help you Here's how I would do it. (a) Don't get "sample$PIDno" as a string - that's pretty useless. Just get the column names as strings. (b) We'll make a separate function that calls coalesce on all the columns in a data frame. This is
TAG : r
Date : January 02 2021, 06:48 AM , By : user103892
Get values from adjacent cells raster R
Get values from adjacent cells raster R
this will help See below my (sloppy) solution. I noticed the adjacent() function omit NA cells, so I modified it to remove that. The orientation for the extracted cells follows this order: "nw","w","sw","ne","e","se","n","s".
TAG : r
Date : January 02 2021, 06:48 AM , By : Tim Tyrrell
Efficient way of computing quadratic forms for outer product matrices
Efficient way of computing quadratic forms for outer product matrices
I hope this helps . You can half the timings by making use of the symmetry. I find it easiest to quickly write an Rcpp function:
TAG : r
Date : January 02 2021, 06:48 AM , By : Mostapen
Cluster groups of 1s in a binary matrix
Cluster groups of 1s in a binary matrix
Hope this helps I think clustering is the right approach here, but you choose a poor ( computationally expensive) method for the task. I would go for DBSCAN like this:
TAG : r
Date : January 02 2021, 06:48 AM , By : amy
Can I identify by row the first and last observation
Can I identify by row the first and last observation
this will help would like to identify the number of firms that start and end each month. The goal is to say by column how much firms start and end. , You can do
TAG : r
Date : January 02 2021, 06:48 AM , By : Jet Thompson
In mlr and parallelMap it possible to parallelize multiple levels? For example mlr.tuneParams and mlr.benchmark
In mlr and parallelMap it possible to parallelize multiple levels? For example mlr.tuneParams and mlr.benchmark
To fix the issue you can do You cannot parallelize across multiple levels currently with parallelMap. The level argument of parallelMap::parallelStart() only accepts a single level.This is a known limitation and probably won't change anymore in the f
TAG : r
Date : January 02 2021, 06:48 AM , By : Joe
POSIXct objects and time zones
POSIXct objects and time zones
hop of those help? You can use lubridate::force_tz() to change a timestamp which had an inaccurate timezone when it was read in:
TAG : r
Date : January 02 2021, 06:48 AM , By : user104292
How to change values in unnamed first column
How to change values in unnamed first column
hop of those help? How do I change the entries of the first column in the matrix returned by read_csv if it doesn't have a header? , If the first column is actually the rownames do the following
TAG : r
Date : January 02 2021, 06:48 AM , By : vdavidovski
Replace text between two symbols across the full string
Replace text between two symbols across the full string
Hope this helps How to Replace the string inside the semicolon and the comma to "X" using R regex.
TAG : r
Date : January 02 2021, 06:48 AM , By : Ben Brown
R with postgresql database
R with postgresql database
like below fixes the issue String literals in Postgres (and most flavors of SQL) take single quotes. This, combined with a few other optimizations in your code leave us with this:
TAG : r
Date : January 02 2021, 06:48 AM , By : vferman
Repeating calculation with different DF
Repeating calculation with different DF
wish helps you If these are repeatable calculations in a list, loop through the list with lapply and do the same code where we specify the first dataset from the anonymous function call (function(x) x)
TAG : r
Date : January 02 2021, 06:48 AM , By : Keniwan
How can I ask a great ggplot / lattice / base plot question?
How can I ask a great ggplot / lattice / base plot question?
wish help you to fix your issue First, follow the agreed-upon standards to ask a great R question and make a great R reproducible example (see this discussion): Share your data. Data small and simple enough to reproduce the problem. Don't overload re
TAG : r
Date : January 02 2021, 06:48 AM , By : Big Ant
Colon-Equals operator proper usage
Colon-Equals operator proper usage
With these it helps I used the := in R to perform some manipulations in my data set but the usage which I am implementing throws an error. , := only works in data.tablesThis should work
TAG : r
Date : January 02 2021, 06:48 AM , By : Lee KW
Changing values into numeric values
Changing values into numeric values
will be helpful for those in need For a base R option, we can try using sub to generate an arithmetic expression, based on the K or M unit. Then, use eval with parse to get the final number:
TAG : r
Date : January 02 2021, 06:48 AM , By : CSCI GOIN KILL ME
How can I make the output of my function (several ggplot2 graphs) an html file (displaying those graphs)?
How can I make the output of my function (several ggplot2 graphs) an html file (displaying those graphs)?
may help you . First, create a simple Rmarkdown file, that takes a parameter. The only objective of this file is to create the report. You can for instance pass a file name:
TAG : r
Date : January 02 2021, 06:48 AM , By : FuzzyHornet
Update a column in a data frame matching a list of values
Update a column in a data frame matching a list of values
This might help you Add a new data frame column with a value in a list1, matching a column value in data frame to the value that is present in another list list2. Both list1 and list2 are of same length , You could make a data frame to lookup e.g.
TAG : r
Date : January 02 2021, 06:48 AM , By : Dov
Create new levels by grouping existing levels
Create new levels by grouping existing levels
I wish this helpful for you Let's say I have sample data like this that is continuous d
TAG : r
Date : January 02 2021, 06:48 AM , By : dummyadresse
Trying to replace a set of numbers with zero in a dataframe
Trying to replace a set of numbers with zero in a dataframe
To fix the issue you can do I have a dataframe with three columns and a lot of rows. One of the columns includes numbers like 80803 and 9995. I want to replace the specific numbers 80803 and 9995 in this column with 0. , You can solve this issue in b
TAG : r
Date : January 02 2021, 06:48 AM , By : user170635
How do I produce a ggplot Log10 scale graph for one (Y) axis?
How do I produce a ggplot Log10 scale graph for one (Y) axis?
will be helpful for those in need tl;dr the range of your data (approx. 23-27) is too small to effectively use a log scale. You can set the breaks manually (see method 2 below), in which case it looks like ggplot is not respecting your request for a
TAG : r
Date : January 02 2021, 06:48 AM , By : zdyne
Filter the values in a variable in a dataframe which match a regular expression using grep in R
Filter the values in a variable in a dataframe which match a regular expression using grep in R
wish help you to fix your issue The 1:9 should be 1-9 and it would be grepl along with ^ to specify the start of the string and $ for the end of the string
TAG : r
Date : January 02 2021, 06:48 AM , By : Carlos Galdino
how to use parameterized query using R and Rpostgres so as to accept values contained in a variable as input to the psql
how to use parameterized query using R and Rpostgres so as to accept values contained in a variable as input to the psql
I wish this help you Parametrized queries are best done using bind -> send -> fetch.So Where you have used the ? expression in your dbGetQuery, this would be done in the
TAG : r
Date : January 02 2021, 06:48 AM , By : Malikul
How to supress code from showing up in Shiny UI?
How to supress code from showing up in Shiny UI?
fixed the issue. Will look into that further It should be easy to prevent "London" showing up at the top of the page, but I couldn't find how. , Take mylist out of fluidPage:
TAG : r
Date : January 02 2021, 06:48 AM , By : turret
Using the R cut function - how do the breaks and labels options work
Using the R cut function - how do the breaks and labels options work
To fix this issue I was looking for an clear explanation of the 'labels are constructed using "(a,b]" interval notation' - as described in the cut help file, which seemed to lack an explanation. , So I tested cut on some simple examples as follows:
TAG : r
Date : January 02 2021, 06:48 AM , By : Aki Björklund
stack the data frames on top of each other and return one single data frame
stack the data frames on top of each other and return one single data frame
should help you out There are a number of ways you can do this. The fastest way (especially for large data frames) is to use rbindlist() function for the data.table package:
TAG : r
Date : January 02 2021, 06:48 AM , By : suresh
How do I retrieve an element along with the list in which it resides from a list of lists?
How do I retrieve an element along with the list in which it resides from a list of lists?
To fix this issue Suppose, I am having a list of lists like below: , Could try:
TAG : r
Date : January 02 2021, 06:48 AM , By : Fred Morrison
Is there a way to find the indices of common (exactly the same) elements in a dataframe?
Is there a way to find the indices of common (exactly the same) elements in a dataframe?
I think the issue was by ths following , As the objective is to find the mean for each similar 'letter', it is better to group by 'letter' and get the mean of 'num'
TAG : r
Date : January 02 2021, 06:48 AM , By : Boyer C.
Count elements of many lists
Count elements of many lists
Does that help I have 10 lists and I want to know how many occurrences I have for each element.
TAG : r
Date : January 02 2021, 06:48 AM , By : Lars
How to convert a numeric form to date form
How to convert a numeric form to date form
it helps some times Use as.Date with the indicated format. If it is numeric convert to character first.
TAG : r
Date : January 02 2021, 06:48 AM , By : cautionsign
How do I extract the download link and download the file in R?
How do I extract the download link and download the file in R?
wish of those help I'm assuming this website is OK with you automatically crawling through it, if you're not sure, check its robots.txt and the site's policy on crawling.You actually have a lot of work ahead of you.
TAG : r
Date : January 02 2021, 06:48 AM , By : Imran
Filtering observations based on specific date condition using data.table
Filtering observations based on specific date condition using data.table
wish help you to fix your issue I have a set of observations, which are recorded every time a user has taken an action. I want to filter only those observations from a user which are six or more months apart. , This is a rolling-join variant of @Uwe'
TAG : r
Date : January 02 2021, 06:48 AM , By : Paul Schwarz
R Regex to identify 2 or 3 consecutive capitalized words in string [R]
R Regex to identify 2 or 3 consecutive capitalized words in string [R]
seems to work fine What you are looking for is to use the {1,2} operator instead of + to limit amount of repetitions.
TAG : r
Date : January 02 2021, 06:48 AM , By : jaredsmiller
Remove all objects from R environment whose names DO NOT contain a specific string
Remove all objects from R environment whose names DO NOT contain a specific string
it should still fix some issue I'd like to remove all objects from my RStudio environment where the object names DO NOT contain a given string. , You can do:
TAG : r
Date : January 02 2021, 06:48 AM , By : brennen
How to use group_by with summarise and summarise_all?
How to use group_by with summarise and summarise_all?
Does that help Here's an approach that breaks it into two problems and combines them:
TAG : r
Date : January 02 2021, 06:48 AM , By : amy
How to Calculate Industry Medians with Own Firm Excluded
How to Calculate Industry Medians with Own Firm Excluded
To fix the issue you can do Consider splitting by SIC groups and run across all its Firm values to exclude from median calculation. Specifically, using: by (for grouping into subset dfs) sapply (to iterate across Firm values and call median) unlist (
TAG : r
Date : January 02 2021, 06:48 AM , By : Giles
R: retrieve dataframe name from another dataframe
R: retrieve dataframe name from another dataframe
With these it helps You are almost there, the problem is that the dataset column from datasetselect is a factor, you just need to convert it to characterYou can add this line after the definition of datasetselect:
TAG : r
Date : January 02 2021, 06:48 AM , By : Tim Tyrrell
summarise function in R
summarise function in R
wish helps you I think rm.na=TRUE is added to the sum, and as TRUE is considered as 1, it sums your initial sum and 1. If you change TRUE to 2 for example
TAG : r
Date : January 02 2021, 06:48 AM , By : Hitesh Prajapati
extract a substring where the characters next to it varies using regex in r
extract a substring where the characters next to it varies using regex in r
help you fix your problem I have some strings like below. I need to extract color part from the strings. , These expressions might work:
TAG : r
Date : January 02 2021, 06:48 AM , By : snapshooter
Coefficient extraction from linear regression
Coefficient extraction from linear regression
may help you . We can loop through the column names of 'Dataset_SR' except the "Y" column
TAG : r
Date : January 02 2021, 06:48 AM , By : Ben Humphrys
How to round only the numeric values in a dataframe?
How to round only the numeric values in a dataframe?
may help you . The question did not include the data so we don't really know what the problem is precisely (please always provide a complete minimal reproducible example) but we have divided the answer into two sections based on two possibilities for
TAG : r
Date : January 02 2021, 06:48 AM , By : evegter
Within a table in R, how can I multiple all the values in a row by a value?
Within a table in R, how can I multiple all the values in a row by a value?
wish helps you I've created the following table in R: , You can use sweep
TAG : r
Date : January 02 2021, 06:48 AM , By : John Phipps
Object not found error in dplyr group_by and count
Object not found error in dplyr group_by and count
it helps some times The conflicts() function helped me get to the bottom of it! "count" was listed as a conflict so I edited the code to be r groundcover_test% group_by(season,site,treatment,transect)%>% dplyr::count(ground) Adding the double colon o
TAG : r
Date : January 02 2021, 06:48 AM , By : algoRhythm99
The proper way to vectorise an if-else tower in R
The proper way to vectorise an if-else tower in R
I wish did fix the issue. I came across the following post: Vectorized IF statement in R?, which deals with a vecotrisation of one if-else construct in R. However, I do not want to build nested $ifelse$ functions in R, is there another way to do this
TAG : r
Date : January 02 2021, 06:48 AM , By : Terrence Poon
How should I source custom functions into a RMardown file?
How should I source custom functions into a RMardown file?
Hope that helps Don't do that. Do what @N.Williams suggested: if you have code that is worth re-using, put it in a package. A package is much more than a script containing its functions. The documentation says what each of those functions should do.
TAG : r
Date : January 02 2021, 06:48 AM , By : afarouk
Why is := faster than `:=`()?
Why is := faster than `:=`()?
Hope that helps Usually, I use the functional form `:=`() to compute multiple columns in a data.table, thinking that this is the most efficient method. But I've recently discovered that it's slower than simply repeatedly using :=. At least on my comp
TAG : r
Date : January 02 2021, 06:48 AM , By : mitry
How to predict future values of time series using h2o.predict
How to predict future values of time series using h2o.predict
I think the issue was by ths following , H2O-3 does not support traditional time series algorithms (e.g., ARIMA). Instead, the recommendation is to treat the time series use case as a supervised learning problem and perform time-series specific pre-p
TAG : r
Date : January 02 2021, 06:48 AM , By : zdyne
How to merge two data frames with only some matching column names and some matching values within that column?
How to merge two data frames with only some matching column names and some matching values within that column?
Hope that helps I have two data frames that I am trying to combine. There are two columns within each data frame that have matching titles, lets say "State" and "City". , innerjoin using both the columns
TAG : r
Date : January 02 2021, 06:48 AM , By : Zinovate
Substracting means of the elements from list
Substracting means of the elements from list
hope this fix your issue I have the following list:
TAG : r
Date : January 02 2021, 06:48 AM , By : user113409
Adding image to flextable and generate my flextable in Word document using Rmarkdown
Adding image to flextable and generate my flextable in Word document using Rmarkdown
will be helpful for those in need Yes, insertion of images in flextable is not supported with rmarkdown::word_document.You will need package officedown to be able to embed images in flextable with R Markdown for Word. You only need to replace output:
TAG : r
Date : January 02 2021, 06:48 AM , By : TomL
colnames() behaviour with data.table in R
colnames() behaviour with data.table in R
it helps some times We need to use copy to avoid it getting changed after the assignment based on the documentation of ?copy
TAG : r
Date : January 02 2021, 06:48 AM , By : Simon Capewell
How to deal with instable second in dataframe datetime column to get minutely data?
How to deal with instable second in dataframe datetime column to get minutely data?
should help you out Here is what I think you are after.Even though I'd recommend reviewing the source data.
TAG : r
Date : January 02 2021, 06:48 AM , By : Brian Cupps
How to Create Each Possible Pair in a matrix
How to Create Each Possible Pair in a matrix
seems to work fine I have a problem I'm not sure how to approach. I have a list of items in a matrix and I want to create a matrix that instead holds every possible combination of two of those items. , We can use expand.grid
TAG : r
Date : January 02 2021, 06:48 AM , By : user121350
Take the minimum date/value of a each row after the first NA and before the last NA?
Take the minimum date/value of a each row after the first NA and before the last NA?
wish of those help I am attempting to take the minimum date in a sequence of dates that is after all NAs before that sequence, and the only thing after that sequence is either NAs, or, that date sequence is the last columns. , Here is an option in ba
TAG : r
Date : January 02 2021, 06:48 AM , By : Suresh S
How can I use paste within an lapply function?
How can I use paste within an lapply function?
seems to work fine Hi there so simply I have a list of dataframes with names. , A summary of the three main options discussed so far:
TAG : r
Date : January 02 2021, 06:48 AM , By : Diego
Reshaping rows to lists by variable in R
Reshaping rows to lists by variable in R
seems to work fine I have a data frame that looks like this: , We create a sequence column by 'id' and then use the spread
TAG : r
Date : January 02 2021, 06:48 AM , By : kameel
Is there an R function for finding to parse correctly txt files?
Is there an R function for finding to parse correctly txt files?
Any of those help I have a test.txt file that has 7 headers. but not each row has 7 values. My txt file was showing only 1 column and I used read.delim to separate the columns. But when I count the unique values per column I have a different output t
TAG : r
Date : January 02 2021, 06:48 AM , By : Jakub Filak
What does the tilde mean in this context of R code
What does the tilde mean in this context of R code
will help you The tilde operator in R is a general operator that creates a formula object.However, the usage in your specific pieces of code is a special case of that: purrr co-opts formulas to implement an anonymous function notation. You can read m
TAG : r
Date : January 02 2021, 06:48 AM , By : Dave
load packages in a loop via `library()`
load packages in a loop via `library()`
should help you out Instead of loading 30 packages each with the library function is it possible to do this in a loop? , The parameter character.only can be used for that. Example:
TAG : r
Date : January 02 2021, 06:48 AM , By : Jouni

shadow
Privacy Policy - Terms - Contact Us © scrbit.com