R: weird behaviour in linear regression I am trying to practice with R through some problems, one of them says:
Through a linear regression model WITH APPROPRIATE SCALE CHANGE
based on the campione data, predict the adv number for a duration in seconds equal to the 
average of seconds in PUBB NOT censored

Note: CENSORED means that seconds == 60
code:
##### just to show how the data was set #######
PUBB = read.table('avvisi.txt', header=T)
I1 = sample(which(PUBB$secondi == 60), 0.25*nrow(PUBB))
I2 = sample(which(PUBB$secondi < 60), 0.75*nrow(PUBB), replace = T)
campione = PUBB[c(I1,I2),]
##############################################

x = campione$secondi
y = campione$adv
plot(x, sqrt(y), ylab = "y = adv", xlab = "x = secondi")
model = lm(x~sqrt(y))
summary(model)  # R-squared:  0.9667

argomento = mean(PUBB[which(PUBB$secondi < 60),]$secondi)
predict(model, data.frame(x = argomento))

Now I'm getting a lot of results (instead of one as expected) with a warning message:
"Warning message:
'newdata' had 1 row but variables found have 640 rows"
To have an idea of the data frame PUBB:
> summary(PUBB)
      adv           secondi        
 Min.   :1.000   Min.   : 0.08013  
 1st Qu.:1.000   1st Qu.:16.84150  
 Median :5.000   Median :40.82163  
 Mean   :5.087   Mean   :37.59638  
 3rd Qu.:9.000   3rd Qu.:60.00000  
 Max.   :9.000   Max.   :60.00000  
> str(PUBB)
'data.frame':   1000 obs. of  2 variables:
 $ adv    : int  9 1 1 9 9 9 4 1 9 9 ...
 $ secondi: num  60 12.503 0.821 60 60 ...
> dput(campione, file="campione.txt")

see here (dput of campione)
'avvisi.txt'
my full code

The reason you are having this issue is because the name of your predicted variable from the original regression and the name of your predicted variable in the new data frame don't match. You can try making your variables into objects if you want to name them by x. An example with the iris dataset in R:
#### Predict by Objects ####
data(iris)
y <- iris$Petal.Length
x <- iris$Sepal.Length
fit <- lm(y ~ x)
predict(fit,
        data.frame(x=mean(iris$Sepal.Length)))

Which gives you your predicted value:
   1 
3.758 

EDIT
I've refit the regression using your new dput and it seems to still work fine.
y <- campione$adv
x <- campione$secondi
fit <- lm(y ~ x)
predict(fit,
        data.frame(x=mean(campione$secondi)))

Giving me this
    1 
4.428 

