« Common Garden Measuring 2009 | Main | demo equipment »

shrivel data

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
codeForAllegra.r

TrackBack

TrackBack URL for this entry:
http://blog.lib.umn.edu/cgi-bin/mt-tb.cgi/89925

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)