[R] Create new dataframes with dames from dataset...
Lars Modig
eb99lamo at kth.se
Thu Aug 7 13:21:56 CEST 2008
Hi
I'm wondering if you could save new data frames with in a loop using the
names within the data frame... I.e. If you have a data frame as below
Product Type Test
A One 67
A Two 55
B One 42
A One 55
I would like to generate new dataframes as follow...
A.One (including)
A One 67
A One 55
A.Two (including)
A Two 55
B.One (including)
B One 42
I've so far has been able to store each data as an indexed eps picture. I
put a summary of my code below, and as you can see I'm not used to program
R, and actually it was a long time since I used C or some other software
also...
Platforms <- sort(unique(data_variable[,3])) # find all platforms sorted
length(Platforms) # no of platforms
for(j in 1: length(Platforms)){ #
row_vector <- which(data_variable[,3]==Platforms[j]) #Find the first
platform
cleaner_1 <- data_variable[row_vector,] #store it in
cleaner_1
Motor <- sort(unique(cleaner_1[,5])) # find all motors for
platform 1 sorted
for(i in 1: length(Motor)){
row_vector <- which(cleaner_1[,5]==Motor[i]) # find the
first motor
cleaner_type_1 <- cleaner_1[row_vector,] # store it in
cleaner_type_1
Data_x <-cleaner_type_1[9]
Data_y <-cleaner_type_1[10]
hist(Data_x[,], probability=TRUE, breaks=5, main=data_header[9])
savePlot(filename = paste(c("C:/pow",j,"_",i), collapse="") ,type = "eps")
# Save plot with order no i
More information about the R-help
mailing list