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
![Share on Twitter twitter](https://echinaceaproject.org/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/twitter.png)
![Pin it with Pinterest pinterest](https://echinaceaproject.org/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/pinterest.png)
![Share by email mail](https://echinaceaproject.org/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/mail.png)
Leave a Reply