Quantcast
Browsing all 206102 articles
Browse latest View live

Factors to calculate total number of values [closed]

Write an R script to define a new character vector gender that is populated with “male” for the first 20 elements, and “female” for the next 30 elements. Use factors to quickly and efficiently...

View Article


Merging multiple text files into one dataframe [duplicate]

I have this reproducible set up.temp <- tempfile() download.file("https://d396qusza40orc.cloudfront.net/getdata%2Fprojectfiles%2FUCI%20HAR%20Dataset.zip",temp) datafiles <- unzip(temp)...

View Article


Image may be NSFW.
Clik here to view.

How to reduce huge gap in ggplot?

My graph looks like this: Is there any way to reduce the huge gap and set the break myself? This is a simpler version I am working on: y1<- c(1,2,1000, 100000) x1 <- c (1,2,3,4) df <-...

View Article

How do I reference other columns when using dplyr mutate()

Forgive me if I haven't formatted this post properly as it is my first.I am currently doing some research on wine grapes and I am trying to find a way to make the mutate() function work they way I need...

View Article

R Converting dataframe object to hts object

I have an aggregated hierarchical dataset (aggregated per hour) as below TIME level1 level2 n <dttm> <fct> <fct> <int> 1 2019-11-29 00:00:00 A a 1 2 2019-11-29 00:00:00 B a 1 3...

View Article


Image may be NSFW.
Clik here to view.

How to get ride of polygon borders using geom_sf in ggplot2

This question has been asked before in an old thread, but the accepted answer does not anymore in the current version of ggplot2. Here is a minimal example:library(ggplot2) library(rnaturalearth) world...

View Article

creating network data from event level data

As a newbie to network analysis, I am struggling with transforming an event level dataset I want to plot into the correct shape. I am grateful for any hints/ leads/ etc. What I did until now, broadly...

View Article

Access Reddit API using OAuth2 in R: how to request and update token

ResolvedI am using the following R code to acquire a token from Reddit API on behalf of a user. However, tokens expire in an hour. To keep access with that app, I need to use a refresh_token parameter...

View Article


Image may be NSFW.
Clik here to view.

R Shiny - Updating the value of a selectInput and progressBar simultaneously

The app below contains an actionButton, a shinyWidgets::progressBar and a selectInput:When the Start button is clicked, an observeEvent is triggered in which I loop through the numbers 1-10 and...

View Article


Counting the number of unique values by date in R

Please help me to count the number of unique IDs per Date. so, initially, there is this data frame of IDs and dates ID Date 1 2009/11/1 1 2009/11/2 1 2009/11/2 2 2009/11/1 2 2009/11/1 2 2009/11/2 3...

View Article

How to create a dataframe?

I'm not sure if this is possible in R, but I have a dataframe original_data with one row and columns as follows:Error in `$<-.data.frame`(`*tmp*`, "ID", value = NA_integer_) : replacement has 1 row,...

View Article

how to write a nested if else statement in data.table r

Below is a general form of nested if-else statement using dplyr package. So I have two questionsWhat is the equivalent code using data.table the below form? is there any other faster function to be...

View Article

Remove quotes from special characters in R

When I print pattern program in r , char<-c("#","@") m<- matrix(paste(char[1]),nrow =4, ncol = 4) print(m) My output is [,1] [,2] [,3] [,4] [1,] "#""#""#""#" [2,] "#""#""#""#" [3,] "#""#""#""#"...

View Article


Is there any function to find if a value is an integer in R? [duplicate]

if (x %% 1) == 0 works for values like 1.2, 2.4 or 2.But for values like 1.0, 2.0 this does not work.

View Article

R repeat automatically: create new df if change in variable

I have a simple grouping function that I need to apply to many different cases in one dataframe. For each character change in "scenario" I would like to create a new dataframe. Thanks for your help...

View Article


Read binary file with R

I am looking for help to read a binary file with R. I know the file can be successfully imported in Python with the following code (np for numpy):dt = np.dtype([('var1', np.uint32), ('var2',...

View Article

How to create a graph from an adjacency matrix by also specifying nodes...

I have the following R code:library('igraph') nodes <- c('a','b','c','d') x <- c(0,1,2,3) y <- c(0,1,2,3) from <- c('a','b','c') to <- c('b','c','d') NodeList <- data.frame(nodes, x...

View Article


Dplyr and ggplot2 questions [closed]

id product cost year name bank postcode email 1 100-47-3008 Book 10 2018 Miesha McClure 7153-2957-3958-6600 SR1 1UE shn@z.erw 2 100-47-3008 blue-ray 10 2017 Miesha McClure 7153-2957-3958-6600 SR1 1UE...

View Article

Error with Plotting Cartogram - 'This function does not give correct...

I'm trying to use the wrld_simple data from the maptools package to plot a Cartogram that involves some European countries based on their Population in 2005: countries = c('Austria', 'Belgium',...

View Article

R function generating incorrect results

I am trying to get better with functions in R and I was working on a function to pull out every odd value from 100 to 500 that was divisible by 3. I got close with the function below. It keeps...

View Article
Browsing all 206102 articles
Browse latest View live


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