[R] How to generate same type of graphs using the previously written commands for a few hundred similar data sets?
susiecrab_ling at hotmail.com
Tue Jul 12 00:29:21 CEST 2011
I have a few hundred of data sets which are within one data file, I need to
first of all take the subsets of each data set, and I've written commands to
generate a graph and csv file. Then I want to generate the same type of
graphs and csv files for the rest of the data sets. I wonder if there's a
command in R which I could use?
To be more specific, I have written out the commands for a particular subset
as the following, and then I need to do the same thing for the rest of the
data subsets, the only thing I need to change is to modify the subset names,
for example, change "seven" into "eight", "seventout" into "eightout", etc.
Is there a command in R that would do this for me? (So I don't need to
repeat myself modifying the names, copying and pasting the same things into
R.) Thank you very much!
alldata <- read.csv(file="file.csv",header=T,sep=",")
seven<- subset(alldata, aserno==7, select=c(I,C,D)) ## aserno==7, so I need
to change 7 into different numbers included in the data file##
sevenout <- subset(seven, I=="a" & D>0, select=c(I,C,D))
f <- function(sevenoutf) nrow(sevenoutf)
sevennumber <- ddply(sevenout,.(C), f)
colnames(sevennumber) <- "N"
sevenout$N <- sevennumber$N [match(sevenout$C, sevennumber$C)]
plot(sevenout$time, sevenout$N, type="n")
lines(sevenout$time,sevenout$N) # the result that I need
write.csv(sevenout, "sevenM.csv", row.names=FALSE) # the result that
View this message in context: http://r.789695.n4.nabble.com/How-to-generate-same-type-of-graphs-using-the-previously-written-commands-for-a-few-hundred-similar--tp3661026p3661026.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help