similar to: Pass character vector to function argument

Displaying 20 results from an estimated 6000 matches similar to: "Pass character vector to function argument"

2010 May 20
1
use object within rda file in for loop
Dear users, I would like to process all the lists from all *.rda files that I have in one folder. Up to now, I can load all the *.rda files without any problem. The problem is when I want to access the list saved within each *.rda file (only one list per rda file). Here is my code: fpath <- "D:/R" listnames <- list.files(path=fpath, pattern=glob2rx("*.rda"),
2008 Mar 03
3
looping through data frames in a workspace
All, I have a workspace containing only data frame objects. I would like to loop though each one and clean-up text columns in them. How can I have R loop through the list? I have tried to find an answer in R help but the closest solution I can find is to make a static list of data frames, as illustrated in this recent post: ---------begin post On Tuesday 19 February 2008 (19:51:15), TLowe wrote:
2010 May 20
6
writing function
Dear group, I am trying to write functions, but as a beginner, everything is not so obvious. Let's say I want the results in a list of elemts like this : tot1, tot2, etc Here is a function: toto <- function(x,y) { for(i in x:y){ paste(c("tot",i),collapse="")<-(i*2) } } If I type this : >toto(1,5) I get this message error: Error in paste(c("tot",
2007 Jan 31
2
How to print the objects in the memory
Hi,all: May be a pointless question a <- 1:10 b <- matrix(1:8,nrow = 4) c <- letters[4:8] ???? > ls() [1] "a" "b" "c" ls() can print the names of the objects in the memory , but I want to get the result : > a [1] 1 2 3 4 5 6 7 8 9 10 > b [,1] [,2] [1,] 1 5 [2,] 2 6 [3,] 3 7 [4,] 4
2011 Jan 05
3
How to 'explode' a matrix
Hi everyone, I'm looking for a way to 'explode' a matrix like this: > matrix(1:4,2,2) [,1] [,2] [1,] 1 3 [2,] 2 4 into a matrix like this: > matrix(c(1,1,2,2,1,1,2,2,3,3,4,4,3,3,4,4),4,4) [,1] [,2] [,3] [,4] [1,] 1 1 3 3 [2,] 1 1 3 3 [3,] 2 2 4 4 [4,] 2 2 4 4 My current kludge is this:
2015 Oct 04
2
Conditional importFrom (roxygen?)
Folks: I am getting a build failure when I: #' @importFrom utils shortPathName which roxygenizes it to the NAMESPACE. I suspect this is because this particular function is Windows-only, but I'm a bit confused how I should "properly" importFrom a function like this so it doesn't cause a build failure, but I don't get a note in my R CMD CHECK if I DON'T have it:
2020 Nov 05
1
Named class vector
The source to the noquote() function looks like this: noquote <- function(obj, right = FALSE) { ## constructor for a useful "minor" class if(!inherits(obj,"noquote")) class(obj) <- c(attr(obj, "class"), if(right) c(right = "noquote") else "noquote") obj } Notice what happens with right =
1997 Aug 20
1
R-alpha: R-0.50-a3(+) Method despatching bug ?
It is very wierd... Can some of you confirm the following behavior ? It is a new bug (feature ?) which was not yet in 0.49 ... noquote <- function(obj) { ## constructor for a useful "minor" class if(!inherits(obj,"noquote")) class(obj) <- c(class(obj),"noquote") obj } "[.noquote" <- function (x, subs) structure(unclass(x)[subs], class =
2011 Jan 05
4
Match numeric vector against rows in a matrix?
Two posts in one day is not a good day...and this question seems like it should have an obvious answer: I have a matrix where rows are unique combinations of 1's and 0's: > combs=as.matrix(expand.grid(c(0,1),c(0,1))) > combs Var1 Var2 [1,] 0 0 [2,] 1 0 [3,] 0 1 [4,] 1 1 I want a single function that will give the row index containing an exact match
2010 May 19
3
save in for loop
Dear users, My problem concerns save() within a for loop. Here is my code: for (i in 1:4) { temp <- data.frame(a=(i+1):(i+10), b=LETTERS[(i+1):(i+10)]) filename <- paste("file", i, sep="") assign(filename, temp) save(filename, file=paste(filename, ".rda", sep="")) } As you can see, save() doesn't work as I would like: (1) the object
2006 Feb 20
2
glob2rx function not working
Dear R users, Inspired by previous list discussion of the glob2rxc function, I am attempting to create a new vector called TOTAL by summing all vectors whose names begin with ABC: TOTAL = sum(list = ls(pattern = glob2rx("ABC*"))) I'm running R 2.2.1 on Windows XP. Can anyone say what I'm missing? Thank you, Mark
2011 Jan 24
2
normality and equal variance testing
I currently have a program that automates 2-way ANOVA on a series of endpoints, but before the ANOVA is carried out I want the code to test the assumptions of normality and equal variance and report along with each anova result in the output file.  How can I do this? I have pasted below the code that I currently use.   library(car) numFiles = x #
2013 Mar 14
2
Grep with wildcards across multiple columns
I have a fairly large data set with six variables set up like the following dummy: # Create fake data df <- data.frame(code = c(rep(1001, 8), rep(1002, 8)), year = rep(c(rep(2011, 4), rep(2012, 4)), 2), fund = rep(c("10E", "10E", "10E", "27E"), 4), func = rep(c("110000",
2010 Mar 11
3
Help function "?" in R 2.10.1
Hello everyone, I have versions 2.7.2 and 2.10.1 installed on a machine that has no access to internet. In 2.7.2 I can use ? to get help on functions, which in 2.10.1 that does not work, all I see is "starting httpd help server...done" and then nothing. Have I downloaded 2.10.1 incorrectly (=forgot to tick some box for local help file repository) or is the internet help now the
2010 Nov 01
2
number of items to replace is not a multiple of replacement length
Hey all, I am writing a function in which I will have a matrix of 4 columns and a variable amount of rows. The first to columns will always contain be of the Character type, the third and fourth columns can be a variation of data types, usually characters and integers, but sometimes lists or matrices. At one point the code makes, for each row, a copy of that row, then it makes some adjustments
2009 Aug 11
1
Passing a list object to lapply
Hello, I'm having difficulty passing an object name to a lapply function. Can somebody tell me the trick to make this work? #Works T13702 <- TRACKDATA[["13702.xls"]][["data"]] min(unlist(lapply(list(T13702), function(x) mdy.date(x[1, 2], x[1, 1], x[1, 3])))) 16553 #Works d<-2 assign(paste("T",substr(names(TRACKDATA)[d],1,(nchar(names(TRACKDATA)[d]
2010 May 18
3
"Re: Change class factor to numeric"
sorry I had a mistake sending my question without a subject. I do resend again. Please excuse me. > Hello > I have a data array with soil variables (caperf), in which the variable "clay" is factor (as I see entering str(caperf)) . I need to do a regression model, so I need to have arcilla (=clay) as a numeric variable. For that I have entered > >
2010 Sep 21
2
labels in (box)plot
Dear users, I would like all the ticks on a boxplot (x and y) to be labeled I have checked all the par() arguments but couldn't find what I'm looking for Here is an example to show it: df <- structure(list(SPECSHOR = structure(c(1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 4L, 4L), .Label = c("cotau", "dibic", "eqgre", "gicam"), class =
2011 Aug 15
3
how can I read a xlsx file
Hello, How can I read a xlsx file using xlsx package? Thanks Albert [[alternative HTML version deleted]]
2010 May 20
2
Overlap of leaf labels
Hi, I have tried looking at the archives but havent found any answer that works till now (Sorry if i have missed anything) I am a newbie to R and i am trying to carry out hierarchical clustering using hclust -> as.dendrogram and then plotting the results as a dendrogram using the plot function plot(object). My question is : In the function "plot", can one decrease the leaf label