I'm trying to write a line based on the below matrix,
print(mat)
[,1] [,2]
[1,] "wesd" "2.0E-5"
[2,] "lesd" "8.0E-8"
[3,] "nf" "16.0"
[4,] "ldop" "1.25E-6"
[5,] "lsop" "2.0E-7"
[6,] "esdoxide" "1.0"
[7,] "gns" "1.0"
Below is my code, .
ipFile = 'text.txt'
fConn <- file(ipFile,open="w")
paramname <- c("a","b","c","d","e","f","g")
for(a in 1:length(paramname)) {
tmpvar = 1
#Using the matrix value printed above
writeLines(c('parameters ',mat[a,1],'_',as.character(tmpvar),'=',as.character(mat[a,2]),'\n'),con=fConn,sep="")
a=a+1
}
close(fconn)
I'm getting the below Error,
Error in writeLines: invalid 'text' argument
I tried to change the integer values used in writeLines to as.character but no hope. And meanwhile when I try to run the above code in the console it works well (by removing the conn=fconn argument in the writeLines code). This code doesn't work when I try to run from the rstudio app.