Questions tagged as 'r'

3
answers

Identify in a data the variables that are factor type in R

I need a cycle that runs through a database and I identify the variables that I have to change to factor type, those that have 0 and 1 because there are variables that only have 0 or 1 that I need to leave numerical (and that there are variables...
asked by 14.07.2017 / 16:47
3
answers

remove non-alphanumeric characters in r

I have a function in r that analyzes them from different text strings and returns all the words that contain the different strings. data <- searchTwitter(input$select, n=input$numtweets) data_text <- sapply(data, function(x) x$getText())...
asked by 18.05.2017 / 10:57
2
answers

How to collapse a data frame with R

Hi, I'm trying to collapse a data frame that I have with R, the idea is that I have 3 variables: site, species, biomass. For each site I have a list of species where the same species are repeated several times in the sites with biomasses, and I...
asked by 26.03.2016 / 21:13
2
answers

Error trying to normalize data

I'm normalizing a csv file with R. datos <- read.csv2("Z.EMR.csv") normalize <- function(x) { return ((x - min(x)) / (max(x) - min(x)))} In this line I get the following error datos_norm <- as.data.frame(lapply(datos, normalize))...
asked by 27.11.2018 / 19:35
1
answer

Function If in R

I have a question and I would like to share it to see if anyone can help me. I'm working on R with a matrix called matriz_diferencia . It has 3 rows of which one is empty and 96 columns. What I'm trying to do, is to complete that third row...
asked by 30.10.2018 / 17:19
1
answer

how can I change a single value of a DataSet in R?

Assuming we have this DataFrame: How can I change the value of column X in row "BA" ?, I know I can modify the whole row but what I want is to see how it is done since there can be dataFrame of many columns. Thanks     
asked by 31.10.2018 / 22:13
1
answer

Doubts of R Concepts

Greetings to all, I am starting in the world of R Language and there are certain instructions that I do not understand its purpose. Like the following: set.seed(12345) data(iris) datos<-irirs I found that the 1st line generates sequences...
asked by 15.10.2018 / 15:01
1
answer

error recorer string with for in r

I want to go through a text string using a loop, but when I run the code, it only makes the first iteration. text <- "CTGGTGCTCGTAGACCGCAGAACC"; i=0 i1=i+3 for (i in 1:length(text)){ DNA <-substr(text,i,i1) i=i1+1 i1=i+2 print(DNA) }...
asked by 27.10.2017 / 10:26
1
answer

Delete except when there is a keyword

I try to delete all the numbers in the text, except if they are preceded by the word hospital . I have: data<-c("3l hospital 11 esta a la vu3lt4") data<- gsub("\b(?![hospital])\s[0-9]|[0-9]", "", data, perl = T) and my resu...
asked by 12.01.2018 / 05:16
2
answers

Sum of a category within a data.frame

From a data.frame with the following characteristics: df <- data.frame(mes= rep(10:12, each = 4) , hour = rep(1:2, 6) , value = sample(1:12)) df > df mes hour value 1 10 1 6 2 10 2...
asked by 30.11.2017 / 23:57