2 つの csv ファイルがあります。1 つは複数のポイントでの測定値を含み、もう 1 つは単一ポイントの説明を含みます。約 100 の異なるポイントと 10000 の測定値がありますが、簡単にするために、2 つのポイントと測定値しかないと仮定しましょう。
データ.csv:
point1,point2,date
25,80,11.06.2013
26,70,10.06.2013
説明.csv:
point,name,description
point1,tempA,Temperature in room A
point2,humidA,Humidity in room A
これで、両方の csv をデータフレームに読み込みました。次に、データフレームの列名を変更して読みやすくします。
options(stringsAsFactors=F)
DataSource <- read.csv("data.csv")
DataDescription <- read.csv("description.csv")
for (name.source in names(DataSource))
{
count = 1
for (name.target in DataDescription$point)
{
if (name.source == name.target)
{
names(DataSource)[names(DataSource)==name.source] <- DataDescription[count,'name']
}
count = count + 1
}
}
だから、私の質問は次のとおりです。ループなしでこれを行う方法はありますか? そして、私がしたかどうかのように、読みやすいように名前を変更しますか? そうでない場合、なぜですか?