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
answers75
viewsError with NULL values in a data frame R
Hello, I am working on building a data frame in R from a JSON that I receive after doing a GET on a service, but I am getting an error because one of the return JSON values is null, it follows part…
-
1
votes3
answers95
viewsRemove data frame row with string divided into multiple columns
I have several files with data stored in text of fixed width. All files have a header with information about the data entity and a last line in FINALIZER format########## Where…
rasked 4 years, 4 months ago Everton da Rosa 755 -
1
votes1
answer49
viewsExtract attributes from a dataframe using the points of a second dataframe
Greetings. I’m trying to extract information from biomes from a dataframe (biomes_df), which has columns of temperature and precipitation. I want to use these values to extract which biomes the…
-
1
votes2
answers64
viewsstr_replace_all - how to find words by the first 3 letters of a string?
I have the following structure: library(stringr) filtro_palavras <- structure(list(palavras = c("cultivo", "produtos", "atacadista", "papel", "madeira", "água", "agrícola", "vestuário",…
-
1
votes0
answers102
viewsRound geographical coordinates for classes with intervals of 0.5° latitude/longitude
I have the following data.frame with the occurrence coordinates of a species: df <- data.frame( especie = c("sp1", "sp2", "sp3"), longitude = c(-48.97376, -36.08333, -41.66931), latitude =…
-
1
votes0
answers17
viewsConvert CODA object to CSV
I’m using "Hierarchical Modelling of Species Communities (HMSC)", and I used the "convertToCodaObject" command to view the model’s empirical information (e.g., mean and sd). However, I’m having…
-
1
votes0
answers58
viewsHow to automate creating excel spreadsheets in R
Good morning, I find myself in a problem, that although it seems very simple to solve, I can not find a solution without manually making the creation of all, so let’s go: library(stringr)…
-
1
votes1
answer94
viewsWhat’s a good accuracy?
Hello, I’m a young student and I’ve been working alone on a project. The project involves car sales (analyzing the amount of cars sold) from Norway from 2007 to 2016. I wanted to try to create a…
-
1
votes2
answers126
viewsGeom_area with different filling colors
I have a DF with 4 columns: data, original, previsto and change. The variable change indicates whether the values of the series original are positive or negative, to plot on the chart in green and…
-
1
votes0
answers249
viewsI cannot use Packages after upgrading to R 4.0.2
Yesterday I updated the R version and used it normal $version.string [1] "R version 4.0.2 (2020-06-22)" This morning, when I went to use, messages appeared that the packages needed to be…
-
1
votes1
answer36
viewsThe "date" format disappears after using the "group_by" function followed by "summarise (Mean())" in R
I am working with the following global temperature database: https://drive.google.com/open?id=1nSwP3Y0V7gncbnG_DccNhrTRxmUNqMqa I import the data with the function import() package rio and engrave…
-
1
votes2
answers57
viewsIs there a "dd-mmm-yyyy" format (e.g., "13-feb-1980") in the R?
I wonder if there is the format "yyyy-MES ABBREVIATED-dd" Example: library(tidyverse) library(lubridate) df<-data.frame(dt=c("1980-02-13", "1983-08-03")) df dt 1 1980-02-13 2 1983-08-03 I can put…
-
1
votes0
answers31
viewsInsertion of line and R 2 equation in a ggplot graph
I would like to know (1) how to obtain the straight line equation and (2) how to insert the line equation and R 2 in my graph generated by ggplot. Researching here, I found similar doubts, but by my…
-
1
votes2
answers24
viewsHow do I return to "double" from the original df?
When I convert df from "factor" to "Numeric" the values become integers. How do I return to "double" from the original df? df <- read.csv2(file.choose()) View(df) str(df) df1 <-…
-
1
votes1
answer49
viewsProblems Adjusting Linear Regression in Stan
I’m having trouble adjusting a linear regression model in Stan. When observing the error message, note the identification in the part of the transformed parameters block. See below the structure of…
-
1
votes4
answers150
viewsCalculate percentage of an item in a group per year in R
I have a DF 14-column: item, grupo and years 2010 to 2021. I need to know the percentage of each item within the grupo to which he belongs. I tried to use a group_by with the summarise, but since I…
-
1
votes1
answer42
viewsIs it possible to multiply a variable of type "factor"?
I’m working with the following database: Qualis. I import this database using the rio::import() and write to the object "df". And I load library(dplyr) Upshot: library(dplyr)…
-
1
votes1
answer45
viewsHalf of boxplot appearing in ggplot2 function
I’m doing a boxplot using ggplot2 package, however, for some external reason, only half of the boxplot is being made for the "Control" and "Commercial IMD" treatments". See below that when doing the…
-
1
votes1
answer64
viewsRegex for numbers of different sizes
I need to read an image . png with a financial handling table, like the one below: From this table I need to extract the columns gross balance, availabilities, Application/Redemption and Final Gross…
-
1
votes1
answer138
viewsCombine with grid.arrange two residue charts (lme vs. lm)
I’m trying to put in the same image, side by side, the residue graphs adjusted by the linear model and the mixed linear model. However, I consulted the following links below and still my error…
-
1
votes0
answers24
viewsProblem with plotweb R - interaction networks
I need to structure in R a network of interactions, but every time I want to plot the graph, this error appears: # 3. Leitura da rede quantitativa read.delim("C:/Users/almei/Dropbox/Thays/TCC/matriz…
-
1
votes1
answer71
viewsHow to combine multiple R-Markdown (.rmd) files into a single document?
In a project on R, I have several files .Rmd in the same folder. As in the example below: Capitulo1.Rmd --- title: "Capítulo 1" output: pdf_document --- # Esse é o capítulo 1. ```{r} plot(cars) ```…
-
1
votes2
answers108
viewsAutomate column subtraction in R
I have a table in the R of people, countries and days. I need to subtract the amount of people from the previous day from the current day column for all columns, someone can help me? I need to make…
rasked 3 years, 12 months ago Marco Sposaro 33 -
1
votes0
answers16
viewsHow to adjust for the baseline variable on a basis for mixed models?
My doubt consists in the realization of a Mixed models where I was asked to adjust to the variable baseline I then have the variable weight in 3 moments (baseline, 4mo and 12mo) in 94 individuals.…
rasked 3 years, 11 months ago Catarina Nunes 11 -
1
votes2
answers51
viewsHow to manipulate two data sets at the same time?
I would like to learn how to manipulate two variables at the same time. An example, I have a training base and a test base for Machine Learning. How could I apply the function Factor both at the…
-
1
votes1
answer69
viewsCompare the information of two data.frames (tables) to create groups and a third column. in R
I am trying to create differentiated groups of jobs from the CBO database (BRAZILIAN OCCUPATION CLASSIFICATION) They provide a CBO2002.csv with two columns the column "CODE" (with the code of each…
rasked 3 years, 11 months ago Lucas Moterani 11 -
1
votes1
answer36
viewsDemand forecast for many items
Good afternoon, folks. I’d like to hear your opinion on the following: I am working in an e-commerce company, which has more than 1000 items for sale, and each item of this, has a series of daily…
-
1
votes1
answer15
viewsTransformation of data frames into binaries in R
I’m doing a class exercise, but I believe you’re doing it the hard way and I’d like to know if there’s an easier way. This is the matrix I need to work on. The final matrix needs to have the matrix…
-
1
votes1
answer29
viewsHow to convert the format of a Date vector without it changing to Character?
I’m starting now on the R and getting beat up a lot with the Date class. I want to change the format "%Y-%m-%d" to "%b-%Y", but it also changes the class of the vector. x.data1 <-…
-
1
votes0
answers21
viewsError while testing Shapiro Wilk on multiple dataframe columns
I have three dataframes, a main one, with 2046 observations and two derivatives of these (with 1980 and 66 observations respectively) representing solvent and insolvent companies. All dataframes…
-
1
votes1
answer31
viewsExtract only uppercase words with R
library(stringr) I am trying to extract only the uppercase words from a string. teste <- "Isto é um Teste para ver se Eu consigo capturar APENAS as Palavras TOTALMENTE Maiusculas" teste [1] "Isto…
-
1
votes0
answers63
viewsInformation download (Fault - Network error)
Hello, I’m having difficulty downloading data from Anatel’s website through R Goal: Download data from Anatel’s website url = 'https://www.anatel.gov.br/dadosabertos/paineis_de_dados/acessos/' for…
-
1
votes0
answers18
viewsSubmit a table using Teamr package in R
I am developing an R routine to send data updates to the users of a MS Teams group using the Teamr package. Difficulty arises in formatting messages... library(teamr) canal =…
-
1
votes1
answer37
viewsAdjusted regression line considering different factors in ggplot2
I’m trying to reproduce the graph below, where the internal lines are the adjusted regression lines: However, for some factor is not being plotted what should, ie, is being presented a single line,…
-
1
votes0
answers25
viewsDemographic Census R Analysis
I need to read the data of the demographic census of the IBGE, of the base of people, in the case of the code below I downloaded the data of the desired UF manually, I was able to read them in the…
rasked 3 years, 10 months ago user22021995 41 -
1
votes1
answer25
viewsProblem using spread()
Hi, how are you? I’m having trouble using the function spread(): it shows error and does not pop. dados<-structure(list(V1 = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
-
1
votes2
answers62
viewsMixed effects model residue plots using ggplot2
I am trying to perform the residue graph of the mixed effects model by means of the ggplot2 function. However, after performing a search I found some available functions but what seems to me is that…
-
1
votes1
answer23
viewsComplete values of a column with values of the column itself in date.table
I have a data.table() with the following columns: municipality, year and pib_per_capta. (I actually have 30 more columns, but for example I think this is enough) The base is fully filled from 2005…
-
1
votes1
answer26
viewsTurns an observation into a variable in R
I would like to know how to transpose the observations of a dataframe to turn it into variables. The Subcategory column has to break down into several variables and its observations would be the…
rasked 3 years, 9 months ago Roney Wesley Galan 179 -
1
votes2
answers55
viewsTransform dataframe from long format to wide
I have a dataframe in long format and would like to transform it to wide format for exporting to Excel. I am using the function pivot_wider package tidyr, but the values are coming out this way: Man…
-
1
votes1
answer45
viewsMerge columns into a single string in R
Suppose the following date.frame: df<-data.frame(V1 = c(9,1,4,2,3,0,7,9,5), V2 = c(9,2,5,4,7,9,2,3,8), V3 = c(9,8,5,7,4,0,2,9,3), V4 = c(9,7,3,6,2,9,5,8,4), V5 = c(9,2,5,4,0,3,9,4,8)) V1 V2 V3 V4…
-
1
votes1
answer36
viewsChange the language of the result of a web-scraping with rvest from the IMDB site
I want to collect information about the IMDB Top 250 using the package rvest. While visiting the page link, the names of the movies appear in their original language, at least in my browser (Firefox…
-
1
votes1
answer33
viewsStrategy to run regressions with many iterations without much RAM
I have a small database (872 Obs. of 27 variables). But the analysis that I need to make of this base ends up being very heavy, because it requires analysis of the iteration of many variables among…
-
1
votes1
answer75
viewsHow to put an image (logo) in the Shiny dashboardHeader()?
I’m making a website in Shiny and would like to put an image of the company logo on dashboardHeader(). Example: The logo would be under "My Website", between the dashboardSidebar() and the…
-
1
votes1
answer65
viewshalf-normal waste graph Plots no ggplot2
I am trying to realize the graph presented below regarding the residues in the half-normal Plot in ggplot2. However, I am facing an error entitled Error: data must be a data frame, or other Object…
-
1
votes1
answer49
viewsfunction summarise
I am using a database with information about the Olympics(https://www.kaggle.com/heesoo37/120-years-of-olympic-history-athletes-and-results) and I want to analyze the data on the Olympic sports in…
rasked 3 years, 9 months ago LonelyBoy7 19 -
1
votes1
answer92
viewsOverlay graphics in ggplot2 considering adjusted lines
I am trying to superimpose two graphs made in ggplot2, in which the first contains the line adjusted by means of a polynomial model of degree 2 and the other contains the adjusted lines of a model…
-
1
votes0
answers32
viewsHow to create a polygon in nmds graph using ggplot2?
I’m trying to create a polygon but I can’t get it filled and complete. geral<-read.csv2("flora.csv", header=TRUE, stringsAsFactors = T);head(geral) comgeral = geral[,4:ncol(geral)] m_comg =…
-
1
votes2
answers60
viewsAdd multiple selects in a single dataset
I have the dataset below and I do a consolidation of the categories Mk_cap, Exports and Money_supply, but each of these grids has a different Unit. df <-…
-
1
votes1
answer53
viewsIdentify the ID that has value at least one column for all rows
I have a data.frame with columns: cnpj, name, year, rop, des, Cax, pcld. I need to identify the cnpj that possess the value "1" in at least one of the columns rope, des, Cax and pcld for all years.…