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
-
2
votes2
answers110
viewsAuto increment in R
How do I generate an auto incremental ID field (1,2,3...) in a data.frame in R that in a new column? meuDataFrase<- as_tibble(unique(tabelImportada$ColunaX)) I need to create a new column on that…
-
2
votes1
answer42
viewsCan anyone tell me if you know any R packages to use with the quasi-beta distribution family in this model?
Can someone tell me if you know any packets of R to use with family distribution quasi-beta! model: pse <- (ps~tr+tra+ds+(1|prop)+(1|in)+(1|nr),data=pes1,family = "???????")…
rasked 4 years, 5 months ago Everton Braga 33 -
2
votes1
answer198
viewsDifference in Main Component Analysis (PCA) graphs
Today I was analyzing a data set and realized something I had never noticed before. In order to visualize a multivariate data set, I created your PCA and designed the observations into the two main…
-
2
votes1
answer930
viewsRselenium - "This version of Chromedriver only Supports Chrome version 74"
I’m trying to use the Rselenium, but it seems that the chromedriver version has been updated and is returning the following error: "Selenium message:Session not created: This version of Chromedriver…
-
2
votes1
answer371
views -
2
votes1
answer104
viewsHow to read a dataset over http in R?
I have access through a link: 'http://**.**.**.**/matrix/pesquisa_2019-03-17.feather' ou a<-readRDS('http://**.**.**.**/matrix/pesquisa_2019-03-17.rds') But I can’t access them…
-
2
votes1
answer49
viewsCreate column with another column value if conditon is TRUE
I am trying to create a column x, with the value of column A, if the value of column B == X, if not = 0 Example: sales<-c(100,140,200,300,20,1000,200,3000)…
-
2
votes1
answer216
viewsInsertion of intervals with the if Else condition structure
Consider the vector and function: j <- 1:10 my_fun <- function(x) { sapply(x, function(x) { if (x == 5) { ('EM ANALISE') } else if (x < 5) { ('REPROVADO') } else if (x > 5) {…
-
2
votes1
answer79
viewsFiltering a data.frame based on multiple variables
I have a data.frame with 9 variables from X1 to X9. The values of these variables are double. I need to filter the lines of this data.frame that contain (Xi,Xj,Xk) == (5.2,6.3,7.1) for example. I…
-
2
votes1
answer207
viewsHow to select the last 3 columns in a data frame in R?
I have a database that is updated monthly, which has 7 columns: USUÁRIO, and the last 6 months of the year with the amount of purchases for each month. Following example: print(DADOS) USUÁRIO JAN…
rasked 5 years, 7 months ago Izak Mandrak 1,059 -
2
votes3
answers95
viewsDate sequence from a range in R
Good morning, I have a base with ID, start date and end date. I wanted to generate a basis that each row be one day within the range with an ID column. Groundwork: base <- data.frame( ID =…
-
2
votes1
answer122
viewsComma to Numeric number conversion in R
I have a script that receives a user value, via readLines. This value is a number (monetary value) with two decimal places that must be saved in a frame date. However, when I convert the received…
-
2
votes1
answer166
viewsHow to fix problem with special characters in Knitr::Kable and kableExtra for a PDF report
I’m trying to customize a chart using R Sweave. The problem is that the R output messes up the symbol , in some cases did not exit the bar in the file . tex which causes error, but already fixed…
rasked 5 years, 7 months ago Marcelo Rodrigues 123 -
2
votes1
answer58
viewsmerge dataframe by lines
I have 2 data frames and would like to merge a data frame with another data frame by the value column, subtracting the values of each line. The data frames I have are : df1: UF Ano Valor 1 AC 2007…
rasked 5 years, 7 months ago Ingled M Cardoso 159 -
2
votes2
answers213
viewsReorder bars in ggplot2 according to one of the fill variables (Fill)
Hello, I have a graph that shows the proportion of equipment available in schools of Pernambuco, and I would like to order it from the equipment with greater presence (greater has) to those with…
-
2
votes2
answers62
viewsPerform a previous values calculation in column on R
I would like to assemble a column according to the result of 2 lines of another column, follows the formula below, I have no idea how to assemble this in R or Python and would like a collaboration…
-
2
votes1
answer41
viewsR - how to use . xlsx and . csv files with onedrive url
I would like to replace the file name for a link that downloads the file directly from onedrive. My intention would be to share with someone only the R script and it could run straight without…
-
2
votes2
answers46
viewsMultiple Moving Medium Columns
I would like to create several columns derived from the column x. These columns should receive moving averages of 2, 5... periods. I tried to do the creation with dplyr::mutate, but it didn’t work.…
-
2
votes1
answer290
viewsGrouping of data - Histogram R
Good morning, everyone. I’m trying to do a histogram with ggplot(), but I’m having a hard time with one detail. Basically I would like to manually group the data that gets inserted inside each bin…
-
2
votes1
answer261
viewsHow do you put three time series into one?
I’m trying to put three time series together in one, but I’m having a lot of problems. I used the junction c of R, but it is not useful to me because as it comes to monthly series, this command…
-
2
votes1
answer64
viewsHow to extract only the first value from a row of concatenated values?
I have the database below, and would like to capture only the first value of each line. a <- data.frame('Exports' = c("c(182752.414, 179107.7)", "c(200491.435, 195097.2)", "c(217566.642,…
rasked 3 years, 9 months ago Roney Wesley Galan 179 -
2
votes1
answer74
viewsHow to create a data frame with vectors of different sizes?
The result of the loop for each iteration is a vector. I intend to send this vector to a data.frame and then export it to Excel. I basically use the cbind function to send each of my 10 model…
rasked 3 years, 9 months ago Manuel Almeida 29 -
2
votes1
answer69
viewsIn R, is there a difference between double and single quotes?
I am starting my learning in R and would like to know the difference between creating strings using single or double quotes. For example: texto1 <- "isso é um texto" texto2 <- 'isso é um…
-
2
votes1
answer51
viewsWhy R is not finding the created function
Before I had made an extremely large code to be able to extract the results I expected, but the code got quite slow and with that, I’m trying to optimize it: Previous code: Rent division…
-
2
votes1
answer118
viewsHow to use external functions within the server using Shiny?
I am creating a graphical interface for an algorithm I developed in R language. The algorithm has several scripts with functions that talk to each other, and after started, it takes hours to…
-
2
votes1
answer46
viewsHow do I build the Summary() function in R for a data frame?
I’m trying to do it this way dados<- c(10,18,19,15,21,34,45,64,20,21,39) resumo <- function(x) { min(x) max(x) n <- length(x) s <- sort(x) ifelse(n%%2==1, s[(n+1)/2], mean(s[n/2+0:1]))…
-
2
votes1
answer177
viewsError in the application of the Boxcox function of the MASS package
I’m getting the following error while using the function boxcox() package MASS: Error in as.data.frame.default(data, optional = TRUE) : cannot coerce class ‘"function"’ to a data.frame I don’t…
-
2
votes1
answer1112
viewsHow to calculate MODA with bimodal value in a date.frame in R?
I need to calculate the MODA of online values in a data.frame. As in R there is no function already set for FASHION, I used a custom function: moda = function(x) { z = table(as.vector(x)) names(z)[z…
-
2
votes3
answers54
viewsReplacing NA values of a column by the value of the top row of the same column of a dataframe
I have the data frame below, and I want to create a script to replace the NA by the value of the top row of the same column. DADOS <- data.frame( a = c(1, 2, NA, 3, 4), b = c(5, 6, 7, NA, NA) )…
rasked 3 years, 5 months ago Peterson Ribeiro 37 -
2
votes1
answer27
viewsChange/ abbreviate words from a data set
Is there a function in the R that can change one or more words in my dataset? Example, change the word São Paulo for SP.
-
2
votes1
answer40
viewsApply function, extract regression data
I have the following sample: x <- structure(list(POP = structure(c(1L, 12L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L, 14L), .Label = c("pop1", "pop10",…
-
2
votes1
answer140
viewsHow to turn my data.frame variable values into columns in R?
Suppose I have the following date.: print(DADOS) CODIGO QTDE MÊS 001 4 1 001 1 1 001 3 2 001 2 3 001 3 3 001 4 3 001 2 4 001 2 4 001 1 5 001 5 6 001 2 6 But I need to turn the values of the variable…
rasked 5 years, 5 months ago Izak Mandrak 1,059 -
2
votes1
answer36
viewsGraph ggplot R prints x-axis variables in non-cohesive charts when using facet_grid()
asia %>% filter(region %in% c("Western Asia and Middle East","Central Asia","East Asia")) %>% group_by(Country) %>% ggplot(aes(x = Country, y = FertRate, col = Country)) + geom_point() +…
-
2
votes1
answer95
viewsFitdist problems in beta distribution
I am using fitdist to estimate the parameters of the beta distribution and adjust them to a data set as follows as it presents the codes. I would like to understand why it is not adjusting to the…
-
2
votes1
answer532
viewsProblems to generate pdf file and equations in the file via R Markdown
I am trying to run the following function via R Markdown, seeking to generate a pdf, and with equations using Latex I already installed all the necessary packages, so with Miktex 2.9 full version…
-
2
votes1
answer208
viewsHow to Find Higher or Lower Values between Columns within a Data Frame in R
I have a data frame x, and in the column of the name V_de_Busca, where the value is greater than 0, I need to search the column V_Encontrado and locate the first value larger than the one searched…
-
2
votes2
answers140
viewsDelete lines with a specific string
I would like to delete all lines that show "-" in the column "Shop area", how do I delete? Below follows the result of the command dput(censo) of my data frame: structure(list(Unidade.da.Federação =…
rasked 5 years, 4 months ago Ingled M Cardoso 159 -
2
votes0
answers61
viewsFunction highcharter::hciconarray does not produce the icons on the chart
The code below is in the documentation of package highcharter to the topic hciconarray: library(highcharter) library(tidyverse) hciconarray(c("car", "truck", "plane"), c(75, 30, 20), icons =…
-
2
votes1
answer89
viewsRemoving lines from a problematic database in R
A few days ago I asked a question in the stack, according to link. The reply I received from prof. @Marcus Nunes shows that less than 10% of lines have more than 15 tabs of the type ;. In that case,…
-
2
votes1
answer39
viewsUse lapply inside loop for?
I would like to generate nBS reamostras for each of the N column vectors of size n of my matrix, and then return something like a list. I got something similar to the one desired with the following…
rasked 5 years, 4 months ago user156522 23 -
2
votes1
answer121
viewsHow to plot two geom_line (one from each group) into a single Plot in ggplot2
I have 2 dfs (one from each group) that correspond to 76 channels of signal acquisition in 20sec. of analysis. To decrease the work of repeating several times (76x) the geom_line function I stacked…
-
2
votes2
answers200
viewsHow to modify only the line of the legend that identifies the group?
How can I change only the thickness of the color lines in the caption that identify the groups? I do not send the dput() graph pq are more than 40 thousand lines. I send a cutout of the figure to…
-
2
votes2
answers190
viewsHow to insert lines in the graphs to denote post-hoc differences between compared groups?
I need to graphically identify post-hoc differences between mean comparisons. As the figure below: Send a dput with simple data to facilitate graph generation (not the figure), as well as the chart…
-
2
votes1
answer495
viewsHow to adjust the size of an already embedded geom_plot to another ggplot2 chart?
In this situation below, how can I adjust the size of the geom_plot() added to geom_jitter() once the function tibble(x = 12, y = 4.5, plot = list(dens_iris)) only allowed to identify the…
-
2
votes1
answer380
viewscreate PDF dynamically in Rmarkdown
Good afternoon. For a week I’ve been trying to do a magic at Rmarkdown but I can’t. Well, come on. Contextualizing: I need to write different Pdfs (or html) with different contents. In this case,…
-
2
votes1
answer66
viewsStandard error bars do not appear in R graph
I have a question in the R, and I believe I’m missing some very simple detail. In short, I would like to understand the effect of photosynthesis on a given species over the days, considering the…
-
2
votes1
answer203
viewsChange time series chart scale
I’m doing a chart of an 84-month time series, but I wanted to change the scale of the x-axis for every 6 months to facilitate interpretation, but I cannot. notif <- ts(not) plot(notif, col=2,…
rasked 5 years, 2 months ago daasferreira 21 -
2
votes1
answer114
viewsProblem with Recommendation System in R
I’m trying to develop a recommendation system using the R language. Basically, the system is music recommendation collecting information from a file where there is a certain amount of users and for…
-
2
votes1
answer55
viewsCreate new column in the partial match-based dataframe of the string without repeats
I have a dataframe with two columns, being them GL GLDESC and wanted to add a third column called KIND based on column data GLDESC. Dataframe: GL GLDESC 1 515100 Payroll-ISL 2 515900 Payroll-ICA 3…
-
2
votes1
answer62
viewsError: Discrete value supplied to Continuous Scale (error function to position "n" in graph)
I’m crowding a few boxplots to compare, year by year, the grades of students periodized and not periodized. I am using the function below to plot these graphs. Within the function stat_summary I’m…