R Language Error: rowMeans(new1) : ‘x’ must be an array of at least two dimensions

Use command:

new1$mean=apply(data.frame(new1),1,mean)
new1$mean=rowMeans(new1)

Generate error: rowmeans (new1): ‘x’ must be an array of at least two dimensions

Change the command to the following:

new1$mean=apply(as.data.frame(new1),1,mean)
new1$mean=rowMeans(new1)

Note that when using rows to calculate the average value, you need to convert “matrix” to “data. Frame”. You can’t directly use the data.Frame() function, but you need to use the as.Data.Frame() function;

Similar Posts: