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 ...

0
votes
2answers
10 views

Fill down every other row with level above in tidyverse

I'm learning R and am hitting a snag with tidry and dplyr. I've got a data frame in R where the first column is a factor that only has a level every other row. I'm trying to figure out how to use ...
0
votes
0answers
13 views

merging quarterly time series in R

How do you merge a and b xts series that are presented like this: a: 1948-01-01 1 1948-04-01 1 1948-07-01 1 1948-10-01 1 b: 1948-03-01 2 1948-06-01 2 1948-09-01 2 1948-12-01 2 Result ...
0
votes
0answers
2 views

image file not found from URL in r-markdown

I used to be able to render images in r-markdown using a URL with the following code ![](https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark) but I get a file not found error ! LaTeX ...
0
votes
1answer
10 views

What different between the assignment operators “<-” and “=” in R?

I read answers in What are the differences between "=" and "<-" in R?. But it is a very old question. There are some changes in R, since > median(x = 1:10) [1] 5.5 > ...
0
votes
0answers
3 views

roxygen2 link whole function family

In the @seealso tag of the roxygen2 package one typically links to another function like this @seealso \code{\link{functionName}}. I would like to link from one function to a whole family of functions ...
0
votes
0answers
10 views

How can I create a categorical column within a dataframe for quantiles of numerical data? [duplicate]

I have a dataframe "Pharmacy" with columns Pharmacy$A, Pharmacy$B, and Pharmacy$C. I need to add a fourth and fifth column with quantile values. The fourth column, Pharmacy$B.cat has to have 3 ...
1
vote
1answer
11 views

“Select * from <table_name>” not working from Oracle 11g when tables are created from R using 'odbc', 'DBI' package

