How to not include NA observations in grouping when using group_by() followed...
I have a dataframe of phone numbers, emails and names. Some emails are duplicated, with different name spellings. I don't really care about which name remains, so I am grouping by email, and...
View ArticleIs is possible to color path by elevation?
I'm using mapdeck::add_path() to show aircraft flight paths. I would like to color the paths by elevation; is this possible? Here is a short example:library(mapdeck) library(sf) # From...
View ArticleHow to sample a normally distributed population with a set mean and standard...
For demonstrations purposes, I want to sample 30 random observations from a normal distribution with a mean of 0 and a standard deviation of 2. I want to sample this "population" 10 times, so I will...
View ArticleHow do I exclude all values in a row where the first instance of this value...
I have a dataset, dfSubject Hi hello RE: Hello RE: How is work No Ok RE: What time are Hello RE: are you I would like to exclude all rows where the first word is RE:SubjectHi hello No Ok Hello RE: are...
View ArticleGet filename without extension in R
I have a fileABCD.csv The length before the .csv is not fixed and vary to any length.How can I extract the portion before the .csv.
View ArticleGetting R's scales::percent() function to evaluate 100% as greater than 20%
When I type percent(100/100) > percent(20/100), I get [1] FALSE. How do I get it to evaluate as true because 100% is definitely greate than 20%?Just to confirm that I'm actually trying to evaluate...
View ArticleExtract residuals only for two observations
Below is my code for a regression analysis.Reg <- lm(hgc94~father_hgc+edex79, data=NLSY_education) summary(Reg) After this process, how could I calculate/report only the first two respondent's...
View ArticleIn R, how do I randomly select (and average) groups of 3 and (and the...
I have 400 rows that have a bunch of columns, with the last five being: a,b,c,d,eFor each row, I want to randomly select three of the above 5 variables and do rowmeans(varx,vary,varz) to make column...
View ArticleHow to format beta0 and beta1 with confidence intervals in R?
I need to calculate β^0 and β^1 for a simple linear regression yi = β0 + β1xi with 87% confidence intervals for β0 and β1 and have to display my results with three significant digits in the following...
View ArticleCalculating row difference and insert into new column in R (without using for...
I have a huge dataset that I want to loop over each user in the first column and calculate interval column based on the difference (subtract) between each row with the next row of start_time column....
View ArticleMatplot Legend Text Font size using R studio
I am trying to plot a graph using the below code, but i am unable to change the font size of the legend. Please suggest the change/edit to make the legend text legible.Seasons <-...
View ArticleInsert rows based on difference between value from col A row N and col B row N+1
I have data with an example as follows (I use R):A B C 1 2 Background 3 19 Background 26 41 person 43 69 person 83 97 Background 107 129 Background 132 179 Background 189 235 Background 243 258...
View ArticleHow to change the Hover background color in ggplotly for bar chart
I using ggplotly to plot a graph. I am using the tooltip function to represent the values in the barchart when the cursor is moved on the top of the graphs. Source_Data <- data.frame( key = c(1, 1,...
View ArticleHow implement a curl request in R
How can I implement this curl request in R?"curl https://a.klaviyo.com/api/v1/campaigns -G \ -d api_key=xxxxxxxxx"Thanks in advanceAlex
View ArticleLaunch and terminate shiny app through terminal
How can I launch the Shiny App, "my_shiny" through the Terminal. Also How do I terminate or close the app through the terminal only.
View ArticleHow do I extract SAP ECC tables into R? Not SAP HANA
I find that there's very little documentation on how to extract SAP tables into R. I'm not talking about SAP HANA. Currently, it's very troublesome that I need to manually extract SAP tables using a...
View Articler loop optimisation (getMinBBox with sf and data.table)
I have some question how to speed up my code.I have a shp with more than 100000 polygons and I want calculate minimal bounding box for each of them. I found some code for this part here:...
View ArticleCreate new section and take time difference if time exceeds a certain amount...
I have a dataset, df, that has 10,000 rows:DateA 9/9/2019 7:52:16 PM 9/9/2019 7:52:16 PM 9/9/2019 7:52:17 PM 9/9/2019 7:52:18 PM 9/9/2019 7:52:18 PM 9/9/2019 7:52:19 PM 9/10/2019 1:02:23 AM 9/10/2019...
View ArticleGeospatial mapping using ggplot faceting in R?
I have a Watershed that has 33 subbasins. I wasn't able to come up with a code to draw a reproducible shapefile for the catchment so i am attaching my Shapefile. I have four models that generate...
View ArticleCount number of events in the previous time period
I trying to create a variable (the made up one "events60" in the data below, that keeps a "running" count of the number of events in the past (in this example it's 60 minutes, but it could be any...
View Article