# R program to modify data of an object# Calling predefined data set
BOD
# Calling with() functionwith(BOD,{BODdemand<-BODdemand+1;print(BOD$demand)})
R
输出
Time demand
118.32210.33319.04416.05515.66719.8[1]9.311.320.017.016.620.8
R
例2 :
# R program to modify data of an object# Creating a data frame
df = data.frame("Name"= c("abc","def","ghi"),"Language"= c("R","Python","Java"),"Age"= c(22,25,45))
df
# Calling with() functionwith(df,{dfAge <- dfAge +10;print(df$Age)})
R
输出
NameLanguageAge1 abc R 222defPython253 ghi Java45[1]323555