I have created some tables in 'Oracle Database 11g Express Edition' using two method: Method-1: From R using odbc and DBI package library(odbc) db <- odbc::dbConnect(odbc::odbc(), ...
0
votes
4answers
29 views

Sorting rows based on variable group in a data frame

I've got a dataframe that looks like this - df=data.frame(Code=c('Q1','Q1','Q1','Q1','Q2','Q2','Q2','Q2','Q3','Q3','Q3','Q3'), Fiscal_Year=c('FY18','FY16','FY17','FY15','FY15','FY18','FY17',...
0
votes
0answers
11 views

Data.table alternative to pmap and reduce?

Hoping to get this process faster if possible. I have two very large dataframes (abbreviated examples provided below). df1 is a shorter dataframe where each row represents a patient hospitalisation. ...
0
votes
1answer
10 views

How to fix problem with “Error in plot.window(…) : need finite 'xlim' values” in R

I am trying to write a function which will do scatter plotting for me, the data structure that I am working with looks as follow: 'data.frame': 129 obs. of 15 variables: $ Player : Factor ...
0
votes
0answers
5 views

Boxplot{car} for Date variables

I rerun a program written 1 month ago on the same dataset, involving boxplots of date variables by the Boxplot function of the car package to label outliers (which I did not manage to do with the ...
0
votes
0answers
12 views

How to adjust the size of the boxplot frame in R to fit the plotted box

Hello fellow programmers, I am trying to plot a boxplot (just a single box, i.e 1 data column) but the issue I am having is that the frame enclosing the boxplot is so big compared to the actual plot/...
0
votes
3answers
19 views

Error downloading data from internet in R

I'm trying to download some data from the internet to work with Text Mining in R, but running the command fails. The commands are: url <- 'http://www.gutenberg.org/cache/epub/100/pg100.txt' ...
0
votes
0answers
12 views

Creating sparse_matrices using model.matrix

I've created a sparse matrix using the model.matrix function in R using the following code: sparse_matrix <- model.matrix(~.+0 data = df) I'm preparing to use the data in an xgboost model that I'...
0
votes
1answer
8 views

R raster getZ returns null even if setZ works fine

I am processing MOD16 data using raster package in R. I would like to subset a raster stack I created by date. I wrote like this: all_ET<-grep(list.files(full.names = TRUE, ...
0
votes
1answer
8 views

Unable to load rJava.dll - not a valid Win32 application - while installing ReporteRsjars

I am having problems installing ReporteRsjars package on my 64 bit R, 64 bit Windows 10 machine. The ReporteRsjars package was downloaded from the CRAN archive (tar.gz file) and installed from a local ...
0
votes
0answers
7 views

Error in curl::curl_fetch_memory(url, handle = handle) : Empty reply from server

I am doing an API request using the GET function from httr. The API takes only one argument at a time, and I need information for ~100000 arguments. I wrote a script doing requests with a loop, and I ...
1
vote
1answer
21 views

How to get first 8 components from PCA using pcromp package?

I am implementing a PCA using prcomp. pcaunemp <- prcomp(rawtChange,center = TRUE, scale=FALSE) I am using the lm function for regression like so: reg <- lm(tr[5:365,1] ~ tr[1:361,1] + tr[2:...
0
votes
3answers
30 views

R: Changing a value in a cell, if the value above and below it match each other, without using a for loop

I’m trying to replace Us (or NAs, easy to lead in Us as NAs) in my dataframe with the values that are in the column above or below them. I.e. 0 1 0 1 U U U U 0 1 1 0 Would become 0 1 0 1 0 1 U ...
0
votes
0answers
9 views

Detecting communities in bipartite graph extremely different speeds by algorithm on 500+400 node network

In the 'bipartite' package in R, I am attempting to detect modules with the computeModules() function. This is on a bipartite graph of approximately 400 + 500 nodes after removing isolates. Using ...
3
votes
3answers
31 views

How to do a join and only select a specific row from a related Group?

I don't know how to exactly phrase this Question. I hope it gets clearer when I provide you with an example: Match <- data.frame(PlayerID=c(1,2,2,3,3), Date = c("01.04.2012","05.04.2012","20.04....
0
votes
2answers
21 views

Lag variable by group/time indicator in dplyr

I have data that looks like this: set.seed(13) dt <- data.frame(group = c(rep("a", 3), rep("b", 4), rep("c", 3)), var = c(rep(0.1,3), rep(0.3, 4), rep(1.1,3))) dt group var 1 a 0.1 2 ...
1
vote
2answers
18 views

Passing column names to user defined function inside mutate_at

My first question in this forum: so kindly excuse me if I have missed some protocols: I am struggling for some time now to pass column names inside my custom function while using dplyr - mutate_at. I ...
0
votes
1answer
12 views

Load for-loop results in container

All of the below is conducted in R. I am trying to store the result of a for-loop result in different containers, but somehow I keep ending up with NA-warnings and the results are not not stored in ...
0
votes
1answer
10 views

Derive preidcted values after glm() in order to get PPV, NPV, sensitivity and specificity

I have run a glm() model; but now I would like to measure the model's accuracy with PPV, NPV, sensitivity and specificity. However, I keep getting confusing results. My outcome is a factor variable ...
0
votes
1answer
10 views

How to RenderTable output to tabPanel in NavBar page + Rshiny app

I am building a dashboard page where the user uploads a file and on clicking the actionbutton it should run the server code and show the output and also allow to download the output as file. Below is ...
0
votes
0answers
7 views

Problem using dist2isobath function (marmap package) with projected coordinate system

I have a grid with created in an projected coordinate system (WGS84 zone 30N) and I am trying to extract the smallest distance from all of the cells of the grid to the coast and to other isobaths ...
1
vote
1answer
11 views

Capture output of next method

I'm creating an S3 method for a generic defined in another package. An earlier method for the generic produces some console output that's not returned as part of the function return value, it's only ...
0
votes
0answers
12 views

How to access debugging in rstudio?

I installed RStudio on a new computer and I cannot debug. I cannot see a "Debug" menu(between the Build menu and the Profile menu). I cannot add a breakpoint(click on the line number in the source ...
2
votes
1answer
26 views

Subsetting nested lists within R

I am trying to create a dataframe from nested lists from within R. Here is an example: mylist<-list(file1 = list("a", sample1 = list(x = 2, y = list(c(1, 2)), sample2 = list(x = 4, y = list(c(3, ...
0
votes
0answers
17 views

R-script to make manifest.csv adds absFP to sampleID's

The following gives an output .csv file, for some reason its putting the absolute filepath on the sampleID's and I cant get work out how to prevent it. #!/usr/bin/env Rscript #WARNING THIS IS FOR USE ...
0
votes
0answers
18 views

Adding two numerical columns makes the newly created column unknown

I have a dataset with two columns which are classed as numerical data but when I add the columns together the class of the newly created column becomes 'unknown'. I find this particularly bizarre as ...
0
votes
1answer
15 views

Fix a variable in SelectInput (RShiny)

I have a selectInput and want to fix one input variable, i.e. you can choose different variables, but one variable is always selected. How can I program this? Thanks in advance.
-5
votes
0answers
21 views

Textarea content not displaying in lines when submit using php

I have a very small form and when I submit its all the data of textarea. It shows in one line with \n\r between all the words. So, I used nl2br() and str_replace() etc. but no luck because then I ...
0
votes
0answers
16 views

writing colored output into CSV file in R and how to keep the header name for the second column empty when exporting the results in csv format

I have a data frame with Names and the class. For example: library(crayon) NameClass<- data.frame(Name = I(c("Jack", "John")), Class = I(c("Green", red("Redflag")))) colnames(NameClass) <- c("...
0
votes
0answers
11 views

R Notebook with dlookr package

I try to create Data summary with dlookr package. In normal R it works but in R notebook it has a notification like this: Error: pandoc document conversion failed with error 251 Anybody knows why?
0
votes
1answer
11 views

Execute wincsp command line arguments from within R

I have some command line batch code which I can run in my windows command prompt just fine. I'm basically pushing a local file text file to a remote server using WinSCP command line arguments - https:/...
1
vote
0answers
25 views

Exclude from autocomplete data object from packes in R not in the global environment

Is there a way to remove from the autocomplete all objects associated to libraries that are not in the global environment, aside from their functions? For example the plyr package loads baseball. I ...
1
vote
0answers
9 views

monotonously increasing error in fhat evaluation points when ploting kde.local.test results from ks package

I have trouble plotting the results from kde.local.test function (ks package from R) testing for local differences in the kernel density between two samples with a two-dimensional kernel density ...
0
votes
0answers
34 views

How use subset command in r when columns names change each time?

I have a sort list that update each time. now consider my sort list is a vector. for examle: >sort.test AP5 AP4 AP7 AP3 AP2 AP9 AP1 AP6 AP8 -45.25 -49.79 -54....
0
votes
0answers
7 views

R Encoding problems in package XML

I am reading XML files into R but I´m struggling with utf8 encoding problems and some HTML tags. Here is a minimal XML file: <?xml version="1.0" encoding="UTF-8"?> <CV id="Z1" lang="de"&...
0
votes
0answers
16 views

sequential subtraction within data.frame in r or python

I'm working on a project where I'm allocating products among facilities based on the ranks. Data is as follows: > product_small facility_abbr itemid need_qty rank available_qty 7 ...
0
votes
1answer
16 views

Confusion regarding DateTime conversion in R

I am trying to convert a character string into a dateTime object in R Sample data: Actual Following is the code that I am using for conversion sample$Tweet_Timestamp <- lapply(sample$...
0
votes
0answers
4 views

Regrid random sites in R

Thanks for help. I have data from a few surface sites which are located randomly, here are some sample data. Station Lon Lat data 1001A 116.3 39.8 0.2 1002A 116.1 40.2 0.3 1003A ...
0
votes
0answers
11 views

Reactive Data, transforming and overwriting

I'm fairly new to R Shiny, and I'm having some problems with reactive Datasets. My idea ist, to load a dataset, do some calculations on it, print the outcome. This is no Problem if I set the dataset ...
-3
votes
1answer
28 views

Filtering values

I have one data.frame with three columns, Name_of_brand,Price and Quantitity. I would like to continue only with observation which is equal or greаther than 100 in column Price_Category. ...
1
vote
0answers
19 views

Fit a linear line with CI to GEV distribution in R

I have a data of 34 years of a variable Y. I want to fit a generalised extreme value distrbution (GEV) to this data. I use the following code. df = structure(list(x = 1:35, y = c(176.55005072974, ...
0
votes
0answers
25 views

Calling R inside loop in Rcpp [duplicate]

I'm writing a code where I have a loop inside Rcpp and I need to use some information generated on that loop inside a function from a R's Package. I don`t need the information generated by R to go ...
0
votes
0answers
16 views

ggsave a ggplot with segmented years and months

This post decribes a method to segment years and months on a time series plot. Unfortunately, the method that I use from this post (option 2) is not compatible with ggsave(). library(tidyverse) ...
1
vote
1answer
16 views

How can i specify encode in fwrite() for export csv file R?

Since fwrite() cannot apply encoding argument , how can i export csv file in specific encode as fast as fwrite() ? (fwrite() is the fastest function within my acknowledgement so far) fwrite(DT,"DT....