I have ran this piece of code before and never had an error.
df.new <- df1
for(i in 1:nrow(df1)){
df.new[j,] <- df1[j,]/df2$specificCol[j]
}
as a point example,
df1[1,1]/df2$specificCol[1] = 6.179306e-06
when I just manually want to set df.new[1,1] with this number, I get the error.
df.new[1,1] <-6.179306e-06
this time however I get this error
Error: Assigned data `6.179306e-06` must be compatible with existing data.
i Error occurred for column `x1`.
x Can't convert from <double> to <integer> due to loss of precision.
* Locations: 1.
Run `rlang::last_error()` to see where the error occurred.
how should I fix this error?
ps. thanks to @user20650, in case someone else needs this:
it was enough to write as.data.frame(df.new) instead of df.new ( which turns back true for is.data.frame(df.new).
I do not know why but this worked!