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
-
1
votes1
answer42
viewsHow To Order In R
How to sort numbers in r dados = order(dados, decreasing = F) dados Here only orders the position... I wanted to know a method of sorting the numbers that are in the given list: dados =…
-
1
votes1
answer36
viewsRandom Number Generator with Restrictions
I need to define randomly the weight of an investment portfolio that is divided into three types and cm the following limitations: Fixed income [0-100%] Variable Income [0-30%] Investment abroad…
-
1
votes1
answer40
viewsHow do I do a repeat structure function on R?
I’m trying this way: H <- function(n) { for (i in 1:length(n)) { x <- 0 a <- 2 b <- 3 func = x + a/b a+2 b+2 return(func) } } Does anyone know how to solve?…
-
1
votes1
answer87
viewsHow to use the `dplyr::rowwise` function with more than one variable?
Consider the data set below: df_1 <- data.frame( x = replicate(4, runif(30, 20, 100)), y = sample(1:3, 30, replace = TRUE) ) I did the following analysis: library(tidyverse) df_1 %>%…
-
1
votes1
answer465
viewsChange colors of the scale of a bubble chart in R
I’m having trouble creating a color scale for my chart nome<-c("a","b","c","d") anos<-c(15,8,25,9) renda<-c(14,5,3,25) final<-c(30,15,42,12) tudo<-cbind(nome,anos,renda,final)…
-
1
votes1
answer37
viewsRemoval of automated outilers
I need to remove outliers from a database in a "manual" way, I would use the following command: a=X Q1<-quantile(X,0.25) Q3<-quantile(X,0.75) IQR<-Q3-Q1 lim_inf=Q1-1.5*IQR…
-
1
votes1
answer27
viewsHow to plot expressions within facet_grid()?
I’m having trouble plotting two distinct expressions: expression 1: "RN (MJ m"^2~"d"^-1~")" expression 2: "ET"[0]~~" (mm"^-1*" m"^2*" )" inside: ggplot()+facet_grid(labeller = label_bquote()…
-
1
votes1
answer40
viewsWhat is the difference between the bar graph and columns in R?
I would like to know the practical difference between the bar and column charts, because I see in ggplot for example that there are commands geom_bar and geom_col. What would be better or what the…
-
1
votes1
answer115
viewsHow to proceed non-linear regression by the mitscherlich model?
Hello, good afternoon! need to perform a nonlinear regression analysis nls(), and suggested me the mitscherlich model: I don’t know how to accomplish, I’d like your help! follows the example of the…
-
1
votes1
answer19
viewsIs there a way to replace the 0 of one column with values of another column in the dataframe in R?
I made a merge of 2 dataframes and I realized later that I had 2 columns that have the same information. As in the example below: linha qt_funcio nu_funcio ... 1 0 3 2 0 4 3 0 1 4 2 0 5 4 0 6 1 0 I…
rasked 3 years, 6 months ago Igor Moreira Alves 13 -
1
votes0
answers103
viewsnaive Bayes - Warning message: In data.Matrix(newdata) Nas introduced by coercion
I was able to run the algorithm naive Bayes on R, but I’m finding problems to make the result confounding matrix. This is the message I receive after performing the prediction with the command…
-
1
votes2
answers42
viewsGraph error in R: "invalid color name"
I’m working with the data set starwars, package dplyr. My goal is to create a chart with this data, where the independent variable is the height of the characters, and the dependent is their body…
-
1
votes2
answers2242
viewsShow Data Labels in Column Chart in R (ggplot2)
I’m a beginner in R and I’m trying to create a bar chart and I can’t display the data labels on each bar. Follow link to the used data frame:…
-
1
votes1
answer1846
viewsLanguage R: How to get scientific numbers out of graphs?
data frame taken from this command in the database: mes = base_final %>% group_by(mes)%>% summarise(soma_trs = sum(valor_trs)) dataframe mes <- data.frame(mes=c ("agosto/2017" ,…
-
1
votes0
answers76
viewsDownload pdfs from different site queries
I would like to download pdfs of different queries from the following site website to download the data However as the link does not change with each new query of municipality, I do not know how to…
-
1
votes0
answers128
viewsHow to create graph in Rstudio with ggplot?
I need to create a simple bar graph with data from a data frame. But I want to divide each bar of the graph into three. For example: In the bar referring to the year 2000, I have to put three…
-
1
votes1
answer69
viewsCombine file . shp with a data frame
I read a file . shp with the package sf. map_recife = st_read("./shape/Bairros.shp", stringsAsFactors = FALSE) > glimpse(map_recife) Observations: 94 Variables: 11 $ CBAIRRCODI <dbl> 19,…
-
1
votes1
answer32
viewsDo a function that returns the average of the notes that person participates in R
How can I do a function that returns the average of MARIA notes my code is like this: PESSOA = (got$Personagens) NOTAS = (got$Nota) medianotas = function(tabelaNotas, tabelaPessoas, nome) Nota = c()…
rasked 5 years, 5 months ago Lucas Nascimento Tavora 11 -
1
votes1
answer55
viewsQuantitative position
I need to calculate the percentage of days that are in a certain range of values in the analyzed column (values are in percentage) in relation to the total quantity of days for that month. Initially…
-
1
votes1
answer23
viewsR language - Column separation
I have the two columns below and I need to separate them so that the digits are in other columns. The idea is to have at the end 4 columns with names of teams and score. Two columns of df2 type…
-
1
votes0
answers113
viewscolors of the interaction line in a network
I would like to elaborate a network (network) type chart. In this chart I would like the colors of the interaction lines (col.interaction) are the same colour as the upper boxes (col.high). Could…
-
1
votes1
answer44
viewsExtract position of values in a matrix in R
I have the following data: numbers <- c(303, 2107, 35000) matriz <- matrix(1:90000, nrow = 300, ncol = 300, byrow=T) I need the position of the values in the matrix. I am trying with the…
-
1
votes0
answers31
viewsWindow accumulated in R
I need to rank days based on a cumulative window of all the days before it. In this case, I need to start with a 252-day window, sort the observations, make a ranking of 20 equally distributed…
rasked 5 years, 5 months ago AparecidaMartins 21 -
1
votes3
answers1493
viewsHow to number lines of a data.frame in R?
Assuming I have the following date.: print(DADOS) letra N1 N2 N3 N4 A 2 3 4 4 A 1 2 3 4 A 2 2 1 3 B 0 1 2 0 C 4 4 3 2 C 2 2 2 2 D 4 3 2 1 D 1 0 1 4 E 4 4 4 4 How can I number the lines of my…
rasked 5 years, 5 months ago Izak Mandrak 1,059 -
1
votes1
answer106
viewsHow to generate charts of daily, monthly and annual averages in time series data in R?
I would like to know how to make averages of various intervals, minimum and maximum daily and monthly of a time series of a file that has two columns (date and temperature value), but the date is in…
-
1
votes1
answer847
viewsloop For, R - Include function in For and save result to object
install.packages("xlsx") install.packages("stringr") library(xlsx) #pacote para ler os arquivos do excel library(stringr) library(e1071) #pacote para calcular a curotse e o skewness #Função que…
-
1
votes1
answer75
viewsHow to plot only a part of a Posixct variable?
I have a df with two variables. The first is a time counter that reaches 9min at a 1000Hz acquisition rate (so it’s huge 540 thousand lines). The second variable is an electrophysiological…
-
1
votes2
answers317
viewsRead error with the fread function of the data.table package
By downloading the database of values of daily and tickets 2019 the portal of transparency http://www.portaltransparencia.gov.br/download-de-dados/viagens, I used the code below to read the daily…
-
1
votes0
answers60
viewsGraphic arts in Barra com Da
I’m trying to create a chart like this in R. I did all the work in R to return a table as shown below. But when I do the graph, it limits me to have x and y axis, and in the graph above the x axis…
-
1
votes1
answer142
viewsCreate table Stargazer function mq in R
I have the data below and would like to create a table Stargazer to generate in latex a pdf. How could I do? x=matrix(rnorm(1500),500,3) mq(x) > mq(x) Ljung-Box Statistics: m Q(m) df p-value [1,]…
rasked 5 years, 4 months ago Everton Toledo 113 -
1
votes1
answer211
viewsPackage installation "tabulizer" error in R
I’m trying to install the package tabulizer in R and I’m not getting it. I also tried downloading directly from CRAN, but it also didn’t work. I also tried installing the tabulizerjars separately…
-
1
votes2
answers72
viewsHow to Find a value between columns
x = data.frame(Índice = c(1,2,3,4,5,6,7,8,9,10), Data = as.Date(c("2019-01-22", "2019-01-21", "2019-01-20", "2019-01-18", "2019-01-17", "2019-01-16", "2019-01-15", "2019-01-14", "2019-01-11",…
rasked 5 years, 4 months ago Thallys Geovany 13 -
1
votes1
answer396
viewsR - Geom_col with division per year
Expensive, I have the following database: I want to plot a chart like the one below using ggplot: I’m trying to do this with the following code, but I’m not getting a good result. ggplot(Database,…
-
1
votes1
answer52
viewsGraph in R - ggbarplot - Axis X with Supervisor / Date
I can’t make a chart by ggbarplot with the X axis being supervisor and the Date. I put my data to long according to the orientation found in this other question: Bar graph with ggplot2 But I stumble…
-
1
votes1
answer93
viewsAdding an area shaded over a Plot in the R?
I’m making some graphs using R, and I need to make a highlight (shaded area in a given location), but I can only plot. Follow the image I can generate: The highlight has to be a rectangle that goes…
-
1
votes1
answer612
viewsHow to break a line in the title of the graph into 2 lines using ggplot?
I need to break the title line of the chart so that it stays at the width of the chart itself. The reason is that the chart will be used in a grid.arrange() and in this way it will become narrow and…
-
1
votes1
answer41
viewsEnd of run message in a Shiny app
I’m developing a Shiny app, where I have several actionButtons which, when clicked, execute other codes through the function source or render according to the following example: library(shiny)…
-
1
votes0
answers61
viewsHow to preserve the date column by exporting a ts or xts object from R to excel?
I am working with a ts file with two variables compib <- cbind(pimsaf, fumosaf) head(compib) pimsaf fumosaf [1,] 77.74133 131.5189 [2,] 80.18227 131.6221 [3,] 79.77395 111.2698 [4,] 79.48862…
-
1
votes1
answer399
viewsHow to perform a prediction using Multivariate Linear Regression model in R?
I am studying solutions to perform a prediction of a product that depends on other variables. In this my study I am using as my database Seatbelts, a Time Series that is already native to R. Which…
rasked 5 years, 3 months ago Izak Mandrak 1,059 -
1
votes1
answer53
viewsConsult Multiple Columns in R
I have a DF and would like to consult multiple columns at the same time in an Auxiliary Table. Example of DF: MATRICULA <- c(123,456,789,111,222,333) DIA_1 <-…
-
1
votes0
answers33
viewsProblems with the Rselenium
I’m trying to create a code where I can extract the amount of news from certain listed companies. But I’m having a lot of problems with the code. Especially with the loops. library(RSelenium)…
-
1
votes0
answers85
viewsKs and Chi Square test for reliability data in R
I’m using parametric models to calculate some reliability items. The question is how to perform the adhesion tests (Test Kolmogorov-Smirnov- KS and the Square chi - χ2) . I tried using the "Ks.test"…
-
1
votes1
answer259
viewsHow to import a file . xls in R keeping accented names in categorical variables?
I imported a file into . xls that contains columns with drug names and their class. Some names have accents like "Antipsychotic", "Benzodiazepine" and "Tricyclic Antidepressant". I used read.xlsx as…
-
1
votes0
answers59
viewsERROR: The "x" line break is not justifying left
I made a line break in the title of the "x" axis using the " n" and the break did not respect the horizontal justification on the left. Follow the data: > dput(PCLstack) structure(list(Grupo =…
-
1
votes1
answer441
viewsSet percentage values in bars in ggplot
I would like to know how to add the percentage values in the bars of the ggplot graph. On the x axis I was able to add, but not on the bars. I would like to add in the same percentage format. The…
rasked 5 years, 2 months ago Letícia Marrara 95 -
1
votes1
answer474
viewsBar graph in ggplot in r
The database I’m reading is as follows: Trimestre PIB 1º T 2018 0.005 2º T 2018 0.000 3º T 2018 0.005 4º T 2018 0.001 1º T 2019 -0.001 2º T 2019 0.004 I made a bar Plot with the following code:…
-
1
votes1
answer87
viewsPlot of lines in ggplot
I have the following data: Ano PIB 2008 0.05 2009 0.00 2010 0.08 2011 0.04 2012 0.02 2013 0.03 2014 0.01 2015 -0.04 2016 -0.03 2017 0.01 2018 0.01 When I do Plot using geom_line of these data it…
rasked 5 years, 2 months ago Letícia Marrara 95 -
1
votes1
answer558
viewsHow to load an Oracle database into R?
I have access to an Oracle database, but have always used this data in the R using the PL/SQL to extract the data in csv. But now I would like to connect my Oracle database on itself RStudio. After…
-
1
votes2
answers509
viewsHow to create a sequence of dummy variables with loop in r
I would like to create Dummies to identify the company in the database. For example, a new variable called "GLO" would be 1 if the enterprise variable assumed the value GLO and 0 c.c. The data…
-
1
votes0
answers25
viewslevenshteinSim in R using two dataframe
Dataframe: dataNomeAlunos NomeAluno Nota Materia Marcos Souza Magalhaes 10 Port Junior Moraes 5 Mat Mirela Chavier 3 Port dataNomeMatch NomeAluno Nota Materia Marcos Sousa Magalhaes 10 Portugues Jr…
rasked 5 years, 2 months ago Brenda Xavier 410