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

Receiving error: argument of length 0 when reading in separate tables from...

Error in 1:nrow(csvs) : argument of length 0 when reading in separate tables from multiple csv filesI am trying to perform the following for loop on separate tables read in from multiple csv files in...

View Article


How to force R to use a specified factor level as reference in a regression?

How can I tell R to use a certain level as reference if I use binary explanatory variables in a regression?It's just using some level by default. lm(x ~ y + as.factor(b)) with b {0, 1, 2, 3, 4}. Let's...

View Article


Finding the number of 1s connected to 5 or more other 1s (e.g. neighbours) in...

I have wrote the below function to find the number of 1s with only one other connecting 1. temp <- list.files(pattern="*.csv") files <- lapply(temp, read.table) number_1_neighbour <-...

View Article

use append() and get() to form list of lists

I have a list of list names and corresponding lists like this:list_names <- list("name1", "name2", "name3") name1 <- list("apple", "banana", "orange", "peach") name2 <- list("foo", "bar",...

View Article

Image may be NSFW.
Clik here to view.

Strange behavior of ggplot's geom_polygon when using gganimate

Say that I have these data. One for shading counties of a state and the other for plotting points.library(tidyverse) library(gganimate) devtools::install_github("UrbanInstitute/urbnmapr")...

View Article


How to update a data.frame based on information from another data.frame

I have two tables: Display and Review. The Review table contains information on reviews on products of an online store. Each row represents the date of the review as well as the cumulative number of...

View Article

Create column based on dates in another dataframe

I would like to determine the tidal state in one dataframe (DF)DF <- data.frame(Date = c(2012-01-01 05:37:00,2012-01-01 05:50:00,2012-01-01 05:58:00), Tide= NA)based on the following dataframe:Tides...

View Article

Image may be NSFW.
Clik here to view.

Combine dodge and stack position in the same bar graph with ggplot2

I need to represent some data in a very specific way. Right now I have a factor "treatment" with 8 levels, and then for each level, 4 different values obtained in the experiment (let's call it "type"...

View Article


Image may be NSFW.
Clik here to view.

Error: stat_summary requires the following missing aesthetics: y

I'm trying to create a barplot with confidence interval error bars using ggplot. Essentially, I have a variable, Q1, with 7 answer options, and I want to plot the percent of respondents for each...

View Article


How does "gsub" handle spaces?

I have a character string "ab b cde", i.e. "ab[space]b[space]cde". I want to replace "space-b" and "space-c" with blank spaces, so that the output string is "ab[space][space][space][space]de". I can't...

View Article

Finding local maxima and minima in R with discrete values

I'm looking for a reproducible way to find the most recent local peak in a given series (and separately, the most recent trough). For the most part the answers here - Finding local maxima and minima...

View Article

Checking the change in factor value for panel observations

I have a panel data set which looks as follows:library(plm) library(Hmisc) library(data.table) set.seed(1) DT <- data.table(panelID = sample(50,50), # Creates a panel ID Country =...

View Article

how to perform calculation by two factors

I would like to calculate the customer's satisfaction level for each employee each day, my data look like this:df <- data.frame( rep(seq( from=as.Date("2012-1-1",tz="UTC"),...

View Article


R Beginner struggling with extremely messy XLSX

I got an XLSX with data from a questionnaire for my master thesis. The questions and answers for an interviewee are in one row in the second column. The first column contains the date.The data of the...

View Article

KNN outlier detection in R

I am trying to run a script I was given to perform outlier detection using a weighted KNN outlier score, but keep getting the following error:Error in apply(kNNdist(x = dat, k = k), 1, mean) : dim(X)...

View Article


grouping by category and then find out difference between categories [r]

I am calculating mean employment rate for different groups from year 1995 to 2015. And then calculate the difference of mean employment rates between groups.This should be yearly ordered.Most of time,...

View Article

Image may be NSFW.
Clik here to view.

export::graph2office moves labels around

I have made plots in R (RStudio) with ggplot2. When I export them via export::graph2office, the labels are moved around. However, this only happens when I specify the font for the labels.library...

View Article


Image may be NSFW.
Clik here to view.

Testing if the data shifted from a specific moment

I have a time-series dataset with millions of companies and the concentration of their respective industries during the last 20 years. However, I know that from 2007 to 2008 there were some changes in...

View Article

"Unable to run a simple JNI program" error message when installing rJava on R...

I have the very common problem that rJava does not install correctly on Ubuntu. This problem has been dsicussed in multiple places here, here, here, to name a few.The basic problem is that on...

View Article

Non character argument in R string split function (strsplit)

This worksx <- "0.466:1.187:2.216:1.196" y <- as.numeric(unlist(strsplit(x, ":"))) Values of blat$LRwAvg all look like X above but this doesn't workfor (i in 1:50){ y <-...

View Article
Browsing all 201839 articles
Browse latest View live


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