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
-
9
votes1
answer2601
viewsEdit bar graph in R: Order of X-axis values - Caption - Bar color - Insert straight - Insert comments
1 - Contextualization I want to build a bar chart using the ggplot2, however I am having difficulties to gather the information and to make the graphic edition. I have data of the oscillation of the…
-
9
votes1
answer3518
viewsPush git "Everything up-to-date " Data is not actually sent
I’m pushing to a repository in gitlab.com. I get the feedback: Warning: redirecting to https://gitlab.com/fellipesillvaoff/Dados_Agronomia.git/ Everything up-to-date In my mind, it worked. In…
-
9
votes2
answers1974
viewsModify gradient colors in graphs in ggplot2
How do I modify the gradient colors of a graph in ggplot? Like, I’m not getting to put a continuous color scale between white and red, I’ve tried a variety of things but still haven’t answered me.…
-
9
votes3
answers166
viewsFind an expression in several elements of a list
Guys, I got a problem. I have 200 spreadsheets with some data from a survey, and I am importing into R and, because they are with different columns, I assign to each element of my list a different…
rasked 6 years, 2 months ago Jessica Voigt 883 -
9
votes1
answer307
viewsHow to fill column charts with hachuras using ggplot2
I would like to present column charts using the ggplot2, but I would like them to be filled with hachuras. Because it facilitates the understanding in case of photocopy in black and white! Using the…
-
9
votes1
answer183
viewsWhat is a Shiny app?
It is common to have to expose a data analysis in a more user-friendly format. In these cases it is also common to hear as a suggestion that this analysis be transformed into a shiny application.…
-
9
votes2
answers1438
viewsWhat is wide/long data?
It is common to read/hear comments saying that the data is in format wide or long. Which means a table is in format wide? And long? Which packages/functions in R can be used to transform a table…
rasked 5 years, 9 months ago Tomás Barcellos 5,562 -
9
votes1
answer161
viewsDifference between Function Factory and closure
In the book Advanced R, to chapters 10 and 11, the author defines Function Factory as: "a Factory for making new functions" Translation Google Translate: a factory to do new functions. And closure…
-
9
votes2
answers300
viewsDifference between "Function Operator" and "Function Factory"
To the chapter 11 of the book Advanced R, the author defines Function Operator as: A Function Operator is a Function that takes one (or more) functions as input and Returns a Function as output.…
-
8
votes2
answers637
viewsHow to make a conditional y~x graph for each data.frame factor?
Suppose a data.frame like the following: set.seed(1) dados <- data.frame(w=rep(c("A", "B", "C", "D"), 50), y= rnorm(200), x=rnorm(200), stringsAsFactors=FALSE) How to create a chart y~x separated…
-
8
votes4
answers19992
viewsHow to transport data from R to excel?
I calculated a series of data in R and would like to know which command I should use to transport them to an excel spreadsheet.
-
8
votes3
answers34320
viewsHow to import excel data pro R?
I have a table in excel that I need to import to R. I could do it quietly with the function read.csv when the table in question was online, but I’m having difficulty importing the file directly from…
-
8
votes2
answers389
views*apply with three-argument functions in R
I created a function of three arguments and I want to apply it to a Matrix 200 X 3 where in each line are the three arguments I need to use in the function. As a result I would get a vector of size…
-
8
votes2
answers472
viewsCreate columns in R from another where some values are null
I want to create a column from another in the R, where part of the lines have no value. The column should be constructed as follows: if the row of the base column has value, it will look for the…
-
8
votes2
answers1533
viewsWhat does <<- mean in R?
What the operator means <<- in R, what are your differences with respect to <- and under what circumstances it may be useful?
rasked 10 years, 2 months ago Carlos Cinelli 16,826 -
8
votes1
answer480
viewsIs there a way to open a direct SQL table in a data.table, without doing the SQL path > data.frame > data.table?
I want to open a direct SQL table in a date.table. When I do a query with dbGetQuery, what I get is a data.frame. I know I can then turn that data.frame into a data.table easily. But I would like to…
-
8
votes3
answers7816
viewsSeparate contents from one column in other columns
I have a file in table form. I need to separate the contents of a specific column in other columns, the data are separated by ;. Well I managed to do this, but the problem is that the content will…
rasked 9 years, 6 months ago Joyce Maia 387 -
8
votes1
answer138
viewsHow to extract values from the statistics calculated by the linhom function (L-Function for inhomogeneous Spatial point processes)?
I have to analyze the spatial pattern of some cactus distributions in the field, and since they are heterogeneous, I cannot use Ripley’s K-function (and corresponding L-function) for stationary…
-
8
votes5
answers8758
viewsHow to remove line that has Missing?
I have a database that has some missings (NA’s), but only one variable (one column), and I need to remove the entire row that has Missing.
rasked 9 years, 2 months ago Wagner Jorge 1,377 -
8
votes1
answer489
viewsHow to resolve java.lang.Noclassdeffounderror when running rhinit() in R
I’m integrating the Hadoop with R using Rhipe and my configuration is as follows:: Ubuntu 14. Hadoop 1.0.3 R 3.2.2 Rhipe 0.73.1 When starting in the environment R the rhinit() the following message…
-
8
votes2
answers1310
viewsHow to remove a word from a string without changing larger words that contain it
I would like to remove a word from a string in R. I was doing it as follows: > s <- "ele esta bem mas tambem esta triste" > stringr::str_replace_all(s, "tambem", "") [1] "ele esta bem mas…
-
8
votes2
answers2782
viewsIs there a difference between assigning value using '<-' or '=' in R?
In practical terms there seems to be no difference, but underneath the cloth as language processes there is some difference?
-
8
votes1
answer2268
viewsIn R, using the plotly package, can I plot the map of Brazil and its states?
I really like the package plotly to make interactive graphics. But at the time of making maps, I have not found so far a way to make the map of Brazil and its states... For example, I removed this…
-
8
votes1
answer469
viewsHow to calculate the median when the data is in Chunks?
Suppose my data is divided into 2 vectors: x <- c(100, 400, 120) y <- c(500, 112) I could calculate the median by joining the two vectors and then using the function median. median(c(x,y)) [1]…
-
8
votes1
answer514
viewsCount sequences of 1 within vector in R
I would like to know how to count sequences of 1 within a vector containing only 0 and 1. For example, in the vector x <- c(1, 1, 0, 0, 1, 0, 1, 1), the count would give the vector (2, 1, 2),…
-
8
votes1
answer1958
viewsAre there any R functions similar to excel PROCV?
In my case I have two date frames.: > head(Trecho) Xt Yt Zt 1 -75.56468 1.642710 0 2 -74.56469 1.639634 0 3 -73.56469 1.636557 0 4 -72.56470 1.633480 0 5 -71.56470 1.630403 0 6 -70.56471 1.627326…
rasked 7 years, 6 months ago Aurenice Figueira 83 -
8
votes1
answer748
viewsfilter in dplyr using a categorical variable
Suppose I have the following data set: set.seed(12) dados <- data.frame(grupos=rep(letters[1:5], 5), valores=rnorm(25)) head(dados) grupos valores 1 a -1.8323176 2 b -0.0560389 3 c 0.6692396 4 d…
-
8
votes1
answer1224
viewsAdd line to line in a date.table in R
Is there any method that can be added row by row in a date.table in R without using a'for', so that the value of the next row in a column is the value of the previous row added with a value…
rasked 7 years, 4 months ago mbranbilla 314 -
8
votes1
answer1670
viewsBar graph sorted using dplyr and ggplot2
I would like to create a bar chart after counting the number of occurrences of the categories of a data set. Suppose my dataset is this below: dados <- structure(list(categorias = structure(c(5L,…
-
8
votes2
answers164
viewsRemove all Environment elements containing numbers and uppercase letters
Consider the objects: vectorA<-1:10 vectorU<-1:10 vector<-1:10 vector1<-1:10 vector86<-1:10 How to remove objects containing numbers? How to remove objects containing uppercase…
-
7
votes6
answers31940
viewsHow to remove a data.frame column in R?
Suppose a generic date.frame, such as: set.seed(1) dados <- data.frame(y=rnorm(100), x= rnorm(100), z=rnorm(100), w=rnorm(100)) head(dados) y x z w 1 -0.6264538 -0.62036668 0.4094018 0.8936737 2…
rasked 10 years, 9 months ago Carlos Cinelli 16,826 -
7
votes1
answer4682
viewsHow to create a Plot with 2 superimposed histograms?
Suppose I have the following data from 2 distinct groups. set.seed(1) grupo1<-rnorm(400,6,2) grupo2<-rnorm(200,8,2) How I make a histogram of the two groups on the same screen, identifying…
-
7
votes3
answers3287
viewsHow to put the regression equation on a graph?
On another question saw how to put the regression line on a graph. But, how to put the regression equation in the graph? For example: Or…
-
7
votes2
answers4567
viewsHow to turn a string into Date format in R?
In the code below the dates are in the format: Mes Dia Ano. I need R to recognize the variable as date. #importa os dados library(XML)…
-
7
votes1
answer339
viewsHow to declare constants in R
when I went to reproduce the example of the question "How to turn a string into Date format in R?" the command tab<-readHTMLTable(u,header=T,skip.rows=1) failed. The error happened because in my…
-
7
votes1
answer473
viewsHow to generate correlated variables in R?
I managed to create the uniform variables X and W, both with normal distribution, using the formula rnorm in the R. However, I wanted to create variables so that they had a -0.8 correlation value.…
-
7
votes2
answers302
viewsConnecting the points to the regression line
Suppose the following database: Income <- structure(list(X = 1:30, Education = c(10, 10.4013377926421, 10.8428093645485, 11.2441471571906, 11.6454849498328, 12.0869565217391, 12.4882943143813,…
-
7
votes2
answers969
viewsHow to do an optimization with inequality restriction?
Suppose I want to minimize the following function: -(5-(x1-2)^2-2*(x2-1)^2) s.a. x1+4*x2 < 3 For optimization problems without restriction I can use the following code. fr <- function(x){ x1…
-
7
votes2
answers132
viewsHow to create a pop-up warning that the script has come to an end?
I would like to display on screen one pop-up notifying that the code just ran. The only script I have, follows below, is the one that opens a command window. system('CMD /C "ECHO O seu script chegou…
-
7
votes1
answer1025
viewsHow to turn hours into seconds in R?
I have the following schedules: 2:00:00 3:00:00 6:00:00 4:00:00 4:00:00 3:00:48 1:00:00 3:00 2:00:00 4:00:00 1:30:00 2:00:00 1:00:00 3:00:00 4:00:00 4:30:00 5:00:00 1:00:00 1:30:00 2:00:00 3:00 3:00…
-
7
votes2
answers6648
viewsHow to change the language of R?
When installing the r on my machine I realized that the menus and console outputs were all in English. How do I change to English? Inside the RGui I couldn’t find any option to change the language…
-
7
votes3
answers2670
viewsKnow the frequency of words
Hello, I wonder if there is a function/command in R that I can know which are the most frequent words in a text and how often it appears. For example, I have a very large database, but it is a…
-
7
votes1
answer339
viewsWork with errors within R loop
I entered the non-linear adjustment function gnls within a loop for so that it could test a series of start values automatically. The point is that eventually some of these start values create a…
-
7
votes2
answers2472
viewsR - download CVM data via POST (package httr) method
I am trying to build a R function to download multiple documents directly from the system provided by CVM. The general instructions given by the CVM for the multiple download are described in:…
-
7
votes2
answers3134
viewscalculate difference between two dates in months on the R
How do I calculate the difference between two dates in months on the R? Suppose the two dates: x <- as.Date("2014-01-07") y <- as.Date("2015-03-17") I can easily calculate in seconds, minutes,…
-
7
votes1
answer424
viewsvector moving mean of a matrix in R
I’m doing the following operation with a matrix in the R: > m <- matrix(1:9, ncol = 3, nrow = 3) > m [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > m2 <- m > for(i in…
-
7
votes2
answers686
viewsHow to make webscrapping of an https using rvest?
I would like to shave a page that is in https using the package rvest. However, it is a website with problems in the security certificate. In such cases, you need to turn off the SSL verification --…
-
7
votes3
answers108
viewsHow can I restructure information contained in a list object into two columns?
Considering a list x composed of nvectors. To illustrate the problem I thought it had 3 elements, as follows: >x $`2751006` [1] 106.2 75.4 65.4 87.4 76.8 196.4 74.2 $`2751007` [1] 73.9 110.1…
-
7
votes1
answer272
viewsHow to know the arguments contained in '...' in a function in R?
In R can be used '...' so that the function receives an undetermined number of arguments. How to know which arguments were used in the function? Example, if I wanted to print the arguments used.…
-
7
votes1
answer391
viewsIn R, correct typing errors followed by a database processing
This problem is quite complex and needs two stages. The first stage consists of correcting typing errors in a database (perhaps a probabilistic solution). The second stage is to tidy up this…