similar to: Equivalent of 'first.var' or 'last.var' from SAS in R?

Displaying 20 results from an estimated 5000 matches similar to: "Equivalent of 'first.var' or 'last.var' from SAS in R?"

2017 Jun 26
2
Odd behaviour in within.list() when deleting 2+ variables
The behaviour of within() with list input changes if you delete 2 or more variables, compared to deleting one: l <- list(x=1, y=2, z=3) within(l, { rm(z) }) #$x #[1] 1 # #$y #[1] 2 within(l, { rm(y) rm(z) }) #$x #[1] 1 # #$y #NULL # #$z #NULL When 2 or more variables are deleted, the list entries are instead set to NULL. Is this intended?
2017 Jun 26
2
Odd behaviour in within.list() when deleting 2+ variables
>>>>> peter dalgaard <pdalgd at gmail.com> >>>>> on Mon, 26 Jun 2017 13:43:28 +0200 writes: > This seems to be due to changes made by Martin Maechler in > 2008. Presumably this fixed something, but it escapes my > memory. Yes: The change set (svn -c46441) also contains the following NEWS entry BUG FIXES o
2008 Sep 24
2
print.data.frame : row.name = FALSE not having intended effect
Hi, Does anybody know if row.name = FALSE actually works in v2.6.2? Because it isn't working for me... here is some sample code and output: ====+====+====+====+====+====+====+====+====+====+ > print(x,row.names = FALSE) party_abbr candidate_name votes_candidate 2 DFL AMY KLOBUCHAR 1,278,849 5 R MARK KENNEDY 835,653 4 IP
2008 Sep 26
3
Newbie: Ranking a data frame, grouped by 2 or more columns
Hi, I'd like to rank obs in a data frame as subset by 2 or more columns... The example input would look like the following: ====+====+====+====+ x y v -- -- -- a w 200 a w 100 b w 500 b w 200 b z 300 b z 400 ====+====+====+====+ And the data frame I want to create is below: ====+====+====+====+ x y v rank -- -- -- ---- a w 200 1 a w 100 2
2008 Sep 23
1
Newbie: Formatting numbers with commas
Hi, Search through the R archives, and couldn't find my answer... how do you format numbers with commas (standard American, one every three digits)? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas
2008 Sep 22
1
Hmisc and Ubuntu (aptitude install)
Hi, I'm trying to get the Hmisc module on my Ubuntu Hardy Heron install. I tried getting Hmisc from within R by issuing the standard 'install.packages' command, but it said I needed 'gfortran' to compile. I thought I could circumvent this by using 'aptitude' to get the package 'r-cran-hmisc', but when I got it, the package had critical missing parts (got
2008 Sep 12
2
Newbie: 'table' output in columns rather than matrix
Hi, Coming to R from SAS... I have a data.frame A with 2 long factors "x" and "y". I want to get a count of the number of rows with each level of "x" and "y" jointly. 'table' seemed like it would work, but as I have many levels, the matrix output is pretty useless to me (and I don't care about zero values). How can I get output that looks
2011 Jan 18
3
tips for looping over a category for beginner
hello, I am very new to R. My current data set is a mix of values and categories. It is a geoscience data set, with values per rock sample. Case in point, each sample belongs to a lithology class, and each sample has several physical property measurements (density, porosity...). I want to be able to plot these physical properties for all samples in each lithology class. this is how i'm doing
2007 Sep 16
1
Identifying objects from a data set
Hello Given the following data for a data set called airquality. To identify the nature of the objects from the data set airquality example "Ozone" would it be best to use the command is. like is.character(airquality$Ozone) ....... I tried attributes(airquality$Ozone) but it came up null. Would there be a better way to identify these objects. Thanking you in advance for your
2008 Dec 02
4
Bug in "transform"?
Dear useRs, Here is a weird behavior of transform function: mtcars1<-matcars transform(mtcars1,t1=3,t2=4) Error in data.frame(`_data`, e[!matched]) : arguments imply differing number of rows: 32, 1 instead, this works: mtcars1$t1<-0 transform(mtcars1,t1=3,t2=4) also works if applied in turn: transform(mtcars1,t1=3) transform(mtcars1,t2=4) I often need to use this
2008 May 05
4
Column renaming
Dear all, Is there a less cumbersome way to rename a column by name (as opposed to index) than -- names( X)[ names[ X] == "bob"]<-"sue" ? A semi-related question: how does one get the index of a column by name, something along the lines of col.index( X, "sue") ? Chip Barnaby --------------------------------------------------------- Chip Barnaby
2005 Jul 01
2
Simple indexing conundrum
My apologies in advance for my thickness but I can't seem to solve the following, seemingly simple, data manipulation problem: I have a data frame that contains multiple factors and multiple continuous response variables, but duplicates of some factor combinations. The duplicates contain bad data, so I would like to eliminate the duplicates. I would like to retain the entire rows
2018 Apr 22
3
How to dynamically add variables to a dataframe
Hi, I am a bit rusty with R programming and do not seem to find a solution to add a number of variables to my existing dataframe. Basically I need to add n=dim(d1)[1] variables to my d0 dataframe and I would like them to be named V1, V2, V3, ... , V[dim(d1)[1]) When running the following code: for (t in 1:dim(d1)[1]){ d0$V[t] <- 0 } all I get is a V variable populated with zeros... I am
2001 Mar 22
1
two easy questions...
Hi all. 1) If I have a dataframe with variable names as follow: PC1 PC2 ... PCn and I want to pass only some of them to a function, e.g. glm(resp~from PC1 to PC10, PC15, etc.,...) is there a faster way than simply writing each variable name in the formula? 2) Again, I have a dataframe, say ali.df, with tha following variables: ali1, ali2, ...ali78 I want to sum, for example, ali1+al2+ali7+f rom
2008 Dec 23
3
Using transform to add a date column to a dataframe
I would like to add a column to the airquality dataset that contains the date 1950-01-01 in each row. This method does not appear to work: > attach(airquality) > data1 <- transform(airquality,Date=as.Date("1950-01-01")) Error in data.frame(list(Ozone = c(41L, 36L, 12L, 18L, NA, 28L, 23L, 19L, : arguments imply differing number of rows: 153, 1 I can't decipher what
2008 Mar 24
2
Newbie help with Sweave
I think I've gotten my Emacs/Sweave/R system set up correctly, thanks to Vincent and Jim, but I haven't been successful getting my first document produced. I'm trying to use one of Friedrich Leisch's examples, http://www.ci.tuwien.ac.at/~leisch/Sweave/example-1.Snw. I cut and pasted the text into a document sweaveexample.Rnw in Emacs. It seemed to be processed successfully with R:
2010 Jan 24
2
How to define degree=1 in mgcv
Hi, all I have a question on mgcv and ns. Now I want to compare the results from glm, gam and ns. Take a simple model y~x for example. glm1 = glm(y~x, data=data1) gam1 = gam(y~s(x), data=data1) ns1 = glm(y~ns(x),data=data1) In order to confirm the result from glm1 is consistent to those from gam1 and ns1, I want to define degree=1 in mgcv and ns. I am wondering if there is somebody can give me
2010 Nov 11
4
Troubleshooting sweave
Hi All, I've reproduced the example from Prof. Friedrich Leisch's webpage. When I write sweave("Example-1.Snw") OR sweave("Example-1.Rnw"), (yes, I renamed them). I get the following error: Writing to file example-1.tex Processing code chunks ... 1 : echo term verbatim Error: chunk 1 Error in library(ctest) : there is no package called 'ctest' Also while
2017 Apr 12
3
"table(droplevels(aq)$Month)" in manual page of droplevels
The last line of the example in droplevels' manual page seems to be incorrect to me. I think it should read: "table(droplevels(aq$Month))". Amazingly (I don't understand) both variants seem to produce the same result (R 3.3.3): --- > aq <- transform(airquality, Month = factor(Month, labels = month.abb[5:9])) > aq <- subset(aq, Month != "Jul") >
2006 Jan 29
1
What does this command "~" mean?
Hi all, I am reading books and tutorials about R. I don't understand the following: plot(salary~rank, data=salary) plot(Ozone~date, data=airquality) I don't understand what does "~" here, and how can plot() have a input argument called "data"... I have looked it up in "plot"'s help but I could not find about argument "data". Could you please