Category "r"

Split a data frame by median

I would like to divide my data based on the median into high and low. I want to put it in one column. df <- data.frame(salary = c(623.3,515.2,611.0,729.0,843

Is it impossible to install R 4.0 on Ubuntu 18.04.4 LTS because r-base-core requires a libc6 version >= 2.29?

I am trying to install R 4.0 on Ubuntu 18.04.4 LTS but I keep getting errors of > sudo apt install r-base-core Reading package lists... Done Building depen

How to use jupyter notebook with R kernal in VS code?

Now I can use jupyter lab with R kernal in a web browser and use VS Code to edit jupyter note book code with python kernal, is it possible to edit R code in VS

Filling a column based on the value of another column in data.table

I have data as follows: dat <- structure(list(amount_of_categories = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ), mun

R: Is there a way to round to 1 decimal place in table1 for continous variables?

Is there a way to round to 1 decimal place for continuous variables in the table1 package? Looking at the documentation, there seems to be a way to do number of

Newline in openxlsx

A question on openxlsx library in R: I'm looking for a way in openxlsx to add a newline to a cell value so that the value is in two (or more lines) in Excel. I

Interaction consider in gam() fitting with R

I am fitting data using gam() function. At this time, there is an interaction in opposite directions between the two variables. Is smoothing possible considerin

Problems with a for loop using writeRaster

I am trying to create a for loop to merge 4 raster (EVI MODIS tiles) at a time (because the 4 raster create one big map) in a list of 8 raster (my real list is

Creating custom Quantiles within data frame?

If i have the following table: tibble(year = c("2020", "2020", "2020","2021", "2021", "2021"), website = c("facebook", "google", "youtube","facebook", "

Problems using `plot_gg()` from `rayshader` package - R

I am trying to replicate the example shown here, made with rayshader package: https://www.rayshader.com/reference/plot_gg.html I was focused in particular on th

How to convert timestamp to date in each row of a column in R?

I have a column which list timestamps and I am in need of converting that to corresponding date for all rows in that column. Listing the code below app21_csv &

functionality to compare the database

I am trying to create a function which can do some test over the database. its something i am creating new to my code. for example i have a database of survey i

Overlay KDE and filled histogram with ggplot2 (R)

I'm quite new in R and I'm struggling overlaying a filled histogram divided in 6 classes and a KDE based on the whole distribution (not the individual distribut

use 'start' and 'end' values in two columns to specify fill range over remaining columns in R

I need to fill each row of a matrix with '1' between 'start' and 'end' columns, where the 'start' and 'end' column names (dates in the real data) are specified

R: What is the difference between the "baseline model" and "unrestricted model" in lavaan model summaries?

Usingsummary(fit.measures = TRUE) I am able to access extensive information about the fit of models stored in lavaan model objects. In this output (exemplified

Using LmFuncs (Linear Regression) in Caret for Recursive Feature Elimination: How do I fix "same number of samples in x and y" error?

I'm new to R and trying to isolate the best performing features from a data set of 247 columns (246 variables + 1 outcome), and 800 or so rows (where each row i

use 'start' and 'end' values in two columns to specify fill range over remaining columns in R

I need to fill each row of a matrix with '1' between 'start' and 'end' columns, where the 'start' and 'end' column names (dates in the real data) are specified

Is there a way to use different y-values per facet in R?

I'm relatively new to R and I'm struggling to figure out a way to get a set of plots with different y values. Below is a simplified version of the dataset I'm w

R obs Number Limited

I've been stuck with the data here for days, as I want to get data from API Binance, which is surely over ten thousand obs, but the R only limited the obs at 15

Creating a 3 by 1 matrix from three columns in a data frame and multiplying by a 2*3 in the correct order and applying to all the rows

I have a 23 constant complex matrix and create a 31 matric created from 3 columns of a data frame(this should be done for each row) and the result is going to b