Displaying 8 results from an estimated 8 matches for "mauriciocornejo".
2012 Mar 30
1
How to use access results of gregexpr in data frames
Hello,
I'm trying to figure out how to find the index of the second occurrence of "/" in a string (which happens to represent a date) within a data frame column.
I've used the following code successfully to find the first instance of "/".
dframe <- data.frame(date=c("5/14/2011", "4/7/2011"))
dframe$x1 <- regexpr("/", dframe[, 1])
2011 Aug 16
2
How to use 'switch' with strings containing spaces?
Hi,
Does anyone know if the alternatives in the 'switch' function can be specified as strings containing spaces? Neither of the two approaches below works.
switch(expr, "Choice 1"="My first choice", "Choice 2"="My 2nd choice", "Choice 3"="My 3rd choice")
x <- c("Choice 1", "Choice 2", "Choice
2012 Nov 21
3
Problems understanding use of regular expression (in gsub) for manipulating currency
Hello,
After reading help file, various threads on this board, and other online tutorials, I've attempted to use gsub (using Perl-like syntax) to change a currency string into something that can be converted to numeric type using only one regular expression. Can anybody point out my error? Note that
> x <- "\"$ 1,200,300,400.50\""
Tried the following in an
2011 Sep 14
1
Can 'mosaic' be used with a continuous variable?
Hello,
I'm wondering if the 'mosaic' plot of the vcd package (or any other function for that matter) can be used with a continuous variable that should be represented via various categorical variables. All the documentation I've read lead me to believe that it only works with counts of categories.
Alternatively, I've thought of first creating a contingency table where the
2012 Dec 03
0
switch() vs eval() for choosing pre-existing alternatives?
Can anyone explain (perhaps with an example) why the R Language Definitions (Version 2.15.2, 2012-10-26, DRAFT) says the following in section 3.2.6?
"To choose from a list of alternatives that already exists switch() may not be the best way to select one for evaluation. It is often better to use eval() and the subset operator, [[, directly via eval(x[[condition]])."
I can't quite
2012 Dec 15
1
How to limit string size when displaying data frames?
Hello,
Is there a way to set the maximum width of character columns when printing a data frame?
I've looked into print(), format(), and options() and have been unsuccessful.
For example, I'd like to achieve the results below without having to modify the data itself.
> x <- data.frame(c1=rnorm(5), c2="ABCDEFGHIJKLMNOPQRSTUVWXYZ")
> x
c1 c2
1
2011 Jun 09
3
How to subset based on column name that is a number ?
Hi,
I have a data frame with column names "1", "2", "3", ... and I'd like to extract
a subset based on the values in the first column. None of the methods I tried
worked (below).
x <- subset(dframe, 1 = = "My Text")
x <- subset(dframe, "1" = = "My Text")
x <- subset(dframe, names(dframe)[1] = = "My Text")
Q
2012 Aug 27
2
Inexplicably different results using subset vs bracket notation on logical variable
Hi,
Would anyone have any idea as to why I would obtain completely different results when subsetting using the subset function vs bracket notation?
I have a data frame with 65 variables and 4382 rows. When I use execute the following subset command I get the correct results (125 rows)
> subset(df, Renewal==TRUE, 1:2)
However, I tried to obtain the same results with bracket notation as