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
votes1
answer75
viewsError in generation of bookdown
I’m trying to create a bookdown (from the package https://bookdown.org/yihui/bookdown/). When I create the book it returns the error below. I have already set the parameters: output:…
-
2
votes2
answers70
viewsHow to return a logical value when the lines have identical values in the R software?
I have a database that contains 3 variables: var1, var2 and var 3. I tried to use some functions in R that would return me a logical value if any of the lines had the same values. One of them was…
-
2
votes2
answers694
viewsDouble bar graph
I am trying to make a double bar chart with the following data frame: Total_CPIs <- data.frame(Período =c(1995, 1999, 2003, 2007, 2011), SP = c(12, 11, 2, 20, 22), RS = c(3, 4, 2, 4, 4)) The…
-
2
votes1
answer128
viewsExport multiple. csv files in R
I’m trying to export multiple files .csv in R through the function lapply. These files are within a list. I tried the following settings: lapply(list,function(x)…
-
2
votes0
answers54
viewsWeb scraping using the rvest
I’m trying to extract the data from a site (where it is necessary to login) but I’m not getting it. html_nodes("https://www.comdinheiro.com.br/home3/","div th") The output is not consistent with the…
-
2
votes0
answers46
viewsUse lapply inside for loop? [2]
About the question in: Use lapply inside for loop? I need to access my matrix in parts (because the procedure generates a problem with the available memory limit for R, given the large size of my…
rasked 5 years, 3 months ago user157038 21 -
2
votes1
answer175
viewsExtracting data from a data frame in R
I have a data frame in R and the table has row sets with the same attribute (name of an instance) and different columns with data on each instance. INSTÂNCIA VALOR 1 VALOR 2 Instancia 1 10 20…
-
2
votes1
answer123
viewsHow to apply the `Join` (dplyr) function in a list?
I tried in many ways to apply the functions join of package dplyr in a list but I can’t do this. With the function Reduce and merge This is easy to do, but my intention is to do it with join as this…
-
2
votes1
answer61
viewsAdd order of records according to date and id
In R, I have the following data: id date 2380 10/30/12 2380 10/31/12 2380 11/1/12 2380 11/2/12 20103 10/30/12 20103 12/31/12 And I want to add a column with the order of the records according to…
-
2
votes1
answer71
viewsHow does the `dplyr::n()` function know that it is not being called from the global environment?
When calling the function dplyr::n() in the global environment, an error occurs. n() # Error: This function should not be called directly This error makes sense and I was curious to see how it was…
-
2
votes2
answers66
viewsread txt file with less than 5 elements using read.table
I am trying to read the txt file with two columns below: +-----------------------------------------------------------------------------+ | Category Information | square| | #|description | miles|…
-
2
votes2
answers107
viewsUsing for loop in a list with charts in R
This is my code: library(ggplot2) library(gridExtra) df <- data.frame(x = 1:100, y1 = runif(100), y2 = runif(100)^2) plot_list <- list( plot1 = ggplot(df, aes(x, y1)) + geom_point(), plot2 =…
-
2
votes0
answers396
viewsLimit use of RAM in R
I’m running some analysis and would like to fix the use of RAM in R to be able to use other software simultaneously without any problem. So I’d like to, for example, limit the 4gb of RAM memory,…
-
2
votes1
answer115
viewsCustomize x-axis values (abscissas) in the geom_smooth or geom_ribbon functions of the ggplot2 package
Although I already have a similar question the solution presented there scale_x_continuous did not meet me in my problem. Normally for that I would use the function factor in…
-
2
votes2
answers182
viewsHow to use filter() to select only a part of the string?
I want to filter by a term that doesn’t always appear alone and the number of combinations is huge. My variable LINHAII has several codes and I want to filter the occurrences that contains E119.…
-
2
votes1
answer194
viewsMy HSD.test does not work. Any tips on how to run?
My treatment is in tracks and I am using as a basis the script taken from the book "Agricultural Experimentation" Kronha & Banzatto pg 161, accessed by website. I intend to perform the Anova and…
-
2
votes2
answers2044
viewsTranspose a dataframe into R
I have a dataframe in R, columns have dates and values and rows have countries. LOCATION jan 1999 fev 1999 mar 1999 EU28 86.70000 85.50000 85.90000 JPN 99.76086 99.76086 101.47350 USA 90.87153…
-
2
votes1
answer630
viewsDo Not Remove Specific Data Frame
I’m working with several DF (more than 30), but I want to exclude all except one specific. Example of my DF: DF1 VCBGF2 FGFR3 BBTYI4 QQASX5 RRTPS6 DF7 TTIPMBBT8 DF9 DF10 So I want to exclude 9 DF's,…
rasked 4 years, 11 months ago Bruno Avila 867 -
2
votes2
answers72
viewsFunction `Broom::Tidy` does not produce the output for some functions
I have the data.frame: library(tidyverse) library(broom) set.seed(1) dataset<-as_tibble(matrix(runif(6*30,20,100),ncol=6)) cluster<-kmeans(dataset,3)…
-
2
votes2
answers455
viewsFilter data frame according to indexes (lines) stored in a vector
Hello, I have a data frame where I store tourist information. Example in the image: and I have vector like this: 1 1 3 4 11 12 13 14 16 29 30 41 6 7 8 9 10 5 15 17 27 this vector in the case is a…
rasked 5 years, 10 months ago Lucas Freitas 145 -
2
votes2
answers384
viewsDownload data from Stock Exchange tables in R
I have the following code, I need to download the data that is in the table, but the dataframe is always returning empty. library(tidyverse) library(rvest) library(bizdays) library(dplyr)…
-
2
votes0
answers1095
viewsHow to do Descending Hierarchical Classification (CHD)/Reinert method in R?
In the Iramuteq has a very common analysis, which is the Descending Hierarchical Classification (CHD) or also known for reinert’s method. Here is an example of the same:…
rasked 5 years, 10 months ago Guilherme Parreira 2,060 -
2
votes1
answer77
viewsHow to save Twitter data, downloaded in R, in Excel?
I am using R to download public profile data on Twitter. The time of collection goes right, with the following code: library(rtweet) trump <- get_timelines("realDonaldTrump", n = 500) The problem…
-
2
votes0
answers69
viewsBasic Descriptive Functions
I’m analyzing a monitoring database of Conservation Units. I’m struggling with some basic functions. I would like to know what functions I should use to achieve the following values with the R:…
rasked 5 years, 10 months ago user136945 -
2
votes1
answer842
viewsHow to summarize data in R?
I have a sample of shopping data and would like to know how many purchases had per user in total. dput to assist response: structure(list(USUARIO = c(931053L, 276977L, 354508L, 909717L, 69758L,…
-
2
votes2
answers689
viewsHow to create Time Series using Start and End in R?
I’m trying to do a time series with a six-month data sample doing the following: compras = ts(dados_dia$QTDE_COMPRAS, start = c(2018,7), end = c(2019,1), frequency = 90) But by making a…
-
2
votes1
answer159
viewsGenerate a calendar in R
I need to generate a calendar with working days in R, but only for the current year. I am using the package bizdays to generate the days, but do not know a way to select only the current year. I…
-
2
votes1
answer43
viewsDelete columns that have NA
I have a row with 10 columns. In some of these columns you have NA. I want to delete these columns and leave only those that have values. I’m a beginner in R. Type: Name Nota1 Nota2 Nota3 Nota4…
rasked 4 years, 10 months ago Patricia P 21 -
2
votes1
answer110
viewsTesting Accuracy of an ARIMA model
I am creating a function to run ARIMA models. After storing the function results in an object to do the Accuracy test, returns the following error: Warning message: In trainingaccuracy(f, test, d,…
-
2
votes1
answer92
viewsOccurrence count of a dataframe giving error
I’m a beginner, and I know my code is still a little awkward, but let’s take it one step at a time. I have a dataframe with 2 columns (SO source and DT doc type), where I need to separate the OS by…
rasked 5 years, 9 months ago user108753 -
2
votes1
answer597
viewsTurn a Row into a Column in R
I have the following dataframe in R I need to turn the row into a column as follows: Nome Valor 1 x 1.1 2 x 2.2 3 y 3.3 4 y 4.4 5 z 5.5 6 z 6.6 And I need him to stay that way: x y z 1 1.1 3.3 5.5 2…
rasked 4 years, 9 months ago Guilherme Isaac 21 -
2
votes1
answer80
viewsJoin columns in ggplot histogram
I have that data https://pastebin.com/9tBv1Enm and tried to make a histogram with x= date and y= count ggplot(ind_geral1, aes(x=mes_ano))+ geom_histogram(binwidth=40) + theme(axis.text.x =…
-
2
votes1
answer276
viewsDownload from automatic download link and save changing directory in R
I have a list of links that automatically download pdf files and would like to save them with a new name in a folder that I created with dir.create(). I thought of originally importing the file as…
-
2
votes1
answer77
viewsHow to create one vector from another, but its elements must be greater than x?
I would like that v2 only those values which are greater than x. It even comes close, but creates a vector with logical elements. I wish they were the elements of v1. v1 <-c (1500, 1600, 1700,…
-
2
votes1
answer254
viewsHow to make the difference between two data.frames in R?
I created two data.frames: the first data.frame that comes from an original basis and the second data.frame which originates from the first, but with the application of a filter. Example:…
rasked 5 years, 9 months ago Izak Mandrak 1,059 -
2
votes1
answer90
viewsStem for Twitter
Dear colleagues, I am trying to do a twittering analysis of a Timeline and needed to stemiate the texts for analysis. I am trying the following procedure: setup_twitter_oauth(consumer_key,…
-
2
votes1
answer194
viewsFor Loop in R - Linear Regression
Hi, how are you? I am a beginner, and I would like to ask some questions about the possibility of automatic linear regressions. I have a database with 520 observations (rows) and 67 variables…
rasked 5 years, 9 months ago Gabriel Guilherme 31 -
2
votes1
answer34
viewsHow to create a range of an xls file, which is fed weekly?
How to create a crease in function read_excel, package readxl, where there is the initial cut and the end is open as it is fed weekly. b_aberto <- read_excel("Boletos_em_ABERTO.csv",…
rasked 4 years, 7 months ago Peter Trauer 23 -
2
votes2
answers492
viewsBarplot with labels
I am trying to create a Barplot chart with labels with the following code: Territo$E [1] 127 130 131 131 123 278 90 139 109 72 96 103 80 120 76 60 51 names <- c("1", "2","3", "4", "5", "6", "7",…
rasked 5 years, 8 months ago Fidel Henrique Fernandes 119 -
2
votes0
answers122
viewsExtract in R tables that take up more than one page in pdf files
Hello, Have a pdf containing a table and I want to extract this table to be able to analyze in R. I am using the tabulizer::extract_tables() . As the table occupies more than one page, it returns me…
rasked 5 years, 8 months ago Jessica Voigt 883 -
2
votes1
answer33
viewsReading Rdatas returning dates frames with different names
I need to read a list of 17 RDATAEach one of them returns one data.frame, but some of these data frames have different names (I don’t know exactly which ones) which would disrupt the code below…
rasked 5 years, 8 months ago Flavio Silva 1,108 -
2
votes2
answers71
viewsIndexing of Dataframe
The data follows below Prouni<-read.csv("C:\\cursos_prouni.csv") The following link redirects to the data https://brasil.io/dataset/cursos-prouni/cursos. The data are shown as in the figure…
rasked 5 years, 8 months ago Fidel Henrique Fernandes 119 -
2
votes2
answers41
viewsForm a dataframe from 3
I have 3 CSV files with 3 data frames, and one brings the columns países and população, another bring países and área and another brings países and expectativa de vida. In the first, there are 195…
-
2
votes1
answer129
viewsHow to put captions on a line chart in ggplo2
I have a line chart with two variables and I need to put the caption of each one, however, I’m not getting. I’m using a code like this: library(ggplot2) data <- c(1:50) dado <- c(1:50) dado1…
-
2
votes1
answer45
viewsHow to make inter-weekly variation on R
I have a database in long format and I need to do the inter-weekly variation, ie today’s data / given 7 days ago - 1. Code I used, but is doing the variation of the previous day: library(readr)…
rasked 4 years, 7 months ago Alexandre Sanches 1,223 -
2
votes0
answers300
viewsR - How to remove all installed packages?
I ran a script in R a while ago and ended up installing all the packages related to statistics. With this, every time I go to make an update, it ends up taking longer than necessary. Since I do not…
-
2
votes1
answer90
viewsWhat does "foo() <-" mean in R?
Consider the vector k class factor three-tiered (1, 2 and 3): k <- as.factor(x = sample(x = 1:3, size = 30, replace = TRUE)) [1] 3 1 1 2 1 1 3 2 3 3 1 2 3 3 2 2 2 1 3 1 2 2 1 3 1 1 3 2 1 1…
-
2
votes1
answer541
viewsNames exchanged in a column: How to replace values in a column by keeping the rest of`data.frame` constant?
I imported a spreadsheet where two observations came exchanged and the rest was correctly filled. My problem can be demonstrated with the example below: the values assigned to the individual…
-
2
votes1
answer2893
viewsChange title and caption colors in ggplot2
How do I change the field pop and continent. I want to put in Portuguese (Population and Continent). The data are in R through the package library(Gapminder). I used the following command:…
-
2
votes3
answers702
viewsAdd elements into a vector using loops and inputs
I tried to write a simple command on R where the program asks 5 numbers for the user (input) and adds each one to a list. The problem is that the array is empty. I’ve tried lists too. Follow the…
rasked 4 years, 5 months ago Guilherme Matos Passarini 99