Posts by RogerioJB • 996 points
17 posts
-
5
votes3
answers166
viewsA: Find an expression in several elements of a list
I made a small change in your data to increase the number of cases: df1 <- data.frame(nome = c("José da Silva", "Maria da Silva"), idade = c(45, 54)) df2 <- data.frame(nome_completo = c("Mauro…
-
6
votes2
answers737
viewsA: How to replace a space by semicolon between two words with gsub()
Here it comes: ex <- "[email protected] [email protected]" # Com o gsub() gsub(pattern = "[[:blank:]]", replacement = ";", x = ex) # Com str_replace_all(), que eu prefiro library(stringr)…
-
13
votes2
answers2429
viewsQ: How to recognize and change the encoding of Latin characters in R?
Is there any efficient way to recognize the encoding of texts downloaded from the internet? I made a scraping of any site (see code below) and I can’t find the correct encoding. In the META tag of…
-
7
votes2
answers686
viewsQ: How to make webscrapping of an https using rvest?
I would like to shave a page that is in https using the package rvest. However, it is a website with problems in the security certificate. In such cases, you need to turn off the SSL verification --…
-
2
votes3
answers656
viewsA: Commands as. Date and srtptime in R
You should use uppercase Y to indicate that the year format has 4 digits. datas=c("26/12/2014", "27/12/2014", "28/12/2014", "29/12/2014", "30/12/2014", "31/12/2014") as.Date(datas, "%d/%m/%Y") #[1]…
-
1
votes1
answer119
viewsA: Error with factor analysis command
Apparently, you’re trying to simultaneously use function options that don’t allow this... See, all the commands below produce the same results. They are modifications of the codes posted by you: #…
-
1
votes1
answer110
viewsA: Using the code below, why am I only collecting data from the last page of the Loop?
See the suggested code below. Now it’s working. The loop needed to be closed (as @Cantoni had already said). But the problem you reported had to do with the fact that you were over-writing the data…
-
6
votes1
answer460
viewsA: Web scraping for scientific papers collection at Sciencedirect
I have a suggestion using the Rselenium and XML packages. Rselenium controls an internet browser (in this case firefox) and allows you to automatically navigate by command line. This is very…
-
1
votes1
answer621
viewsA: I cannot import data from a CSV to Postgresql with dbWriteTable from R
I’ve found that one path may be the following: library(data.table) postgresqlWriteTable(con = con, name = "tabela1", value = fread("tabela.csv")) But I still don’t know if this is a great…
-
3
votes1
answer621
viewsQ: I cannot import data from a CSV to Postgresql with dbWriteTable from R
I am trying to import a CSV into a Postgresql database from R. On the Postgresql server, I created an empty database, called "Data". library(RPostgreSQL) library(sqldf) drv <-…
-
5
votes4
answers1143
viewsA: Add rownames as column using dplyr
Try this here: library(dplyr) dados <- mtcars dados %>% mutate(names = row.names(dados)) You can also do: dados %.% mutate(names = row.names(`__prev`)) `__Prev` (between crases) indicates the…
-
3
votes1
answer278
viewsQ: I get NA when I convert Character to time (Posixlt)
Why do I get NA when I do this conversion from Character to Posixlt? library(bReeze) data(winddata) tempo <- winddata[,1] tempo[1:6] # Preview # [1] "06.05.2009 11:20" "06.05.2009 11:30"…
-
6
votes4
answers8289
viewsA: How to put different graphics of ggplot2, separately but on the same screen?
You can also use the functions grid.arrange package gridExtra. library(ggplot2) library(gridExtra) # Crio 4 gráficos grafico_1 <- qplot(1:5,1:5) grafico_2 <- qplot(10:1,1:10) grafico_3 <-…
-
4
votes3
answers6503
viewsA: How to avoid encoding problems when picking up data with Twitter?
I don’t know if there’s any way to permanently fix the character coding problems. There are several factors that hinder the correct identification of the encoding. On a given web page, the encoding…
-
4
votes2
answers2111
viewsQ: I can’t install Ibgepesq in R to read the Pnads
I just downloaded the 2013 PNAD of IBGE -- and I tried to open it with the package for R that IBGE itself elaborated, the Ibgepesq. It is available as . zip archive at this address:…
-
8
votes1
answer480
viewsQ: Is there a way to open a direct SQL table in a data.table, without doing the SQL path > data.frame > data.table?
I want to open a direct SQL table in a date.table. When I do a query with dbGetQuery, what I get is a data.frame. I know I can then turn that data.frame into a data.table easily. But I would like to…
-
6
votes2
answers441
viewsQ: How to make a "rbind" in tables of an SQL base from R?
I would like to "merge" two tables of a Sqlite "database" from the R -- and save it to a new table within the same database. Below, I send a minimum reproducible code:…