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
votes0
answers436
viewssubtraction in Diff R software
my level in R is beginner in case you can help me with a problem I will be grateful. I have a mathematical function that generates me a vector, and I have to subtract between the value of the second…
-
1
votes1
answer2309
viewshow to turn a factor variable into a numeric in R?
Good morning I am importing a txt format database and the values comes in factor but I want in Numeric. How do I?
-
1
votes1
answer63
viewsConcatenating column when should only read an input
I’m using the following code: library(data.table) setwd("/home/andre/monografia/") ; getwd() obj = read.csv(file = "Grup1C0.csv"); tes = obj[4,4] View(tes) The road that is in position [4,4] of the…
rasked 8 years, 8 months ago André Oliveira 376 -
1
votes1
answer2018
viewsHow to transform numeric variables into strings in R (0=NO and 1=YES)?
1I have a datasheet where 0=No and 1=Yes. When I try to create a table of this variable appears the following: ] How do I make the function prop.table a the pie function of the pie chart recognize…
-
1
votes1
answer79
viewsGeometric figure with data in R
I have 3 points and I would like to form a triangle with them, then overlap another triangle with 3 new points and so on. I tried that, but I can’t make the triangle and the boundaries of the…
-
1
votes1
answer469
viewsOverlay graphics with ggplot2?
I am learning to use ggplot2 and would like to make a chart and then overlay a point on it. For example: set.seed(1) a = data.frame(X1 = rnorm(3), X2 = rnorm(3)) g <- ggplot(a, aes(x = X1, y =…
-
1
votes1
answer437
viewsScoring, Hessian and Newton Raphson function of the exponential distribution in R
How to find the score vector and the Hessian matrix in R to apply the Newton Raphson in the code below: rm(list=ls()) cat("\014") #Função para simular variáveis aleatórias de uma modelo de regressão…
-
1
votes1
answer48
viewsCreate a package that depends on other packages
Staff I am creating a package with some functions one of them depends on another package, as "gives the signal" for R understand and install this package? The package I depend on is raster. a =…
-
1
votes1
answer367
viewsFit models for meta-regression calculation in R Studio
I started using R Studio a short time ago to do a meta-regression analysis using package Mada. I need to create a model fit for each variable and after creating 6 models fit the R started giving an…
-
1
votes1
answer73
viewsNesting error
I need to make a graph in the concatenated R, are 4177 iterations, I’m using ggplot2, but is giving the error below: Error: evaluation nested too deeply: infinite recursion / options(expressions=)?…
-
1
votes1
answer38
viewsTransform class within package
Guys I have a matrix and I want to turn it into another specific class of a package, rgeos, place the @import in the package, give library in it too, but when I check it gives error that mistake. a…
-
1
votes1
answer36
viewsAccess objects of the formula class
How do I access a formula objects separately? For example: e <- new.env() a <- list() b <- list() a[[1]] <- matrix(rnorm(20), 2) b[[1]] <- matrix(rnorm(20), 2) e$a <- a e$b <- b…
rasked 8 years, 4 months ago Wagner Jorge 1,377 -
1
votes1
answer110
viewsParameter estimation using the Optim function
I’m having a problem estimating parameters when using the code below: N=1000 m=matrix(ncol=5,nrow=N) mu1=1.2 mu2=1.5 phi1=1 phi2=2 rho=0.5 n=100 truevalue=c(mu1,mu2,phi1,phi2,rho) for (i in 1:N){…
-
1
votes1
answer4792
viewsHow to delete any line from a data frame in R?
I have a data frame as follows: how do I remove the first line?…
rasked 8 years, 4 months ago Fernando Duarte Junior 19 -
1
votes1
answer87
viewsError in output of Optim when creating a regression structure
By running the simulation below I get the error at the end of the code, someone can help me to solve it? #Valores iniciais dos parâmetros usados para gerar t #Ou seja, Valor verdadeiro dos…
-
1
votes1
answer179
viewsProblem loading winbugs into R
I’m trying to run a code on the R that loads the package winbugs that I have already installed require(R2WinBUGS); but I’m making this mistake Read 180 items Error in file(con, "rb") : cannot open…
-
1
votes2
answers94
viewsOrganize Results Kalman Filter in a Matrix
simple question: With the code below I estimate Kalman Filter with an AR component(1). The goal is to exit the vector k_fk. When I have only one vector it is simple. But I need to run the same code…
-
1
votes1
answer55
viewsProlema with R Studio layout
I just installed R Studio and it is not the same I see in all tutorials on the internet with four windows. Instead it is like this: Someone knows how to fix?…
rasked 8 years, 1 month ago Carolina Bury 109 -
1
votes1
answer99
viewsHow to combine two dataframes in the correct order using R
df <- read.csv('train.csv') train1 <- train[train$variavel3 == 1] train2 <- train[train$variavel3 == 0] fit1 <- rpart(variavel1~variavel2) fit2 <- rpart(variavel1~variavel2) dftest…
rasked 8 years ago Pedro Teixeira 63 -
1
votes1
answer110
viewsProblem running application in R
While Trying to Run the Script Below: Area="C:\Users\user\Desktop\shape.shp" Pasta="" library(raster) library(rgdal) library(rgeos) library(maptools) long2UTM <- function(long) {(floor((long +…
-
1
votes1
answer91
viewsIncluding Trust Interval in a Row of a Matrix
I want to create an array of 38 rows and two columns with coefficients on odd lines and confidence intervals for parameters on even lines. Then call the Stargazer. My code is: library(quantreg) y…
-
1
votes3
answers105
viewsChanging charts of a regression
I’m trying to modify the chart of the Tables of this regression that I’ve been around: x c(-0.0179316822180174, -0.00641604898349779, 0.0118829440361971, -0.00821159118344772, -0.0171607214317729,…
-
1
votes2
answers667
viewsHow to save a series of xls spreadsheets in csv using R?
I have 198 spreadsheets all in Excel (xls format) and I need to pass them to the format . csv so you can work with them in R. These sheets are saved inside a folder on my computer all of them in…
-
1
votes0
answers66
viewsHow do I select imported data in R?
I need to analyze my data with PCA on R (version 3.3.2), and the tutorial I have from an older version does not seem to apply. I imported the data in .xlsx and according to what I know, I need to…
-
1
votes1
answer222
viewsImprove performance for predictive model creation
I am creating a predictive model in R, using the library Caret. When I run on R it takes a long time, and still gives some errors. In comparison, I run the same base on Weka in a matter of a few…
-
1
votes1
answer168
viewsError in function Optim
I am trying to maximize the likelihood of logistic distribution with a regression structure. The code is: cov1 <- rep(1,115) cov2 <- rnorm(115,0,1) e <- rlogis(115, 0,1) yy <- 1*cov1 +…
-
1
votes1
answer1431
viewsHow to stratify/divide a data.frame into categories of a variable in R?
I am running a linear regression model on R and would like to perform stratified analysis according to categories of a variável X with 4 categories (X1, X2, X3 and X4). I thought I’d stratify the…
-
1
votes0
answers170
viewsWeb scraping with R 2
I wish I could create a role in R to capture the information from this site http://www.fns.saude.gov.br/visao/consulta/simplificada/filtro.jsf being that it passes me this consolidated information…
rasked 7 years, 8 months ago Luis Claudio 11 -
1
votes1
answer42
viewsChanging list by reference in R
I have the following problem. I have 5 graphs (per hour, it won’t matter the structure of each graph, only that I have 5 graphs) and put them inside a list in R. I will make changes to these graphs…
-
1
votes1
answer72
viewsSentences in a Loop on R
I’m trying to make a very simple "for", but it doesn’t come out: This is my data: data=structure(c(NA, NA, NA, 0.364282642384808, -3.01119851776463, -8.66579826331935, -3.65240790618631,…
-
1
votes1
answer54
viewsHow to send data from data frames in optimized R code questions?
Edited - As pointed out in Marcos Moraes' comment, I tried to reinvent the wheel of a resource available in the base layer of R, since dput is able to produce the same effect. Fault ours. : ( The…
-
1
votes1
answer287
viewsHow to create a variable by averaging another variable from the same dataset?
Imagine I have the following basis: Country <- c("Brazil", "Brazil", "Brazil", "Brazil", "Brazil","Brazil", "Argentina", "Argentina", "Argentina", "Argentina", "Argentina", "Argentina") Year…
-
1
votes2
answers5601
viewsHow to calculate the average of a column in Rstudio but ignore the 0 values in the column?
example column 1 = 1 2 3 4 0 0 0 the normal average of this would give 1.428571 but ignoring the 0 would be 2.5, I would like to know how to do this, ignoring the values 0 of the column.
-
1
votes2
answers534
viewsHow to plot multiple charts on several different pages using ggplot
I have the following data frame (df): Subject Period Treatment Time Concentration 1 1 1 A -1.000 0.000 2 1 1 A -0.500 0.000 3 1 1 A -0.250 0.000 4 1 1 A 0.000 0.000 5 1 1 A 0.167 1.147 6 1 1 A 0.333…
-
1
votes1
answer308
viewsHow to turn my data.frame into a time series?
My data frame is this: IPCA.X04.05.2017 IPCA.Beta.1 IPCA.Beta.2 IPCA.Beta.3 IPCA.Beta.4 IPCA.Lambda.1 IPCA.Lambda.2 2 IPCA 0,0526 0,0442 -0,1269 0,0524 1,3477 0,7203 My goal is to create a large…
rasked 7 years, 6 months ago Danilo Imbimbo 533 -
1
votes0
answers122
viewsChart correlations (round)
How to create a graph (round Graph in Ellipse) of correlations between 20 characters when I already have the correlation table ready and do not need to calculate the correlation in R?
rasked 7 years, 6 months ago Rosângela M. Simeão 11 -
1
votes0
answers186
viewsHelp with using the igraph and timeorded library in R
I’m using the lib 'igraph' and 'timeorded' (http://www.benjaminblonder.org/timeorderednetworks/) to work with time graphs. I have the following time graph: "graph.txt": a c 1 1 a d 2 2 b d 2 2 c d 3…
-
1
votes1
answer60
viewsGEE on R-someone can explain to me the SFV code
model0 <- glm(stable ~ Sex+Age+Height+Weight+Surface+Vision,binomial,ctsib) summary(model) model1 <- glm(stable ~ Sex+Age+Height+Weight+Surface+Vision+factor(Subject),binomial,ctsib)…
rasked 7 years, 6 months ago Maria Lopes 115 -
1
votes0
answers62
viewsget.shortest.paths in time graph
I’m using the "igraph" library and I’m working with dynamic graphs. I have the following graph: VertexFrom VertexTo TimeStart TimeStop to c 1 1 a d 2 2 b d 2 2 c d 3 3 d b 3 That is, v1 is connected…
-
1
votes1
answer466
viewsLabel does not appear on the chart
Hello, My configuration is as follows:: > sessionInfo() R version 3.3.1 (2016-06-21) Platform: x86_64-W64-mingw32/x64 (64-bit) locale: _LC_COLLATE=Portuguese_Brazil.1252_,…
-
1
votes1
answer252
viewsHow to make the graph start on the y-axis by ggplot?
Hello, I’m trying to get the chart below to start on axis y, but I’m not getting it. The idea is to bring the first value of the x-axis, the time 6h, to the value 0 of the y-axis. Below follows the…
-
1
votes1
answer159
viewsCreate an exploratory chart type weight~collection by filtering treatments in R
With the tapply function I can know their values: tapply(peso, list(coleta, tratamento), mean, na.rm=T) tapply(peso, list(coleta, tratamento), sd, na.rm=T) sd Biofloc Control A1 NA NA A2 20.69427…
-
1
votes1
answer57
viewsR function returns wrong value
the Log.Lik function below returns the value -INFwhen should return the value -5836.219. I can’t figure out the mistake, anyone has any suggestions? rm(list=ls()) library(ssmrob) data(MEPS2001)…
-
1
votes2
answers1479
viewsAdd factors from a data frame?
I have the following df: Factor Valor F1 1.224 F1 1.533 F1 0,77429 F2 3.477 F2 2.6767 F3 0.557 F3 1 How do I get the total values?…
-
1
votes1
answer597
viewsReplace matrix value (R)
I need to replace the value that appears on the main diagonal of my matrix with another, how to proceed?
-
1
votes1
answer261
viewsHow to use the tablaStack function in R
Good evening my Biostatistics teacher is teaching to use R, he passed the following question (Construct frequency tables of RACE, MARITAL STATUS and SCHOOLING. Identify which categories of these…
-
1
votes1
answer124
viewsPlot of the degree distribution of a graph in R
I have a graph and I want to plot the degree distribution. Example: > library(igraph) > g <- make_ring(10) > degree(g) [1] 2 2 2 2 2 2 2 2 2 2 > g2 <- sample_gnp(1000, 10/1000)…
-
1
votes0
answers47
viewsError rpy2.robjects in Ubuntu - Lookuperror: 'show' not found
I just can’t test python functions with R. In my notebook jupyter I did: !Pip install rpy2 And when having imported the robjects gives error: import rpy2.robjects as ro;
-
1
votes1
answer65
viewsRead a typed number (R)
Good morning everyone, I need to do a barbadinha script in R where I have to read a typed number and give his predecessor (like, if I write 10 the predecessor is 9). But I have a problem that I…
rasked 7 years, 2 months ago Carlos Winter 39 -
1
votes0
answers63
viewsInternal server error, can anyone fix?
I set up a code to log into a website and download a spreadsheet, however, the connection has been closed, someone can help me? library(RCurl) curl = getCurlHandle() curlSetOpt(verbose = T,…