Posts by itamar • 589 points
29 posts
-
0
votes0
answers14
viewsQ: How to take advantage of objects created in a Rmarkdown file in another Rmarkdow file
I’m working on a report in Rmarkdown and I need to do another report which is actually a summary of the first. As it is a synthesis of the first, I need to rescue some objects from the original…
-
5
votes1
answer110
viewsQ: Insert image with kableExtra function::spec_image( )
library(tidyverse) library(kableExtra) Suppose the following dataset: games <- tibble(logo = "", nome = c("Joao", "Pedro", "Geovanna"), medalha = c("Gold", "Silver","Bronze")) I want to add…
-
0
votes1
answer20
viewsA: Failure with st_intersection() function
Sharing more information: the error message mentioned occurs when working from version 1.0 of the package sf, as PEBESMA explains in that post. Apparently, as of version 1.0 there has been a change…
-
0
votes1
answer20
viewsQ: Failure with st_intersection() function
library(sf) library(geobr) library(tidyverse) I’m having trouble using the st_intersection() package sf for certain data loaded with the package geobr. For example, if I try to make an intersection…
-
0
votes4
answers264
viewsA: R - How to replace "." (dot) with " (space) in the column names of a Data.Table?
An option using the stringr package str_replace(nomes, pattern = "\\.", replacement = " ") [1] "Salário Janeiro" "Salário Dezembro" "Salário Médio"…
-
-1
votes1
answer37
viewsQ: How to obtain bordering municipalities from a geom_sf + ggplot
library(tidyverse) library(geobr) Suppose I’m working with a Conservation Unit. Catimbau National Park (PE), for example. Low data by package geobr ucs<-read_conservation_units() parna_catimbau…
-
1
votes1
answer55
viewsQ: Coloring map with ggplot_2
Vi that question here in the so and tried to reproduce to my situation, however, still I did not get the desired result. library(tidyverse) library(geobr) library(RColorBrewer) Below the map of…
-
1
votes5
answers1065
viewsA: Remove duplicated names with regular expression
I know that there are already some answers to this question and that the question was asked years ago; but I was practicing other ways of trying to do that. I ended up meeting the following with…
-
1
votes4
answers16549
viewsA: How to include columns in a data.frame?
The function mutate() of dplyr may also be an option: library(dplyr) mutate(df, z=c(1,2)) x y z 1 a 1 1 2 b 2 2
-
1
votes3
answers8030
viewsA: How to include lines in a data.frame?
Another possibility is using the function add_row() of dplyr: library(dplyr) add_row(df, x="c", y=3) x y 1 a 1 2 b 2 3 c 3
-
-1
votes2
answers35
viewsQ: How to export [[ ]] from a list in separate excel files using R?
I play here part of a dataframe I’m working on: producao<-data.frame( discente = c("ANA", "ANA", "ANA", "ANA", "ANA", "MIGUEL", "MIGUEL", "MIGUEL", "MIGUEL", "MIGUEL", "JAIME", "JAIME", "JAIME",…
-
2
votes2
answers53
viewsQ: How to count repetitions in a range using length(which()) in R
I create the data frame called producao: producao<-data.frame(aluno = c("Pedro", "Joao", "Marcio", "Pedro", "Joao", "Pedro", "Marcio", "Marcio", "Marcio"), qualis = c("A1", "B2", "A1", "B2",…
-
1
votes1
answer45
viewsQ: Merge 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
answer31
viewsQ: Extract 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…
-
3
votes1
answer42
viewsQ: Standardize phone number with REGEX on R
library(tidyverse) I’m trying to standardize the "numero_telefonico" column of this dataset: https://raw.githubusercontent.com/rivaquiroga/latinr-taller-regex/master/datos/telefonos.csv Download the…
-
5
votes2
answers70
viewsQ: Error plotting with ggplot
library(tidyverse) library(lubridate) Suppose a dataset containing the year followed by the number of books published by an author: df<-tibble( ano = c(2007, 2008, 2017, 2018), n = c(1, 2, 2, 1)…
-
5
votes2
answers50
viewsQ: How to relate a column to a dictionary in R?
library(tidyverse) I have a dataset that has in one column titles of articles and in another column, their respective authors. I reproduce here a row of this dataset: df<-tibble( titulo= "A…
-
3
votes1
answer78
viewsQ: How do I distribute the content of a column to other columns in R?
I’m trying to distribute the contents of one column in another 3 columns. I have the following Data Frame: library(tidyr) df<-data.frame(Coluna= c('2237-5953', '(RE) PENSANDO DIREITO', 'B4',…
-
1
votes1
answer42
viewsQ: Is 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)…
-
3
votes1
answer42
viewsQ: Notice message by adding year, month and day with the ymd() function of the lubridate
I’m practicing with the pack hflights I install the package; I load the package; and I carry the lubridate install.packages("hflights") library(hflights) library(lubridate) The data (Year, Month,…
-
2
votes2
answers190
viewsQ: Label data in column charts at "Dodge" position in R
I am working with the following data frame: library(tidyverse) df<- data.frame(Ano=c(2017, 2018,2019,2020), Vagas=c(16, 14, 27, 32), Inscritos=c(70, 107,74,88), Aprovados=c(15,14,17, 12)) df Ano…
-
0
votes2
answers428
viewsQ: How to return only repeated values in R?
suppose the following dataframe: ref<-data.frame(autores=c("AZEVEDO, L. S.; NASCIMENTO, E. F.; CANDEIAS, A. L. B.", "BERGER, R.; SILVA, J. A. A.; FERREIRA, R. L. C.; CANDEIAS, A. L. B.; RUBILAR,…
-
-1
votes1
answer62
viewsQ: Divide bibliographic references into columns in R
I am with df which contains several bibliographic references. My intention is to divide these references into the following columns: "Author", "Title", "Periodico", "Data of the Periodico" (volume,…
-
1
votes2
answers57
viewsQ: Is 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…
-
2
votes1
answer121
viewsQ: How to change the colors of geom_points in R
library(tidyr) library(dplyr) library(ggplot2) library(lubridate) Suppose the following df: Ano<-c(2012:2020) Janeiro<-c(112,127,121,131,150,158,137,165,164)…
-
0
votes2
answers49
viewsQ: Convert days to years using R lubridate
Assuming the following dataframe: library(dplyr) library(lubridate) df<-data.frame(inicio= ymd(19800101), fim=ymd(20200101)) %>% mutate(dif=fim-inicio) inicio fim dif 1 1980-01-01 2020-01-01…
-
1
votes1
answer36
viewsQ: The "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…
-
0
votes2
answers98
viewsA: Convert "2012-01-01" to "2012-Jan-01" in R
Thanks for the tips Rui Barradas. I continued researching and testing and found this other possibility: I created a new "fen3 object". I used the function "paste0" to paste in the column "dt" the…
-
5
votes2
answers98
viewsQ: Convert "2012-01-01" to "2012-Jan-01" in R
good morning. It’s my first post here. I just started my journey in "R" and I’m having a hard time with dates. I even managed to get to the result I wanted, however I took a turn, in my view, VERY…