similar to: Is there a quicker way to drop a data frame column than setting it to NULL?

Displaying 20 results from an estimated 20000 matches similar to: "Is there a quicker way to drop a data frame column than setting it to NULL?"

2007 Oct 21
6
exporting text output to pdf
Hello, I am new to R and I am trying to figure out how to print text output from an operation like table() to a pdf file. Is there a simple command to do this, or do you need to work with connections at a rudimentary level? Thanks you, Jesse [[alternative HTML version deleted]]
2010 Aug 26
5
Quick GREP challenge
> grep("f[0-9]+=", "f1=5,f22=3,", value = T) [1] "f1=5,f22=3," How do I make the line output c("f1", "f22") instead? (Actually, c(1,22) would be even better). Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Quick-GREP-challenge-tp2339486p2339486.html Sent from the R help mailing list archive at Nabble.com.
2010 Feb 21
2
Newbie woes with par:mar
I have a simple barchart with horizontal bars and horizontal tick labels, produced with barplot(x, horiz = T, names.arg = c, las = 1) The labels are longish strings, truncated on the plot. I wish to leave more space for the left margin, and experiment with mar parameter, barplot(x, horiz = T, names.arg = c, las = 1, mar = c(5, 15, 4, 2)) trying various values for the second vector element, but
2010 Sep 06
3
Failure to aggregate
I have a (very big - 1.5 rows) dataframe with a (POSIXt" "POSIXlt") column h (hour). Surprisingly, I cannot calculate a simple aggregate over the dataframe. > n.h1 = sqldf("select distinct h, count(*) from x group by h") Error in sqliteExecStatement(con, statement, bind.data) : RS-DBI driver: (error in statement: no such table: x) In addition: Warning message: In
2010 Jan 23
3
How to implement a "select distinct x, count(distinct y) ... group by x" for a data frame
... Being an R newbie, I can only think of extracting distinct x values with unique, looping over them, extracting matching rows from the original data frame, applying table, and recording the size of table's output alongside the x value being checked. Is there a more elegant way? Thank you. -- View this message in context:
2010 Jan 30
2
Applying a transformation to multiple data frame columns
How can one simplify the folowing? t$aum[is.na(t$aum)] = 0; t$aum.core[is.na(t$aum.core)] = 0 t$num[is.na(t$num)] = 0; t$num.core[is.na(t$num.core)] = 0 Thank you. -- View this message in context: http://n4.nabble.com/Applying-a-transformation-to-multiple-data-frame-columns-tp1457641p1457641.html Sent from the R help mailing list archive at Nabble.com.
2010 Feb 14
4
Newbie woes with *apply
Dataframe cust has Date-type column open.date. I wish to set up another column, with (first day of) the quarter of open.date. To be comprehensive (of course, improvement suggestions are welcome), month = function(date) { return(as.numeric(format(date,"%m"))) } first.day.of.month = function(date) { return(date + 1 - as.numeric(format(date,"%d"))) } first.day.of.quarter =
2010 Apr 28
2
How to read contents of a text file into a single string?
... Both readLines() and scan() produce a number_of_lines x 1 vector; trying paste(s, collapse = NULL) leaves it unaffected. How can I concatenate vector elements (lines) into a single string? Thank you. -- View this message in context: http://r.789695.n4.nabble.com/How-to-read-contents-of-a-text-file-into-a-single-string-tp2069303p2069303.html Sent from the R help mailing list archive at
2010 Dec 25
1
Extracting a dataframe column as a dataframe
> x = structure(list(time = structure(c(1020232904.818, 1020232904.818 ), class = c("POSIXt", "POSIXct"), tzone = ""), price = c(321, 323.5)), .Names = c("time", "price"), row.names = 1:2, class = "data.frame") > x1 = x[,c("price")] > dput(x1) c(321, 323.5) Is there similar syntax that gets "price" as a
2010 Feb 14
2
Problems with boxplot in ggplot2:qplot
Dataframe closed contains balances of closed accounts: each row has month of closure (Date-type column month) and latest balance. I would like to plot by-month distributions of balances. A qplot call below produces several warnings and no output. Can anyone help? Thank you. PS. A really basic task, very similar to the examples on p. 71 of the ggplot2 book, apart from a Date grouping column; I
2010 Dec 27
1
Can't merge on datetime?
x = structure(list(date = structure(list(sec = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), min = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), hour = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), mday = c(1L, 2L, 3L, 4L, 5L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 17L, 18L, 19L, 22L, 23L, 24L,
2010 Feb 02
1
[R] Suppressing scientific notation on plot axis tick labels (PR#14202)
On 02/02/2010 6:20 AM, Dimitri Shvorob wrote: > Ruben Roa has kindly suggested using 'scipen' option - cf. > >> fixed notation will be preferred unless it is more than ???scipen??? digits >> wider. > > However, > > options(scipen = 50) > x = c(1e7, 2e7) > barplot(x) > > still does not produce the desired result. This is strange. I see what
2013 Mar 14
2
Modifying a data frame based on a vector that contains column numbers
Hello! # I have a data frame: mydf<-data.frame(c1=rep(NA,5),c2=rep(NA,5),c3=rep(NA,5)) # I have an index whose length is always the same as nrow(mydf): myindex<-c(1,2,3,2,1) # I need c1 to have 1s in rows 1 and 5 (based on the information in myindex) # I need c2 to have 1s in rows 2 and 4 (also based on myindex) # I need c3 to have 1 in row 3 # In other words, I am trying to achieve this
2006 Apr 24
1
omitting coefficients in summary.lm()
Hi, I'm running a regression using lm(), in which one of the right-hand side variables is factor with many levels (say, 80). I am not intersted in the estimates of the resulting dummies, but I have to include them in my regression equation. So, I don't want the estimates associated with theses dummies to be printed by summary.lm( ). Is there an easy way to do this? Thank you, Dimitri
2010 May 24
2
adding one line to a plot
Hello! I am running a very simple mini Monte-Carlo below using the function tstatistic (right below this sentence): tstatistic = function(x,y){ m=length(x) n=length(y) sp=sqrt( ((m-1)*sd(x)^2 + (n-1)*sd(y)^2)/(m+n-2) ) t=(mean(x)-mean(y))/(sp*sqrt(1/m+1/n)) return(t) } alpha=.1; m=10; n=10 # sets alpha, m, n - for run 1 N=10000 # sets the number of simulations n.reject=0 # counter of num.
2010 Oct 27
4
One silly question about "tapply output"
Dear R helpers I have a data which gives Month-wise and Rating-wise Rates. So the input file is something like month           rating           rate January        AAA             9.04 February      AAA             9.07 .......................................... .......................................... Decemeber     AAA            8.97  January           BBB           11.15 February        
2010 Apr 30
1
Trouble using Ecdf () from the Hmisc library
Hello: [Kindly Cc when replying] The question in a nutshell is this: Is there a more robust alternative to Ecdf ()? The details: I've used Ecdf () _a lot_ over the past few years and I have learned to live with its warnings. But I am running short on time and patience now [*] Here is a reproducible example: > library (Hmisc) > x <- read.csv ( file =
2013 Jun 08
1
splitting a string column into multiple columns faster
Hello! I have a column in my data frame that I have to split: I have to distill the numbers from the text. Below is my example and my solution. x<-data.frame(x=c("aaa1_bbb1_ccc3","aaa2_bbb3_ccc2","aaa3_bbb2_ccc1")) x library(stringr) out<-as.data.frame(str_split_fixed(x$x,"aaa",2)) out2<-as.data.frame(str_split_fixed(out$V2,"_bbb",2))
2009 Mar 26
2
Analogy for %in% for the whole columns (rather than individual values)
Hello! I have a matrix a with 2 variables (see below) that contain character strings. I need to create a 3rd variable that contains True if the value in column x is equal to the value in column y. The code below does it. a<-data.frame(x=c("john", "mary", "mary", "john"),y=c("mary","mary","john","john"))
2010 Aug 04
6
applying strsplit to a whole column
I am sorry, I'd like to split my column ("names") such that all the beginning of a string ("X..") is gone and only the rest of the text is left. x<-data.frame(names=c("X..aba","X..abb","X..abc","X..abd")) x$names<-as.character(x$names) (x) str(x) Can't figure out how to apply strsplit in this situation - without using a