1
私はハイチャートをグラフに使用しています。私はすべてのために同じグラフを描く必要がある、異なるコースを持っています。私は、コースの上にforループを持って、私のループの中にこれらのグラフをプロットしようとしています。 ループ内に何かがプロットされず、ループ外から正常に動作するという問題があります。問題へハイハットを使用してループ内にプロットする
for(i in unique(my_data$CourseID)){
courseData<-subset(my_data, my_data$CourseID== i)
#Course by Majer
byMajer <- table(courseData$MajerName)
#barplot(byMajer, main="Students by Majer", xlab="Majers")
byM <- aggregate(courseData$MajerName, by=list(courseData$MajerName), FUN=length)
hc <- highchart(debug = TRUE) %>%
hc_title(text = courseData$CourseName[1]) %>%
hc_chart(type = "column") %>%
hc_xAxis(categories = byM$Group.1) %>%
hc_add_series(data = byM$x)
#this is not working. it shows nothing.
hc
#but if I try to have this, it works, I will use below variables outside the loop
assign(paste("hc",i,sep=""), hc)
}
#Below graphs showing in the output. I need to get rid of them and use the one inside the loop.
hc1; hc2; hc3; hc4; hc5; hc6; hc7; hc8; hc9; hc10; hc11; hc12; hc13; hc14; hc15; hc16; hc17; hc18
どうもありがとう..を。 – shanyour
@shanyourこの回答があなたの質問に答えるなら、あなたはそれを受け入れられたものとしてマークすることができます - そうでない場合は、未回答の情報を提供してください。 –