[R] building transformation macro
davv.vikas
davv.vikas at gmail.com
Thu May 24 10:43:18 CEST 2012
Hi All,
I am writing a macro which perform following functionality
1) take a file say excel or csv
2)read all the labels
3) dynamically genrate square,square-root,log of each column with
appropiate column name and write it to a new file,
i am stuck at dynamically genrateing the column names like Revenue_square
etc.
Exmaple " i have a excel with 3 columns Revenue, cost & profit
Now my Macro should be able to read the values and for each coulmn and
perform square,square root and log of Revenue, cost & profit and write to
excel with column names as Revenue_square,Revenue_squareroot, Revenue_log
cost_square etc...
Below is my code
test$Rev_square = test[c(1)]^2
data=read.delim2("//ARLMSAN01/CTRX_Data/vikasK.sharma/Desktop/balancesheet_example.csv",header=T,sep=",")
headings = names(data)
show (headings)
HEADINGS = toupper(headings)
for ( i in 1:length(HEADINGS))
{
show(i)
data$Rev_square=data[c(i)]^2
show(data$Rev_square)
names(data)
}
--
View this message in context: http://r.789695.n4.nabble.com/building-transformation-macro-tp4631175.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list