How to find out which package version is loaded in R?
You can use sessionInfo() to accomplish that. However, as per comments and the answer below, there are better options [1] ‘0.3.9’ Or:
You can use sessionInfo() to accomplish that. However, as per comments and the answer below, there are better options [1] ‘0.3.9’ Or:
You can use sapply for this: If not every column needs converting:
Here’s how I take your question, and an answer that is very close to @David Arenburg’s in the comment above. The extra space after [:punct:] is to add spaces to the string and the + matches one or more sequential items in the regular expression. This has the side effect, desirable in some cases, of … Read more
First make some data: Then select some rows at random:
I’ve been playing around with the Life Analytics trading with R tutorial (http://lifeanalytics.blogspot.com/2011/01/forex-trading-with-r-part-1.html) and keep getting stuck on a problem related to building the data model. So I start with a bunch of functions: Then try to build a model passing the data to the functions: And keep getting the following error: Error in formula.default(object, … Read more
I had the same problem. You can try to use small trick to equalize classes of training and test set. Bind the first row of training set to the test set and than delete it. For your example it should look like this:
CheckForMersennePrimes has extra {} on line 2 and line 4 (inside for loop) of this function, like vec<-MarsenneNumber(x){if()…} I removed those extra braces. I think, your intention is to get values of vec in which factorlist(vec[i]) is equal to 1. If this is true, then you have to initiate vec outside the for loop and check for this condition. Then finally return a1 which contains all vec values passing … Read more
That is R’s way of printing a zero length vector (an integer one), so you could test for a being of length 0: It might be worth rethinking the strategy you are using to identify which elements you want, but without further specific details it is difficult to suggest an alternative strategy.
Assuming you have this data frame df, see data below. First you have to transpose all data frame except the first column. The result being a matrix that we need to convert to a data frame. Finally, we assign as column names of df2the first column of the original data frame df. Output: Data:
OK, I can reproduce this from scratch, with reshape (but not with reshape2). Something is indeed getting mangled by head(). The specific problem is an interaction between utils::head.data.frame, which drops pieces of the object without keeping a completely consistent internal structure, and as.matrix.cast_df (called by matplot), which assumes that structure is there. Adding the following method seems to fix the problem. It might … Read more