我需要繪製約50幅這些圖表,我只需要更改x,y和數據。有沒有辦法縮短這個看起來不那麼雜亂?無需下載任何外部庫。如何循環或縮短R中的腳本
RatingsA,RatingsB和Looks是具有大約100k個值的向量,例如, ( 「空」,439 ...等)
#Plotting graphs based based on Looks Vs Ratings
png('1.png')
par(mfrow=c(4,2))
plot(RatingA ~ Age, main="Looks Vs RatingA at List1", xlab="Looks", ylab="RatingA", xlim=c(20,80), data=List1)
plot(RatingA ~ Age, main="Looks Vs RatingA at List2", xlab="Looks", ylab="RatingA", xlim=c(20,80), data=List2)
plot(RatingA ~ Age, main="Looks Vs RatingA at List3", xlab="Looks", ylab="RatingA", xlim=c(20,80), data=List3)
plot(RatingA ~ Age, main="Looks Vs RatingA at List4", xlab="Looks", ylab="RatingA", xlim=c(20,80), data=List4)
plot(RatingA ~ Age, main="Looks Vs RatingA total", xlab="Looks", ylab="RatingA", xlim=c(20,80), data=mainlist)
dev.off()
png('2.png')
par(mfrow=c(4,2))
plot(RatingB ~ Looks, main="Looks Vs RatingB at EVR1", xlab="Looks", ylab="RatingB", xlim=c(20,80), data=List1)
plot(RatingB ~ Looks, main="Looks Vs RatingB at EVR2", xlab="Looks", ylab="RatingB", xlim=c(20,80), data=List2)
plot(RatingB ~ Looks, main="Looks Vs RatingB at EVR3", xlab="Looks", ylab="RatingB", xlim=c(20,80), data=List3)
plot(RatingB ~ Looks, main="Looks Vs RatingB at EVR4", xlab="Looks", ylab="RatingB", xlim=c(20,80), data=List4)
plot(RatingB ~ Looks, main="Looks Vs RatingB total", xlab="Looks", ylab="RatingB", xlim=c(20,80), data=mainlist)
dev.off()
請考慮下面的代碼片段。 (for C(「A」,「B」))print(paste0(「Var」,i))' – shayaa