Here’s a snippet of R code showing how to extract info from the shrivel character data (a file is below…
df <- data.frame(shrivel.txt =c("x", "xoxx", "xxxx", "oooo", "xoooo")) df # start off with this data frame str(df) df$shrivel.count <- nchar(as.character(df$shrivel.txt)) #add column vx <- gsub("o", "", df$shrivel.txt) # replace o with "" vx df$shrivel.xs <- nchar(vx) # make a new column in df vo <- gsub("x", "", df$shrivel.txt) # replace x with "" vo df$shrivel.os <- nchar(vo) # make a new column in df str(df) df # final data frame



Leave a Reply