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
-
4
votes1
answer97
viewsGgplot of a Data.frame in separate graphs
I have that date.frame: > df ind m X1 X2 1 2015-12-21 21 0.1431529 0.1426365 2 2015-12-21 42 0.1403679 0.1443714 3 2015-12-21 63 0.1467133 0.1466899 4 2015-12-21 84 0.1513388 0.1485589 5…
-
4
votes2
answers22615
viewsUpdate the R version of Rstudio?
The version of the R I have installed is outdated. What is the procedure to update the R considering that I use Rstudio in Windows?
-
4
votes2
answers1104
viewsShow an object/variable with different names in R?
Considering the following routine: x <- 1:10 for (i in 1:length(x)) { ## Nome da variável: nomevar <- paste0("Var_", i) var <- x[i] + 2 assign(nomevar, var) print(nomevar) # aqui esta minha…
-
4
votes2
answers999
viewsHow to read data with variables in lines, in Rstudio?
I am starting with the R language in Rstudio. I am an advanced MATLAB user but with difficulties in R. My question is: I have a spreadsheet where each row is a variable and each column is an…
-
4
votes1
answer1126
viewsFilling out data.frame from another date.frame
I have two data.frames: "a" and "df" a <- data.frame(x=seq(13,37,1),rep(c(1,2,3,4,5),each=5),seq(21,105,21)) colnames(a)<-c("values","date","term") b<-data.frame(x,21,42,63,84,105)…
-
4
votes3
answers1099
viewsHow to divide the elements of a matrix by the average of its column
I need to divide the elements of a matrix by the respective average of its column, as I can do this, there is some function to perform this simple operation? Considering the matrix: > A <-…
-
4
votes0
answers115
viewsRead in blocks do not advance with read.csv. How to fix?
I am trying to make the following code to read a giant file that does not fit the memory. library(dplyr) arq_grande <- file("dados2014.csv", "r") tam_chunk <- 1e2 df1 <-…
rasked 8 years, 9 months ago André Oliveira 376 -
4
votes2
answers1031
viewsHow to extract a specific string snippet
Let’s have this URL extracted /ac/rio-branco/xpto-xyz-1-0-16-5-abcd-a1G57000003DE4QEAW And I just want the piece that starts with a1G, someone knows how I only get this bit?…
-
4
votes1
answer167
viewsHow to show the axes of a histogram with their respective classes in R?
I plot a histogram of the weight variable in my datasheet but it appears without the axes. The code I used was: hist(rehab.1$PESO, main = "", axes = F, xlab = "Peso(kg)", ylab = "frequências…
-
4
votes1
answer103
viewsHow to delimit the number of characters written per line in a "txt" output in R?
I’m writing a filelog and I want to print it on an A4 sheet. One of the parts of this filelog has a variable, with the following structure:…
-
4
votes1
answer107
viewsbRasilLegis - XML content does not Seem to be XML
I’m trying to lower the votes of Members to the propositions in votes held in the Plenary of the House of Representatives, in 2015, through the package bRasilLegis in R. But when I put the…
-
4
votes1
answer141
viewsOverlay words on the R software graph
Hello, I made a chart in R, but the words were overlaid, I would like help to fix it. Follow the chart to see how it looked. Hug.…
-
4
votes2
answers305
viewsTurn positive values into negative values in a data.frame based on one condition in another column (R)
I have the following date. :: df <- data.frame(Qtd=c(100,200,300,400,500), op=c('V','C','C','V','V'), stringsAsFactors=F) How I can turn the values in the Qtd column to negative if the op column…
-
4
votes1
answer723
viewsApply a function using some columns of all rows of a Dataframe (r)
I have the following Dataframe : AVG_VOLUME AVG_RETURN VOL PRICE SPX Index 500000 0.01 0.08 2082 KR7000270009 6000 0.02 0.09 102 KR7005930003 7000 0.02 0.08 103 JP3266400005 8000 0.03 0.08 104…
-
4
votes1
answer760
viewsHow to sort boxplots by average or median on R
How to order a series of boxplots by median or average? The command used: boxplot(base$y~base$FID) sorts charts by order of the base variable$FID, I would need the sort to be done by the average or…
rasked 8 years, 6 months ago Henrique Pizarro 659 -
4
votes1
answer5243
viewsHow to apply filters to a data.frame?
I have a database in Excel with 12135 data and not all fields are filled and some individuals have negative age and others are older than 17 years and others older than 70 years. I need to know…
rasked 8 years, 7 months ago Evandro Lopes 41 -
4
votes1
answer3996
viewsGet the module of a negative number in R
Is there any function in R to obtain the module of a negative number or a number vector? example: v <- c(1,-2,3,-4) module(v) #> [1] 1 2 3 4…
rasked 8 years, 5 months ago rafa.pereira 273 -
4
votes1
answer460
viewsHow to check if a polygon is regular or convex
Is there a function in R that checks whether a polygon is regular or not and some that checks whether it is convex or not? If either answer is no, any idea? As I thought: #Por exemplo um…
-
4
votes2
answers78
viewsFunctions with a number of "dynamic" arguments
want to construct a function that can have the number of variable parameters, as the function c, and how to access their addresses, for example: c(a = 1, b = 2, d = 9) #acessar a, b e d Has…
rasked 8 years, 5 months ago Wagner Jorge 1,377 -
4
votes1
answer270
viewsA: Insert date difference in a time difference function
I found a function made by J.Ahumada and found it super interesting, everything to do with my work. The function is to separate photographic records of a species into a given sample unit(ua) from a…
-
4
votes1
answer1572
viewsHow to chart profiles in R?
I’m trying to create a profile chart for this data frame that I titled "Femi": This is the data code: structure(list(oito = c(21, 21, 20.5, 23.5, 21.5, 20, 21.5, 23, 20, 16.5, 24.5), dez = c(20,…
rasked 8 years, 6 months ago Cloves Paiva 369 -
4
votes0
answers85
viewsInstall patch pro R
As documented here, R’s iconv function does not work satisfactorily. Fortunately, a patch has been developed that solves the problem (apparently). My question is basic: how do I install the patch?…
-
4
votes1
answer158
viewsHow to extract every umpteenth element from a list?
Considering a list composed of several vectors: lista<-list(c("1949", "1963", "45", "X2752009", "X2752013", "X2753007", "X2850009", "X2851005", "X2851008", "X2851014", "X2852002", "X2852003",…
-
4
votes1
answer271
viewsQuadratic Curve Estimating Minimum Square using R
I have a quadratic model that I want to run a simple multivariate regression using Minimal Ordinary Squares. This is my code: df<-data.frame(rnorm(50),rnorm(50)) x_Square<-df[,2]^2…
-
4
votes1
answer131
viewsHow to fit a Lowess curve into longitudinal data using R?
I have the following data: structure(list(X26 = c(1.69, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), X27 = c(0.94, NA, NA, NA, NA,…
-
4
votes1
answer37
viewsProblem endpoint function R
I’m working with this date.frame: St <- data.frame(read.csv2("interest_LastMonthDay.csv")) Date AAA_S.t. Date.1 BBB_S.t. Date.2 CCC_S.t. 1 27/12/88 1,80400 28/12/88 0,8368 28/12/88 0,0080 2…
-
4
votes1
answer66
viewsWhy does rvest break when processing an empty file?
When trying to process the contents of an empty file the package rvest locks and closes the RStudio. Follows small reproduction of the problem: tf <- tempfile() file.create(tf) html_erro <-…
-
4
votes1
answer164
viewsProblems with interpreter R
I did the installation of R4intellji and selected a program in R. However when I ask to run (run) the program gives the following error: The R interpreter is not specified Could someone help me?…
-
4
votes1
answer713
viewsLogistic regression with non-binary variable
I need to do a classifier with logistic regression to classify this categorical variable that can have 14 different values. Does anyone know if it is possible to do this with glm() or if I have to…
rasked 7 years, 10 months ago Carolina Bury 109 -
4
votes1
answer625
viewsGraph of columns of a Data Frame using GGPLOT
I have that date.frame: A K1 B K2 C K3 D K4 E K5 1 0.89386498 0.239258200 -0.004970278 0.99477685 -0.243845617 0.80370370 0.3132989 0.637155451 -0.55467576 0.049341476 2 0.35422172 0.681622485…
-
4
votes2
answers158
viewsError using package plm - Error in x[, ! na.check] : (subscript) Logical subscript Too long
I am using the plm package to perform analysis in a panel. To structure the base as a panel, I used the function pdata.frame of the same package. With this, I had as return a panel with the…
rasked 8 years, 3 months ago Otto Tavares 43 -
4
votes1
answer215
viewsError when trying to extract table from a site by R, how to resolve?
I’m using this code, I want to import the country table to the R: library(XML) url <- "http://en.wikipedia.org/wiki/List_of_countries_by_population" country_data <- readHTMLTable(url, which=2)…
-
4
votes1
answer1316
viewsJoin 3 graphs using Plot
I want to join the three graphs below using the function plot. I do the basics starting with the command par(mfrow=c(1,3)) but I can’t get them together. The problem I believe is the fact that I’m…
-
4
votes1
answer154
viewsInteger overflow in R
I’m working on a population dynamics simulation that involves generating whole numbers. Due to the hypotheses of my model, I am generating random numbers through the function rmultinom R. However, I…
rasked 8 years, 2 months ago Marcus Nunes 17,915 -
4
votes1
answer122
viewshttps (webservice) requisition from the São Paulo Public Treasury
I’m trying to make a request https the Webservice of the São Paulo Public Treasury, but I don’t know where I’m going wrong. This is the address: http://www.fazenda.sp.gov.br/contas/webservice.shtm…
-
4
votes1
answer279
viewsBuild Accumulated Density Probability using R
I have this two-column date frame (Y and X) With the package quantreg I can estimate the amounts of Y given x. Done this I’m not managing to build the CUMULATIVE Y conditional density function.…
-
4
votes2
answers751
viewsError reading file: Error in scan line 6 Did not have 63 Elements
I’m a beginner in R and I can’t read the file I’m working with. tab1<-read.table("savedrecs.txt", header=T, sep="\t") Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,…
rasked 7 years, 7 months ago Giovanni Laranjo 41 -
4
votes2
answers186
viewsHow can I transform a variable(0-10) into 3 categories?
The GLEASON variable in the database is 0 to 10. And I wanted to turn this variable into three categories, for example: 0-4: not aggressive, 5-7: aggressive intermediate and 8-10: very aggressive.…
rasked 7 years, 7 months ago Maria Lopes 115 -
4
votes1
answer1695
viewsCalculating T-Student Probabilities in R
I have the mean and standard deviation of my distribution: mean = -0.49 ; sd=3.029041 How do I calculate the probability of y a standard deviation below the average using the T-Student with 85…
-
4
votes1
answer1324
viewsConvert numeric date to R
I imported a JSON table for R and the dates are in Unix format. Example: data <- c(1436904192, 1490717463, 1491924165) How can I convert this entire column at once to the date format 14/7/15…
-
4
votes1
answer89
viewsSelect data from df according to data from a list
Dear(as) as given below: nr <- c(100:199) dt <- rep("data",100) x <- data.frame(nr,dt) y <- c(110:115) I need to get,the common numbers between the first column of the date.frame x and…
-
4
votes1
answer4378
viewsHow to delete repeated values in a text column in R?
I have a data.frame that has a column with names, but these names repeat a few times. I need to create a new column in a new data.frame with all names, but no repetitions.
rasked 7 years, 5 months ago Filipe Vargas 95 -
4
votes2
answers62
viewsMerge two series (zoo) of the same variable making the intersection and filling
I have two zoo series like this: to: data valor 01-02-2010 2 01-03-2010 0 01-04-2010 9 b: data valor 01-06-2010 3 01-07-2010 6 01-08-2010 2 I wish a set c this way: c: data valor 01-02-2010 2…
rasked 7 years, 5 months ago Artur_Indio 1,093 -
4
votes1
answer60
viewsPlot Main Title with Text and formula y = a + betaX + Epsilon
This is the data: a=structure(c(2.96898844129164, 2.7849952585919, 2.4022019576164, 2.97749332978932, 3.23431466394159, 3.37620019711505, 3.3295390792587, 3.11646532271242, 2.84000702738219,…
-
4
votes2
answers1947
viewsJoin multiple files from a folder in R
I’m trying to piece together several xlsx files in R. For this, first I open the following libraries and use the programming: library(readxl) library(plyr)…
-
4
votes1
answer2932
viewsCalculate covariance matrix in R
Given a matrix whose elements are values of a given attribute in n positions in space. How to calculate the covariance matrix (nxn) of the values of this attribute at the given positions?
-
4
votes1
answer650
viewsInteraction graph in ggplot2
I’m trying to adapt some standard R graphics to the style of ggplot2. One of the graphs for which I intend to do this is the interaction graph in a linear model adjustment study. The following data…
-
4
votes2
answers291
viewsSelecting part of a data frame and saving in loop
I have a date frame of more than 1000 rows and two columns (col1 and col2). How do I select n data frames (subsets of the original data frame) based on column 2 (only the same elements) by means of…
-
4
votes1
answer186
viewsSchedule automatic updates on R
I have an algorithm on designed in R that retrieves data from a database, does some statistical calculations and produces a Dashboard with kpis and graphs generated from these calculations. But…
rasked 7 years, 4 months ago Bruno Rigueti 305 -
4
votes2
answers12366
viewsHow to sum the values of selected columns of each observation (row) in R?
I have a database with 10,000 observations (individuals/lines). I want to add the values of three variables (columns) for each individual (row). Ex.: x1 x2 x3 x4 x5 x6 1 0 1 0 40 45 76 2 1 1 0 31 86…