Questions tagged [r]

R is a free, open-source programming language and software environment for statistical computing, bioinformatics, visualization and general computing. Provide minimal, reproducible, representative example(s) with your questions. Use dput() for data and specify all non-base packages with library ...

1
vote
0answers
12 views

How to make nested purrr map to extract rows based on dynamic variables instead of nested loop?

I have a data frame as below:## Please copy following text in your clipboard (do not copy this line)hid ,mid ,aprps,astart ,aend ,ax ,ay ,exph10001,1000101,3 ...
0
votes
0answers
11 views

Obtaining all pairwise scatterplots amongst variables

Im trying to solve this question with the dataframe stackloss:Use the pairs() function to obtain all pairwise scatterplots among the four variables. However when i use the pairs function I get a ...
0
votes
0answers
21 views

How do I calculate a percentage using R studio

I have a data set that lists badbuy cars by state. I want to calculate the top 10 states with the badcars by percentage per stateThe code that isn't working is: carDF2=carDF %>% filter(!is....
0
votes
0answers
13 views

image transition/interpolation for gif animation of climate change

I'm trying to make a gif of change, both for climate change and habitat suitability, using two images: present and future value as input; My goal is to interpolate the pixel values, say from blue (...
1
vote
0answers
9 views

Add points to usmap with ggplot in r

I was able to create a US map with this tutorial. When I tried to add additional points to it they all ended up in South Dakota, no matter what I input for data.library(ggplot2)library(usmap)...
0
votes
1answer
20 views

Check if URL exists in R

I want to loop over a list of URLs and I want to find out if these URLs exist or not. RCurl provides the url.exists() function. However, the output doesn't seem to be right, because for example it ...
0
votes
0answers
13 views

Why can't I load seqinr package in R?

I am learning R. I have install "seqinr package" successfully. But when I load the "seqinr" package, it is something wrong. Does anyone know how to resolve it?enter image description here
3
votes
2answers
31 views

R: why group_by still requires “do” even when using quosures

