Most voted "r" questions
R is an open-source environment and programming language for statistical computing, bioinformatics, and graphics. It is advisable to supplement your question with a minimum reproducible example.
Learn more…2,359 questions
Sort by count of
-
3
votes2
answers1179
viewsWeighted Average in R
With the data set I have the columns C1(year),C2(states), C3(weight), and C4(value). I’d like to do the weighted average (C4) with (C3), per state(C2) per year(C1). dados <- data.frame(c1 =…
rasked 5 years, 11 months ago Everton Toledo 113 -
3
votes1
answer732
viewsHow to convert million units into dozens unit in R?
Suppose I have the number 80 million. Numero = 80000000 print(Numero) [1] 8e+07 Because it is a large number the R already shows me in Scientific Number, but I would like to convert that number that…
-
3
votes1
answer702
viewsHow to stack multiple data frames in R?
I have 5 data frames in R with the same columns. I need to group them into a single data.frame, which command should I use? Filenames are: parse10, parse20, parse30, parse40, parse50.
rasked 5 years, 2 months ago Jéssica Jabczenski Roslindo 43 -
3
votes1
answer125
viewsHow to use the remote driver on proxy protected computer via R software Rselenium package?
Well, I need to access a site on my work network, but this is protected by proxy. Some sites accept using httr and rvest packages, others do not. To log in to site for examples I cannot. Example:…
-
3
votes1
answer60
viewsError installing R Rsqlite package in Windows10
While trying to install R Rsqlite package on Windows 10 I get the following error message. make: *** [C:/R/R-3.6.1/etc/x64/Makeconf:215: DbDataFrame.o] Error 1 ERROR: compilation failed for package…
rasked 4 years, 11 months ago Sandro Henrique Antunes Ribeir 31 -
3
votes1
answer138
viewsHow to avoid displacement of a forecast using ARIMA?
I created a prediction model on R using ARIMA with a 2-year daily historical basis (2018-2019). In this model I use Multivariate Analysis to create predictions. dados = dados_dput QTD_PED_TS =…
-
3
votes1
answer205
viewsCox regression model in R
Hello, I’m trying to develop a Cox regression on R, but I can only get a straight line with practically continuous values. ano<-…
-
3
votes1
answer403
viewsConvert date to month in full
I have a table in r with a column with months in numerical format data = c("01", "03", "03", "04", "05", "10", "12")) I would like to convert in the abbreviations of the months. I found how to put…
-
3
votes1
answer48
viewsDoubt with If statements in R
In this code I am wanting to record the amount of values of z such that -1 < z < 1 inside x, and z < -1 or z > 1 in w. It rotates the rnorm(100)(that is, it creates 100 observations of a…
-
3
votes1
answer251
viewsproblem with unnest_tokens()
I am a linguist, I work in text mining and I am trying to import a novel (200 pages of text linearly written with line breaks) for analysis in R. Several errors occur. First I tried:…
rasked 5 years, 9 months ago user135517 -
3
votes1
answer203
viewsFind a variable value for a --- Target function
good afternoon staff I have a function that I know the result, and I want to find the value of parameter c for each result I have , similar to Excel target function #Vetor com valores de cv para…
rasked 5 years, 9 months ago Henrique Faria de Oliveira 725 -
3
votes1
answer393
viewsCaption in ggplot does not appear
I do not know what I am doing wrong, because the caption does not appear in the graph I build. Follow my code: ND<-c("D0","D1","D2","D3e4") #diferentes níveis de desfolha (D)…
-
3
votes2
answers327
viewsHow to identify a single point and label it in R
I’m looking to identify and label a single point on a graph. I am working with a dispersion chart with an indicator on the y-axis and the years on the x-axis. My intention is to highlight Brazil and…
rasked 5 years, 8 months ago Diego Fernandes 31 -
3
votes1
answer62
viewsHow to plot negative coordinates (South Pole) using ggmap, ggplot?
I’m trying to plot some points between South America and the Antarctic Peninsula, but from the error when I delimit the area I wish to appear on the map (xlim, ylim). I had already plotted the map…
-
3
votes1
answer45
viewsLoop with R arrays
I need to create a matrix that has all the coordinates for a 128x128 matrix in R if it were a 3x3 matrix, ex: 1 2 3 1 a b c 2 d e f 3 g h i I would need the following matrix x y 1 1 1 2 1 2 3 1 3 4…
-
3
votes2
answers124
viewsLANGUAGE R: Error "Error in course[[1:98]] : recursive indexing failed at level 2" when trying to search the items in a list, how do I resolve?
I have a "course" list in R, it consists of 98 items, each item has one or two variables of type Character. I want all the first variables of each item in the list, but when typing the command:…
-
3
votes1
answer117
viewsStarting point of axis X using scale_x_date()
I am making a stacked area chart and use the following code ggplot(gdados, aes(Commissioned, acum, fill = Country)) + geom_area(col=c('black')) + scale_fill_brewer(palette = "Paired")+…
-
3
votes1
answer46
viewsComposition Graph using ggplot2
How can I produce a composition chart using ggplot2 reproducing the same model as the figure below? Sample matrix: x<-c(0, 1.52, 8.12, 0, 0.29, 0, 3, 4, 1.2, 1.1) y<-c(4.8, 3.03, 6.82, 9.76,…
-
3
votes1
answer89
viewsLast characters of a data.frame column in R
I have a table within a date.frame, and I need to get only the last two characters of that table, how do I do that? bs.: I was trying to do it using str_sub, but in it I can only define which…
-
3
votes3
answers146
viewsPrint more variable text
A doubt, as I print (print) a variable x after a text in R. As in the python you do. print (f"seu numero é",x)
-
3
votes0
answers169
viewsHow to change the title, caption, filter and export the Map in pdf using leaflet in R?
I created a map of MG to identify the Qtde of consultations by mining municipality. I got the code below on the internet and it worked. But I would like to add some more information, but I’m not…
-
3
votes1
answer41
viewsPlot factors (spp) of metaMDS in ggplot
I want to plot the species in the clusters of the metaMDS result using ggplot. I tried so, but gives error:Error: Aesthetics must be either length 1 or the same as the data (20): label.…
-
3
votes2
answers74
viewsRenaming string text in a column
Hello, good morning! I have a quarterly data frame that is divided by 1st, 2nd and 3rd month of each quarter, see: Trimestre Variável Referência temporal 1º trimestre 2007 Animais abatidos No 1º mês…
rasked 5 years, 7 months ago Ingled M Cardoso 159 -
3
votes1
answer123
viewsEquivalence to kmeans inside Caret::Train
I tried to adjust a model kmeans within the package caret with the function train. But I checked that it is not available. I generated a frame to do this: set.seed(15) d <- data.frame( x =…
-
3
votes1
answer159
viewsSelecting logistic regression variables
I’m new to RStudio and I’m having trouble simplifying my code. I’m doing a logistic regression and would like to select only variables with p<0.20. For that, I did the following: imcbi <-…
rasked 5 years, 7 months ago Sergio Martins Pereira 31 -
3
votes1
answer86
viewsHow to make the output of the Kable() command appear in Rstudio Viewer?
I’m trying to get a Latex table with the knitr package R, but I’m not getting the output to appear on Rstudio Viewer. For example, when trying to convert head(mtcars): kable(mtcars, "latex") I get…
-
3
votes1
answer62
viewsFill date.frame using for output
I wanted to know how to apply the logic of R to Python. For example: If I enter the code below in R: x <- data.frame() for (i in 1:10) { x[i,1] <- i } It will create in the date.frame x a…
-
3
votes1
answer89
viewschange the distance between the bar and the Y axis in r
How can I change the distance of the bars relative to the y axis using ggplot? using the code: k <- c("a","b","c","d","e","f") j <- c(3,5,8,1,2,6) df <- data.frame(k,j) ggplot(df,…
-
3
votes1
answer42
viewsStandardize phone number with REGEX on R
library(tidyverse) I’m trying to standardize the "numero_telefonico" column of this dataset: https://raw.githubusercontent.com/rivaquiroga/latinr-taller-regex/master/datos/telefonos.csv Download the…
-
3
votes2
answers145
viewsOperations with Data Frame
I need to do as the image below. What would it look like? I’ve already managed to isolate lines that are just zeros in all columns using the subset(Base,…
-
3
votes1
answer32
viewsCreate conditional with counter in a column
I have a basis that I need to know which number is greater than 100, but if I have a sequence of values greater than 100 I need the column to accumulate the value of 1 in 1, I added an output figure…
rasked 3 years, 9 months ago Roney Wesley Galan 179 -
3
votes1
answer69
viewsInsert names next to bubbles of a Bubble Chart into the R and exaggerate the difference between them
Good night I’m creating a bubble chart in R I was able to plot the graph and put the name next to the bubbles nome<-c("a","b","c","d") anos<-c(15,8,25,9) renda<-c(14,5,3,25)…
rasked 5 years, 7 months ago Henrique Faria de Oliveira 725 -
3
votes2
answers36
viewsCount frequency of occurrences including zeroes
For the following case the x count using the function table will return the frequency of the existing values. I would like to know how to return the count to the discrete interval from 1 to 12,…
-
3
votes1
answer553
viewsError trying to draw graph: "length of the larger object is not multiple of the length of the smaller object"
I have a function: my_gamma = function(x) { f = function(t){t^(x-1) * exp(-t)} integrate(f, 0, Inf) } I’m trying to draw your chart with ggplot2: plot = ggplot(data.frame(x = seq(0.01, 10)),…
-
3
votes2
answers450
viewsBar graph with ggplot2
How can I make a graph with the data below comparing the two areas? I would like to leave the Cerrado bars on the side of the Bosque bars. I tried many times, but I could only build the chart for…
-
3
votes1
answer495
viewsCreate an executable in R through the Shiny package
I wonder if it is possible to create an executable that goes directly to the panel generated by Shiny code without having to open the R and execute the codes library(shiny) # Define UI for…
-
3
votes1
answer40
viewsHow to reference columns in a R function?
My question is how to announce a column in the Arglist of a Function.Example: I want to do this library(data.table) a<-mtcars data.table::setDT(a) a[,.( disp2 = sum(disp), cyl2 = mean(cyl) ), by…
-
3
votes3
answers53
viewsmaximum values
how do I select the 5 highest values (km in this example) in a data set? I only know the function which() and max(), but they give only the greatest of all, not the biggest 5 for example. dados…
-
3
votes1
answer545
viewsCreate new column from existing column in R
I have a database in which the first column has the code of the disciplines of my institution and the second column has the name of the respective discipline. I want to create a third column where…
-
3
votes2
answers52
viewsCreate new columns of data in a data frame
I would like to create 2 new columns in my "Minimum" and "Maximum" date frame, where the value of these columns depends on the "Total area groups" column, where for example, when "Total area…
rasked 5 years, 4 months ago Ingled M Cardoso 159 -
3
votes1
answer71
viewsError in Webscraping process Youtube videos on R - NA' does not exist in Current Working directory
I am developing an academic work in which I should analyze the text of 25 selected videos on various Youtube channels. My advisor gave me a script about how he is developing this, so that I work on…
-
3
votes2
answers84
viewsPlot is different from function values
Hello, I plotted on Rstudio the function fdp.GUCU below, which is a normal distribution (0.1) when x is between -1 and 1, and a Cauchy (0.1) outside these limits. The problem is that the graph plot…
rasked 5 years, 3 months ago Tainá Caldas 71 -
3
votes1
answer42
viewsCreate new rows and columns for non-existent values
I have a date frame where the "years" column is not filled in all the data I need. I would need, for each observation, the 1988 to 2014 scale, filling with 0 (zero) the years whose values do not…
-
3
votes1
answer212
viewsChange the header color of the "Material" theme of the "rmdformats" package to an html output in Rmarkdown
I would like to change the header color of the "Material" theme of the "rmdformats" package to an html output of rmarkdown. I want to change from green to blue just the header, keeping all other…
-
3
votes1
answer75
viewsProblems automated formatting subsection Rmarkdown in R
I need to generate a report that has several sections and subsections, which depending on the month, may or may not appear in the database To get around the problem, I created an appearance…
-
3
votes1
answer30
viewsR splinefun with NA
Has anyone used splinefun with a set of data with NA? x<-c(0.7948801, 1.3248001, 1.5897601, 8.7436794, 9.5385607, 12.4531202, 13.2480008, 14.0428786, 23.0515214, 23.5814400, 28.3507206,…
-
3
votes1
answer64
viewsConverting from HTML/CSS to pdf using pandoc in R
Folks I’m having trouble converting my generated html/css file into Rmarkdown. You could help me? Follow my code: My file . Rmd --- title: "Table" output: html_document: css: "test.css" --- ```{r}…
-
3
votes1
answer33
viewsSome error bars do not appear on "sciplot" graph
There is a problem when I am making a averages chart in R using the "sciplot" package. For starters, this is the code for a part of my dataset: dados <- structure(list(Dias = structure(c(1L, 1L,…
-
3
votes1
answer111
views -
3
votes2
answers909
viewsHow to replace variables with NEGATIVE values with ZERO within a date.frame in R?
Let’s say I have a 6x5 data.frame, for example: print(Dados) Linha A B C D E L1 4 3 -1 2 4 L2 1 -2 1 -5 1 L3 -1 -1 2 3 4 L4 2 4 5 -7 9 But I want to replace the Negative values of the data.frame…
rasked 5 years ago Izak Mandrak 1,059