‘height’ must be a vector or a matrix. barplot error
You can specify the two variables you want to plot rather than passing the whole data frame, like so: Alternatively, you can use ggplot to do this:
You can specify the two variables you want to plot rather than passing the whole data frame, like so: Alternatively, you can use ggplot to do this:
To get the matrix multiplication to work, you need to convert the data.frame (presumably that’s what da is) to a matrix: But this gives a 7×7 matrix which can’t be added to the 3×3 identity matrix that you’re using. Do you mean something like: You may like to have a look at An Introduction to … Read more
This is a very common mistake, you need to use the named argument FUN: otherwise mean will be interpreted as another grouping variable (part of the … argument to ave.)
The issue is because plot() is looking for vectors, and you’re feeding it one data.frame and one vector. Below is an illustration of some of your options.
If you want the output to print to the terminal it is best to use Rscript Note that when using R CMD BATCH a.R that instead of redirecting output to standard out and displaying on the terminal a new file called a.Rout will be created. One other thing to note about using Rscript is that it doesn’t … Read more
1. tapply I’ll put in my two cents for tapply(). You could write a custom function with the specific statistics you want or format the results: 2. data.table The data.table package offers a lot of helpful and fast tools for these types of operation:
The problem seems to be in your geom_rect area (it plots without this). Other “date_trans” errors on this site point to needed to set dates with as.Date. So yes, you were in the right debug area. This works: Wrap your minimum and maximum in xmin and xmax call in geom_rect section: CODE BELOW FOR OTHERS TO USE I created three data lines … Read more
You can’t do this I’m afraid, well, not with update.packages(). You need to call install.packages(“R2jags”) instead. You can’t install R2jags in the current session because you have already loaded the current version into the session. If you need to, save any objects you can’t easily recreate, and quit out of R. Then start a new R session, immediately run install.packages(“R2jags”), then … Read more
Here’s a one-liner that removes all objects except for functions: It uses setdiff to find the subset of objects in the global environment (as returned by ls()) that don’t have mode function (as returned by lsf.str())
The reason why you are getting this warning is in the description of fun.aggregate (see ?dcast): aggregation function needed if variables do not identify a single observation for each output cell. Defaults to length (with a message) if needed but not specified So, an aggregation function is needed when there is more than one value for one spot … Read more