Às 11:52 de 08/05/2023, Georg Kindermann escreveu:
Dear list members,
when I create a data.frame containing an array I had expected, that I get a
similar result, when subsetting it, like having a matrix in a data.frame. But
instead I get only the first element and not all values of the remaini
Hi Sacha,
On second thought, perhaps this is more the direction that you want ...
X2 = cbind(X_train,y_train)
colnames(X2)[3] = "y"
regr2<-randomForest(y~x1+x2, data=X2,maxnodes=10, ntree=10)
regr
regr2
#Make prediction
predictions= predict(regr, X_test)
predictions2= predict(regr2, X_test)
HTH,
Thanks!
No, to be consistent with what I get with a matrix I think it should be like:
x <- data.frame(id = DFA$id[1])
x$ar <- DFA$ar[1, , , drop = FALSE]
str(x)
#'data.frame': 1 obs. of 2 variables:
# $ id: int 1
# $ ar: int [1, 1:2, 1:2] 1 3 5 7
Georg
Gesendet: Dienstag, 09. Mai 2023 um
Dear R-users,
I updated my R. I installed 4.3.0.
I have Windows 10 Pro.
I can only install/update packages/files if I select method wininet.
For example:
> update.packages(ask='graphics',checkBuilt=TRUE)
--- Please select a CRAN mirror for use in this session ---
Warning message:
In download.f
Right ... that's what I thought you meant.
I'm pretty sure -- but not certain -- that columns of matrices are treated
specially by [.data.frame, so that you have to explicitly index a higher
dimensional array, e.g. like this:
subs <- c(1,3)
DFA <- data.frame(id = 1:3)
DFA[["ar"]] <- array(1:12,
I think the following may provide a clearer explanation:
subs <- c(1,3)
DFA <- data.frame(id = 1:3)
ar <- array(1:12, c(3,2,2))
## yielding
> ar
, , 1
[,1] [,2]
[1,]14
[2,]25
[3,]36
, , 2
[,1] [,2]
[1,]7 10
[2,]8 11
[3,]9 12
## array subscrip
Thanks!
With data.table I'm not able to create it.
DT <- data.table::data.table(id = 1:2)
DT$ar <- array(1:8, c(2,2,2))
#Error in set(x, j = name, value = value) :
# Supplied 8 items to be assigned to 2 items of column 'ar'. If you wish to
'recycle' the RHS please use rep() to make this intent
7 matches
Mail list logo