Dear R-experts,

I am relatively new to R. Please help me in converting a dataframe into a 
numeric and then creating a new dataframe.

R-code attached:

my_xtrain=read.table("./train/X_train.txt") 
my_xtest=read.table("./test/X_test.txt") 
my_merge_data=merge(my_xtrain,my_xtest,all=TRUE) 


### my_merge_datad is a new dataframe in which I want my_merge_data to be 
numeric
my_merge_datad=as.numeric(as.character(my_merge_data),na.rm=TRUE) 


### my_m: I want to initialize a dataframe here
my_m=dat() 


for (i in 1: 561) {

## here in my_m[1,i] I want to store the mean of all the columns, 1 to 561  
      my_m[1,i]= mean(my_merge_data[,i]) 

## here in my_m[2,i] that is the second row of the new dataframe my_m I want to 
store the standard deviation of columns 1 to ##561
      my_m[2,i]=std(my_merge_data[,i]) 
}

Thanking you,
Aditya

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to