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
-
5
votes2
answers3494
viewsSecond-degree Polynomial Regression in R: How to Obtain X given Y?
Gurus do R, I have the following data frame (Df) that establishes the relationship between variables X and Y: X Y 1 25 2457524 2 25 2391693 3 25 2450828 4 25 2391252 5 25 2444638 6 25 2360293 7 50…
rasked 8 years, 2 months ago Weidson C. de Souza 163 -
5
votes1
answer210
viewsPlot grid histograms with fixed Y-axis - R
I would like to plot two (or more) histograms in R where the Y axis prevails a global value for all histograms. I don’t want overlapping histograms, I want overlapping histograms. The more histogram…
-
5
votes1
answer282
viewsinclude missing data
Good afternoon, i have the following problem. I need to put together two datasets that have 2 variables in common, "uor" and "mes". Only 1 variable has no values for a given month. And what I wanted…
rasked 8 years, 1 month ago Rafael Cunha 4,954 -
5
votes1
answer138
viewsI can’t install the stringi package on Centos
I’m trying to install the package stringi in a cluster that rotates Centos 7, but I am failing miseravelvente. The error that occurs is below: ** testing if installed package can be loaded Error in…
rasked 8 years, 1 month ago Marcus Nunes 17,915 -
5
votes2
answers256
viewsSort the k highest results using dplyr
I can select the k greatest results from a table in R. For example, if k equals 5, I get the following result: library(dplyr) library(ggplot2) top_n(mpg, 5, wt=displ) # A tibble: 5 × 11 manufacturer…
-
5
votes1
answer126
viewsShow information of a dataframe on a shapefile map
I have a table. dta that I already imported into the R. One of the columns of this file is called "Mun" and has the code of the municipalities of Brazil, a number of 7 digits. I lowered the…
rasked 8 years, 1 month ago Gabriel Herrera 51 -
5
votes3
answers749
viewsAdd currency rating in R
I have the following problem here at work: in a data frame I have a column of Gross value at certain date: 2016-02-01 751434574 2016-03-01 748873781 2016-04-01 755528121 To work in the R without…
rasked 7 years, 7 months ago Flavio Silva 1,108 -
5
votes1
answer119
viewsError installing R packages in Gitlab CI
When I try to install R packages using shell, the following error occurs: My code from the archive gitlab-ci.yml is as follows: before_script: - export DJANGO_SETTINGS_MODULE= ---- - pip install -r…
-
5
votes1
answer806
viewsError: Object of type 'closure' is not subsettable
I’m trying to encapsulate a code in functions but in the process such error happens: Object of type 'closure' is not subsettable But I can’t find why. Follow the code working: h = (b-a)/n B =…
-
5
votes1
answer663
viewsHow to export data from R directly to sql server?
Friends, I consumed a web service with R and now I need to export this data directly to sql server. How do I?
-
5
votes1
answer70
viewsHow do I exchange a apply inside a for for for a double apply?
I have a vector origem and a vector destino with different locations in latitude and longitude. For each location in origem, I want to count how many places in destino are located in a radius of up…
-
5
votes1
answer125
viewsTake the previous value with a condition on R
I have a single key base made of two other repeating variables, CNPJ and date. I need to do some sum and division accounts with the previous date values for each CNPJ. If there is no previous date…
-
5
votes1
answer220
viewsBarplot arguments
I made a graph with the barplot function, and I need to change the angle of the text on the x-axis, because the words are long. I know that to place them vertically use them=2, but I want them to be…
-
5
votes1
answer215
viewsComparison of value within data frame
Hello, I have a database, with about 50000 remarks, as follows, only figurative values: nome<-c("joão","pedro", "joãoo") identificador<-c(123456,124578,123456) valor<-c(2145,350,23)…
-
5
votes1
answer1047
viewsHow to generate a sequence of dates in r?
How do I generate a list with dates, for example, starting in 2011-07-01 and ending in 2011-10-31 ?
rasked 7 years, 3 months ago Filipe Vargas 95 -
5
votes2
answers1281
viewsHow to import . dat file to R
I downloaded a file . dat which is basically an array with data. However, it seems to me that the only way to work with him is by doing the following command (I’m using the R and I don’t have much…
-
5
votes1
answer139
views -
5
votes2
answers3756
viewsChart of average profiles (including error bars)
I have a dataset that I titled Amazonia, which can be downloaded in this link. I need to construct a chart of average profiles (including error bars) of the newborn weight variable ('weight'…
-
5
votes1
answer1755
viewsHow to import multiple excel tabs at the same time?
I am trying to reproduce the code below, but without success. What should I put in the argument path? Is it the same in all of them? Any clearer examples so I can understand? Any tips on how to…
-
5
votes2
answers331
viewsFilter Different texts at different positions in R
Good afternoon. I have the following data: NOME <- c("MARIA 1001", "MARIA 1002A", "JOSE 1003B", "PEDRO 1003", "CARLOS 1019J", “ANTONIO 50”, “MARIA 80”) VALOR <- c(10, 20, 30, 40, 50, 60, 70)…
-
5
votes1
answer16303
viewsHow to make and calculate the Frequency Distribution Table in R?
I’m trying to make the Frequency distribution table in R, however, I am not succeeding due to some formulas and calculations that I cannot implement in R. The structure of the frequency distribution…
-
5
votes1
answer85
viewsCode improvement
Good afternoon. I have the following data structure: structure(list(CIDADE = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label =…
-
5
votes2
answers961
viewsHow to convert string (in English) to date?
I have a data.frame with a column (mes) that represents the month and year of each observation that is in string form. I wanted to modify it to date so I could use proc in excel with date. How can I…
-
5
votes2
answers326
viewsRegular Expression R
I have a variable that indicates the year of Elementary School that a student is attending, but this variable was not fulfilled in a single way. For example the 1st Year of Elementary School because…
-
5
votes2
answers101
viewsComplete observations in a data frame
Suppose I have the following data set: dados <- structure(list(Ano = c(2001L, 2001L, 2001L, 2002L, 2002L, 2002L, 2003L, 2003L, 2003L, 2004L, 2004L, 2004L, 2005L, 2005L, 2005L, 2005L), Categoria =…
rasked 7 years, 4 months ago Marcus Nunes 17,915 -
5
votes2
answers552
viewsR - Selecting elements of a data frame with a column that has the same name as a global variable with`dplyr`
Consider the following data.frame and the variable x df <- data.frame(x = c(rep(0, 10), rep(1, 10)), y = 1:20) x <- 0 I tried to use the dplyr to select column elements x equal to the global…
rasked 6 years, 9 months ago Marcos Banik 1,779 -
5
votes1
answer274
viewsAutomatically identify points of influence in a regression
Whenever we make a linear regression, we need to verify that the hypotheses assumed for the model are correct. One of the best ways to do this is through diagnostic graphics. See the example below:…
-
5
votes2
answers1750
viewsHow to create a for in R with the indexes of a data frame
If I have a date.: > dato<-as.data.frame(matrix(1:64,8,8,T))[-3,] > dato V1 V2 V3 V4 V5 V6 V7 V8 1 1 2 3 4 5 6 7 8 2 9 10 11 12 13 14 15 16 4 25 26 27 28 29 30 31 32 5 33 34 35 36 37 38 39…
-
5
votes2
answers558
viewsHow to make concentric circles in r Plot
I need to make concentric circles, preferably displaced from the origin, in function plot() to serve as a visual reference to a function. I tried the abline(), but I was unsuccessful.…
-
5
votes1
answer111
viewsWhy is the latest prediction of the time series with the neuralnet package so far out of line with the rest of the predictions?
I set up a neural net to forecast seasonal precipitation from the observed series. When I validate with observed data, the results are good. But in the series predicted by the model, the latest…
rasked 7 years, 2 months ago Rodrigo Junior 115 -
5
votes2
answers899
viewsRenaming the levels of a factor based on a data frame
Suppose I have the date frame iris, present in the memory of R: head(iris) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3…
-
5
votes2
answers651
viewsHow to perform the tapply function for multiple dataframes in R?
I wish to perform only ONE function tapply and get results for each of the dataframes at once: dataset1<-data.frame(group = rep(c('a','b','c','d'), 3, each = 3), number1 = c(1:36), number2 =…
-
5
votes1
answer83
viewsChange chart fill orientation
I would like to know if there is a possibility to change the orientation of the filling of the colors of the following chart What I want is for the colors to be filled from the outside in. Does…
-
5
votes1
answer735
viewsSort of Dates ggplot2
Hello, that’s my first question in this world of R and I haven’t completely mastered it yet. I am learning this wonderful language and now I have serious problems plotting a graph using the package…
-
5
votes1
answer50
viewsProblem using ggplot by group
This is my dataframe: structure(list(ind = structure(c(177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L, 177L,…
-
5
votes1
answer69
viewsExtract dataframes from lists with dataframes under given criteria in R
I organized my list of dataframes like this: df.1<-as.data.frame(matrix(rnorm(10),10,80)) df.1.in.list<-split.default(df.1, gl(10, 8)) On the list df.1.in.list i would like to keep the…
-
5
votes2
answers78
viewsDeleting columns containing NA s in their last 5 rows
I have this personal dataframe, set.seed(1) df <- data.frame(A = 1:50, B = 11:60, c = 21:70) head(df) df.final <- as.data.frame(lapply(df, function(cc) cc[ sample(c(TRUE, NA), prob = c(0.85,…
-
5
votes1
answer1124
viewsWhat is the difference between Numeric and integer vectors?
In R, identical vectors (containing the same numbers) can assume the classes numeric and integer. For example: x<-(1:5) class(x) [1] "integer" x<-c(1,2,3,4,5) class(x) [1] "numeric" Why does…
-
5
votes1
answer387
viewsHow to make a difference in R dates?
dataset <- structure(list(PLACA = structure(c(5L, 5L, 5L, 4L, 1L, 2L, 3L, 7L, 6L, 8L), .Label = c("DSF9652", "EFR9618", "EQW6597", "ERB1522", "EWM3539", "LOC1949", "LQQ5554", "OQT5917"), class =…
rasked 6 years, 9 months ago Diego Peliciari 319 -
5
votes2
answers817
viewsOverlay graphics in R with ggplot
Hello, consider two data frames: df = the number of students who answered items A,B,C,D and E of a 6-question test ITENS <-c("A","B","C","D","E") Q.1 <-c(10,20,10,40,10) Q.2…
-
5
votes1
answer595
viewsImport multiple excel tables at the same time
I want to import 27 Excel tables into R without having to type 27 times the import command already, that the table names go from tab101 to tab127. I tried that way, but you made a mistake:…
-
5
votes1
answer93
viewsHow to change the distance or rotation of the axis heading of a graph relative to the axis itself
I make the graphic below using the plot3D package of R. I would like to move the label a little away from the z axis ($f(y_{1},y_{2})$) of the values of the axis or leave it horizontal. Does anyone…
-
5
votes1
answer310
viewsProblems accessing a website via Rstudio
Problems when connecting there is a particular site via Rstudio url <- "https://www.jusbrasil.com.br/diarios/busca?q=%22licen%C3%A7a+sem+vencimentos%22&idtopico=T10001849&o=data" links…
-
5
votes2
answers226
viewsHow to add space in "boxplot" and center the middle
I would like to make two modifications to the following chart : Leave a small space between the green(F) and orange(s boxplot) Place the point referring to the median at the center of each boxplot…
-
5
votes2
answers214
viewsApplication of the `assign` function in loops
I want to play names in variables with a loop. With for I can get: library(tidyverse) for(i in 1:6){ names<-str_c('var',i) assign(names,runif(30,20,100)) } But with lapply and map nay: lapply…
-
5
votes2
answers498
viewsHow to make mobile sum in R?
I have a vector 1:50 and need to perform a moving sum (equal to moving average), that is, in the case of the last 5 observations, the new vector would be c(sum(1:5), sum(2:6), sum(3:7), ...,…
-
5
votes1
answer60
viewsHow to implement mappers in R?
I would like the answer to contain information on: What are mappers? How to create a mapper on R? In what situations mappers are used (their role in functional programming)?…
-
5
votes1
answer3753
viewsHow to change the y-axis scale on a line chart
I’m trying to plot a graph where the points on the y-axis vary in decimal places but I couldn’t adjust the axis scale to vary in decimal places as well. t_mean = c(30.24, 30.73, 30.94, 31.97, 31.28,…
-
5
votes2
answers49
viewsExtract vectors from a vector set of vector names and merge into a single vector
I have a vector that contains names of other vectors. For example: teste [1] "vetor_arte" "vetor_rio" "vetor_parque" vetor_arte [1] 1 3 4 11 12 13 14 16 29 30 41 vetor_rio [1] 6 7 8 9 10…
-
5
votes1
answer647
viewsHow to deal with multiple quotes in R?
My problem is using quotes in a query within a R function. I have to call a list of select * from probes."probes_90_2018-05" For that I do: coelho<-dbConnect("PostgreSQL", fnord)…