[if the format of my email is changed or is difficult to understand, a text
file is attached for easy understanding]Dear useRs,
i was wondering that if its possible in R to automatically generate plots and
get it saved at the desired location? i have
data of cancer patients, from about 1000 cities around the world. i have
converted that data into a list (called tcp) and
that list has 1000 sublists. the sublists are named, according to the city
name. the orientation of the sublists are as
follow
$ Tokyo
month 2009 2010 20111 515 356 1212 444 145 1203
478 147 1244 147 236 1245 785 142 1256 478
111 4787 478 856 7858 147 786 4569 147 122
12310 786 123 14711 123 787 25812 110 898 369
$ Nagoya
month 1955 1956 19641 512 444 7712 441 145 4703
445 156 4744 145 236 7845 785 147 4456 447
178 9887 478 980 8858 189 886 7869 145 722
18310 756 123 16711 145 127 24812 110 128 259
what i wanted to do is the following
1- drawing curve of each column in the sublist against the first column of each
sublist(month vs patients).
2- drawing average curve of each city over the yearly curves. (for example, for
tokyo, overlay average curve of 2009,2010
and 2011 on already generated 3 curves).
3-saving the resulting diagram on a suitable location in my pc.
i used the following commands for these three operations
>jpeg("C:/world survey/ Tokyo.jpg")>matplot(tcp$ Tokyo[,-1], type = "l",
>col="grey", xlab="TIME(month)",
>ylab="patients")>apply(Tokyo,1,mean)>data.frame(Tokyo)>avgTokyo<-as.matrix(Tokyo,
> ncol=1)>lines(avgTokyo, lwd = 2)
As as you can see that i have 1000 cities to work on, isnt there any other
suitable way of doing that??i am interested in knowing about "function"
command. because when i used the following command
>lapply(seq_along(tcp), function(i) matplot(tcp[[i]][,1],tcp[[i]][,-1],
>type="l",col="grey"))
i did plot every city' diagram but didnt save it anywhere.
Could you please guide me how to plot and save simultaneously all the firgure
in one go?
thanks in advance
eliza
Dear useRs,
i was wondering that if its possible in R to automatically generate plots and
get it saved at the desired location? i have data of cancer patients, from
about 1000 cities around the world. i have converted that data into a list
(called tcp) and that list has 1000 sublists. the sublists are named, according
to the city name. the orientation of the sublists are as follow
$ Tokyo
month 2009 2010 2011
1 515 356 121
2 444 145 120
3 478 147 124
4 147 236 124
5 785 142 125
6 478 111 478
7 478 856 785
8 147 786 456
9 147 122 123
10 786 123 147
11 123 787 258
12 110 898 369
$ Nagoya
month 1955 1956 1964
1 512 444 771
2 441 145 470
3 445 156 474
4 145 236 784
5 785 147 445
6 447 178 988
7 478 980 885
8 189 886 786
9 145 722 183
10 756 123 167
11 145 127 248
12 110 128 259
what i wanted to do is the following
1- drawing curve of each column in the sublist against the first column of each
sublist(month vs patients).
2- drawing average curve of each city over the yearly curves. (for example, for
tokyo, overlay average curve of 2009,2010 and 2011 on already generated 3
curves).
3-saving the resulting diagram on a suitable location in my pc.
i used the following commands for these three operations
>jpeg("C:/world survey/ Tokyo.jpg")
>matplot(tcp$ Tokyo[,-1], type = "l", col="grey", xlab="TIME(month)",
>ylab="patients")
>apply(Tokyo,1,mean)
>data.frame(Tokyo)
>avgTokyo<-as.matrix(Tokyo, ncol=1)
>lines(avgTokyo, lwd = 2)
As as you can see that i have 1000 cities to work on, isnt there any other
suitable way of doing that??
i am interested in knowing about "function" command. because when i used the
following command
>lapply(seq_along(tcp), function(i) matplot(tcp[[i]][,1],tcp[[i]][,-1],
>type="l",col="grey"))
i did plot every city' diagram but didnt save it anywhere.
Could you please guide me how to plot and save simultaneously all the firgure
in one go?
thanks in advance
eliza
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.