Quantcast
Channel: Active questions tagged r - Stack Overflow
Browsing all 206180 articles
Browse latest View live

How to merge two datasets that have different column names in R?

I have 2 datasets x_data has 130 variables (columns)y_data has 126 variables (columns) Both data sets have information I need but after doing intersect(names(x_data), names(y_data)) Only 19 columns...

View Article


Image may be NSFW.
Clik here to view.

writing a function called circle() that creates a circle for any n in R....

This is what output should look like

View Article


Extracting text with gsub [duplicate]

I have some text. I want to extract a key that can vary from many ways:text <- c("bla el patron a extraer se cambia de 'ND' a 'a123' bla bla", ".. el patron a extraer se cambia de 'ND' a 'b123'...

View Article

Image may be NSFW.
Clik here to view.

Vertically align column name using kable and rendering with rmarkdown into html

Created the table below and would like to vertically align the word "Species" in the center/middle of the cell. I am using RMarkdown to generate the HTML not LateX. Any tips? --- title: "Untitled"...

View Article

In r, how to save plot and reuse the plot code

The following code is a minimal example of what I have and what I am trying to achieve. The idea is I have a large chunk of code that builds up a plot in many steps. I want to save the plot as a png at...

View Article


Sort a Dataframe using External Factor Ordering in R

A niggling problem. Simple example. Suppose I have the following:df <- data.frame(x = as.factor(1:10), y = rnorm(10, 0, 1)) x_order = c("3", "1", "5", "7", "8", "9", "2", "6", "10", "4") I would...

View Article

R: removing obs. only if a value of a column is present for the same...

I'm currently working in R with a data table containing two columns: id and type. The type value can be female, male, or both. There are instances where ID is repeated with differing values of Type....

View Article

create bins with equal size in sparklyr?

The data frame df1contains a numeric variable x1.df1 <- data.frame(x1 = rpois(1000, 5)) I need to create 10 bins such that each bin roughly contains the same number of x1In base R, one can...

View Article


R: How to display mean-separation letters for 2-way ANOVA when interactions...

I am comparing a fertilizer experiment where I have a response variable (growth rate) with two independent variables (genotype and rate). I ran a 2-way ANOVA using the lsmeans, car, and multcompView...

View Article


Remove duplicates and manipulate dataframe based on conditions from 2 columns

I've a dataframe as under+------+-----+----------+--------+ | from | to | distance | weight | +------+-----+----------+--------+ | 1 | 8 | 1 | 10 | | 2 | 6 | 1 | 9 | | 3 | 4 | 1 | 5 | | 4 | 5 | 3 | 9 |...

View Article

Accessing variables in e1071 for custom error.fun

I am trying to write a function that calculates F1 so I can use F1 as the error.fun in tune.svm using the e1071 library. I have found the underlying code: repeat.errors[reps] <- if...

View Article

R: httr SOAP POST request for xml return error - "media type is unsupported"

I'm trying to use R script to make SOAP query. Expecting xml file response. The POST request return error: 415. I am struggling how to phrase it right in R. I tried in httr:library(httr) library(xml2)...

View Article

Difficulty with haven package Reading SPSS data in R

I am trying to use the haven package to read spss data and am getting the following error: Error in df_parse_sav_file(spec, encoding, user_na, cols_skip, n_max, : Failed to parse ~FilePath/Dataset: The...

View Article


Error: Memory Exhausted (limit reached?) R code Windows Task Scheduler

I am attempting to use Windows Task Scheduler to automatically run R code daily using instructions from another StackOverflow question (Scheduling R Script). Window Task Scheduler correctly opens...

View Article

Reshaping data in R for multiple value types

This is a relatively simple question but I'm having some issues (thank you in advance!). My data looks like this (minimal working example):df <- data.frame( ID = c("A","A","A"), org =...

View Article


Showing valueBox with crosstalk select_filter

Within my Flexdashboard, I want to generate a valueBox displaying the sum sales values, based on a filter. I constructed the filter by using crosstalk, shiny is not an option because of the...

View Article

R vtreat prepare() cat_P output

I have a dataset containing categorical variables and numeric features:Experiment Replicate Batch Condition Cellline Feature1 Feature2 ... <chr> <chr> <chr> <chr> <chr>...

View Article


Data Table R: molten or reshape data table without stacked variable column

Datastr(DT) Classes ‘data.table’ and 'data.frame': 6 obs. of 3b variables: $ A : Factor w/ 6 levels "0","1","2","3",..: 1 2 3 4 5 6 $ N : num 13 11 10 5 1 1 $ ID : Factor w/ 1 level "1": 1 1 1 1 1 1...

View Article

Adding values from one dataframe to another based on two matching conditions...

I have two dataframes below: dput output df1:structure(list(Location = c("1100 2ND AVENUE", "1100 2ND AVENUE", "1100 2ND AVENUE", "1100 2ND AVENUE", "1100 2ND AVENUE", "1100 2ND AVENUE" ), `Ivend Name`...

View Article

R - using purr add columns on dataframe

I'm looking to use purr to create a year variable on my data sets and join them together. This example will illustrate the problem and what I have tired.# files in the directory files <-...

View Article
Browsing all 206180 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>