Questions tagged as 'r'

1
answer

R code_function with ()

What does this line of code mean? with(epilepsy,by(seizures/timeadj,list(treat,expind),mean)) The data is from the faraway package.     
asked by 24.05.2017 / 19:03
1
answer

How to return cells based on identifier in R

I need to return the class of a specific id for a table. Often a single id encodes several classes: id<-c("A","B","C","D","C","B","A") clas<-c(1,2,2,2,3,3,4) tab<-data.frame(id,clas) What I need is to make a data.frame that returns...
asked by 28.03.2017 / 21:38
1
answer

I need to create a column with the ln of a variable in the same data frame

I have a series of data eg GDP and I need to create a column next to it with the variable lnPIB, how do I in R?     
asked by 13.02.2017 / 00:32
2
answers

Make subset and keep values NA

I'm sure there's a way to make subset and keep the NA values in R. However, when I apply this function, the NA values are also disappearing from my base. I'm just using the formula below: dados1<-data.frame(subset(dados,V2!="CNPJ")) So y...
asked by 13.12.2016 / 19:22
1
answer

R - How to create a delayed variable (lag) conditioned to the individual?

I need to delay a variable from my db ( dCoopCred ). However, it can not mix the delay of two individuals (% with%). I would like CNPJ to be LAG_Result_ant_desp in t-1 (previous period). Example: structure(list(CNPJ = c(...
asked by 15.06.2018 / 01:34
1
answer

Speed of table crossing - R

Good evening! I cross two bases in Rstudio, using the merge, but I would like to know if using another way (eg left_join), I get faster, because my tables can get 8 million lines. Thank you.     
asked by 08.06.2018 / 04:06
1
answer

How to find if there is a word inside a text in R

I need to know if there is a specific word inside a certain text, for example fnord . So far I've only found: x<-"fnord: Você não tem nivel de acesso a está informação." strsplit(x, "[[:punct:] ]") [[1]] [1] "fnord" ""...
asked by 24.07.2018 / 21:42
1
answer

R Delete rows from the date frame by condition

I have the following data set: Nome <- c("Laetia","Vouacapoua","Lecythis","Pourouma","Poraqueiba","Pseudopiptadenia", "Abarema"); I1 <- c(1,3,3,2,3,3,3); I2 <- c(1,3,1,3,3,3,3); I3 <- c(1,3,1,3,2,3,3); I4 <- c(1,3,2,2,3,3,3) x...
asked by 26.07.2018 / 04:56
2
answers

Select column of a data.frame - division of Database in R

I imported a table as a database to handle in R. However, I need to do some calculations with only a few columns in this table. How do I select only these columns for the calculations?     
asked by 13.07.2017 / 20:24
1
answer

How to check if a polygon is convex

How do I check if a polygon is convex? The input can be given by: #Por exemplo um quadrilátero, a primeira coluna é x e a segunda coluna é y. quadrilatero = matrix(c(0,2,-7,1,4,3, 4,5), ncol = 2) Output is TRUE or FALSE .     
asked by 28.04.2016 / 13:29