How to make a user-defined function work nicely with pipes and group_by? Here is a simple function:library(tidyverse)fun_head <- function(df, column) {column <- enquo(column)df %>% ...
0
votes
0answers
17 views

Problems using dataframe in R with columns of different width

I have uploaded a csv file, like the following: datamap <- read.csv(file="TheWorlds50BestRestaurants2018.csv", header=TRUE, sep=",")I want to put that dataset into a data frame. However,...
0
votes
1answer
22 views

External functions inside filter of dplyr in R

How does an external function inside dplyr::filter know the columns just by their names without the use of the data.frame from which it is coming?For example consider the following code:filter(...
0
votes
0answers
19 views

Replacing NAs in a Matrix in R

I have created a container of NAs and am trying to replace the NAs with a specified value that is an argument in one of the functions. num.cars.beg<-20num.cars.end<-70num.cars.incr<-5num....
0
votes
1answer
15 views

Reference a specific value within a dplyr group by case

I have data similar to below, representing interactions between entities.> library(tidyverse)> set.seed(20)> dta <- data_frame(group=c(1,1,2,2,2,3,3,3),flag=c(1,0,1,0,0,0,1,...
-1
votes
1answer
22 views

R dataframe: select rows by sorting one column and based on values in two columns

I have a dataframe df as below:user_id rating date status10506 4 2008-11-11 210506 3 2008-11-13 110506 4 2008-11-23 3...
0
votes
1answer
10 views

Strings in R - Insert a desired/arbitrary digit between a string and digit

I have a character vector that looks like this: questions <- c("question1" "question10" "question11" "question12" "question13" "question14" "question15" "question16" "question17", "question18" ...
0
votes
0answers
6 views

quantmod::chartSeries() in a loop doesn't behave as expected

Why is the result an 8-page PDF instead of 1-page PDF with 8 charts?library(quantmod)s=c("AAL","DAL","UAL","LUV","FDX","ALK","JBLU","HA") x <- list()### get symbolsfor (i in s) { x[[i]] &...
0
votes
1answer
12 views

Converting text anchors to number factors for more than one variable at a time in R

The dataset I have shows each participant's data for the variables as the text option instead of the numeric value only. For instance, if the answer choices to the variable is:1) A little2) ...
0
votes
0answers
21 views

Stitching data frames together in R without reordering each data frames columns [duplicate]

I'm currently trying to vertically stack three data frames together in R so I can keep my data clean. The problem is that the ordering of each of the frames is different and I don't want R to reorder ...
0
votes
0answers
12 views

How to invoke invokes the OS command (shell file) with argument in R

I like to invoke the OS command (running a shell file in linux) within R code and send argument together that I got in the R code. For example, MyRcode.R will do some calculation and get a vector ...
0
votes
0answers
14 views

aggregate polygon shapes that share boundary(ies) in R

I've been looking for an existing R function(s) for aggregating polygon elements within the same layer that share a common boundary. I created a polygon layer from a raster file using ...
2
votes
1answer
26 views

Why does r str changes evaluation

Using str() appears to change the evaluation why?MWE:f1 <- function(x, y=x) {str(y)x <- x + 1y }f1(1) # result is 1f2 <- function(x, y=x) {x <- x + 1y }f2(1) # ...
3
votes
1answer
35 views

Fastest way to determine COUNTRY from millions of GPS coordinates [R]

I have millions of GPS coordinates and want to quickly add a column of the country of the coordinates. My current method works but is extremely slow:library(data.table)#REPRODUCE DATAdata <- ...
0
votes
0answers
11 views

Use download button with dataframe inside observe event

I have a application that allows user to upload the data, then an action button to trigger some calculation. I then have some progress bar to show user how long the process would take. Once the ...
0
votes
0answers
12 views

Modify point stroke on a PCA biplot using autoplot function

I am using the autoplot function to make a PCA biplot. In my case, I would like to increase the point stroke to improve the readability of the plot. How can I do that?Here's an example:library(...
0
votes
0answers
8 views

quantmod::chart_Series() how to simplify x-axis labels?

What is the proper way to remove the bottom portion of the x-axis labels for chart_Series()? eg. I would like to remove "Jan 03 2007 ... Oct 19 2018", but leave the years above the x-axis.library(...
-1
votes
1answer
25 views

Sum the column values in one dimensional list in R

I have the following list, which goes from 1 to 1000. Here I have 29 columns and in each list I have one row (one dimensional list)Here is my sample r code.data=sample(c(0,1), replace=TRUE, size=...
0
votes
0answers
9 views

Problems installing dartR and package ‘later’ is not available (for R version 3.5.1)

I am trying to install dartR to work through at least part of “Introduction to dartR” tutorial.I am running R version 3.5.1I have used install.packages("dartR")and gotpackage ‘dartR’ ...
1
vote
1answer
16 views

ggplot using loess dates- change axis label from numeric to character

I have a dataset with discrets distances and Months (The months are interpolated as 1, 1.1, 1.2, etc.) and a z variable. Months are numeric, not dates here. I interpolate using a loess function and ...
0
votes
1answer
12 views

Extract data from a column to create another column in R

I have a data frame that has 3 variables that I would like to split into 4 variables. The data frame looks like this:Species_Name SIXTEENS_Title SIXTEENS_Sequence...
0
votes
0answers
6 views

y value for createDataPartition in R

I can't figure out what exactly to put for the y function in the createDataPartition function. My understanding is that the partitioning is splitting the data into portions you specify, e.g. a 70/30 ...
0
votes
1answer
8 views

Customizing emmeans plot

I'm using emmeans and would like to learn how to customize plots. For a reproducible example, I'm using warpbreaks data.library(emmeans)lm <- lm(breaks ~ wool * tension, data=warpbreaks)emm ...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,