similar to: Assigning variable value as name to cbind column

Displaying 20 results from an estimated 20000 matches similar to: "Assigning variable value as name to cbind column"

2010 May 06
3
Intersection list
How can I create intersections of vectors? a <- c(1,2,3) b <- c(1,5,6) the intersected list c should contain c(1)... Ralf
2010 Aug 04
4
Adding collumn to existing data frame
Hi experts, I am trying to write a very flexible method that allows me to add a new column to an existing data frame. This is what I have so far: add.column <- function(df, new.col, name) { n.row <- dim(df)[1] length(new.col) <- n.row names(new.col) <- name return(cbind(df, new.col)) } df <- NULL df <- data.frame(a=c(1,2,3)) df # corect: added NA to new collumn df <-
2010 Oct 06
5
Create variable by name
Can one create a variable through a function by name createVariable <- function(name) { outputVariable = name name <- NULL } after calling createVariable("myVar") I would like to have a variable myVar initialized with NULL in my environment. Is this possible? Ralf
2010 Jul 09
2
select columns from vector of column names
Hi I want to extract columns from a data frame using a vector with the desired column names. This short example uses the select argument in the subset function to accomplish what I am trying to do. Is there a better solution? #names of desired columns colnames <- c("col1","col3") #my data data <-
2010 Jun 24
8
Install package automatically if not there?
Hi fans, is it possible for a script to check if a library has been installed? I want to automatically install it if it is missing to avoid scripts to crash when running on a new machine... Ralf
2010 Jul 29
2
Reset R environment through R command
Is it possible to remove all variables in the current environment through a R command. Here is what I want: x <- 5 y < 10:20 reset() print(x) print(y) Output should be NULL for x and y, and not 5 and 10:20. Can one do that in R? Best, Ralf
2010 Mar 02
16
Three most useful R package
Hi R-fans, I would like put out a question to all R users on this list and hope it will create some feedback and discussion. 1) What are your 3 most useful R package? and 2) What R package do you still miss and why do you think it would make a useful addition? Pulling answers together for these questions will serve as a guide for new users and help people who just want to get a hint where to
2010 Feb 18
3
svm regression
Hi, I am trying to use svm for regression data. this is how my data looks like: >dataTrain x y z 1 4 6 2 5 4 3 7 5 >classTrain a 2 3 4 >dataTest x y z 1 7 2 2 8 3 >classTest a 3 4 5 building the model model<-svm(dataTrain,classTrain,type="nu-regression") pred <- predict(model, dataTest) > pred 1 2 3.008842 3.120078 I
2010 Sep 21
5
Combined plot: Scatter + density plot
Hi, in order to save space for a publication, it would be nice to have a combined scatter and density plot similar to what is shows on http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=78 I wonder if anybody perhaps has already developed code for this and is willing to share. This is the reproducible code for the histogram version obtained from the site: def.par <-
2010 Nov 15
1
Sweave: Conditional code chunks?
I have a code junk that produces a figure. In my special case, however, data does not always exist. In cases where data exists, the code chunk is of course trival (case #1), however, what do I do for case # 2 where the data does not exist? I can obviously prevent the code from being executed by checking the existence of the object x, but on the Sweave level I have a static figure chunk. Here an
2010 Aug 04
3
Output (graphics and table/text)
Hi R Users, I need to produce a simple report consisting of some graphs and a statistic. Here simplification of it: # graphics output test a <- c(1,3,2,1,4) b <- c(2,1,1,1,2) c <- c(4,7,2,4,5) d <- rnorm(500) e <- rnorm(600) op <- par(mfrow=c(3,2)) pie(a) pie(b) pie(c) text(ks.test(d,e)) obviously, the ks.test does not make it to the output. How can this be archived by a)
2018 Nov 27
1
Subsetting row in single column matrix drops names in resulting vector
Dmitriy Selivanov (selivanov.dmitriy at gmail.com) wrote: > Consider following example: > > a = matrix(1:2, nrow = 2, dimnames = list(c("row1", "row2"), c("col1"))) > a[1, ] > # 1 > > It returns *unnamed* vector `1` where I would expect named vector. In fact > it returns named vector when number of columns is > 1. > Same issue applicable
2010 Jul 09
1
select columns from dataframe
Hi, I would like to extract columns from a dataframe using a vector of desired column names. The following working example uses the select argument in the subset function to accomplish what I am trying to do. Is there a better solution? Thanks. #my data data <- data.frame("col1"=c(1,2,3),"col2"=c("A","B","C"),"col3"=c(4,5,6))
2010 Jul 24
2
union data in column
Is there any function/way to merge/unite the following data GENEID col1 col2 col3 col4 G234064 1 0 0 0 G234064 1 0 0 0 G234064 1 0 0 0 G234064 0 1
2007 Mar 27
1
gam parameter predictions --Sorry for double posting
R-help, Sorry for posting again the same question (dated 26-03-2007) but all my mails have been sent to the recycle bin without possibility of recovering and thus I don't know if anyone has answer my query. Here is the original message: I'm applying a gam model (package mgcv) to predict relative abundances of a fish species. The covariates are year, month, vessel and statistical
2010 Jul 29
3
Statistical mailing list
I am looking for a mailing list for general statistical questions that are not R related. Do you have any suggestions for lists that are busy and helpful and/or lists that you use and recommend? Thanks in advance, Ralf
2011 Jan 17
2
data frame column name change
How do I change the name of one column in a data frame ? Suppose I have a data frame x with 5 columns. If the names were date, col1, col2, col3, col4 and I wanted to simply change the name of date, what would the command be ? I tried the following and it didn't seem to work : names(x[1]) <- "newname" Thanks in advance for the comments -- View this message in context:
2010 Sep 22
3
Extracting bins and frequencies from frequency table
Dear R users, I would like to great a frequency table from raw data and then access the classes/bins and their respective frequencies separately. Here the code to create the frequency tables: x1 <- c(1,5,1,1,2,2,3,4,5,3,2,3,6,4,3,8) t1 <- table(x1) print(t1[1]) Its easy to plot this, but how do I actually access the frequencies alone and the bins alone? Basically I am looking to get:
2010 Oct 06
3
Source awareness?
Here the general (perhaps silly question) first: Is it possible for a script to find out if it was sourced by another script or run directly? Here a small example with two scripts: # script A print ("This is script A") # script B source("C:/scriptA.R") print ("This is script B") I would like to modify script A in a way so that it only outputs 'This is script
2007 Jan 06
2
Get column value of col1 .. col10
Hi, I have a table with column name like col1, col2, col3, col4 ... col10. In rails, after I get the instance of the class, I would like to use a for loop to retrieve values from these columns and put them into a hash. The hash will be used for another find call. Is that possible? Thanks. Arnold -- Posted via http://www.ruby-forum.com/.