Displaying 20 results from an estimated 6000 matches similar to: "Sum list elements"
2011 Dec 15
4
Undocumented functions
Hi!
I am building a package. This package will not submitted to CRAN.
I write the help files for the most important functions of my package, I
cannot write it for all functions. This may sounds strange, but so there!
I know that all user-level functions should be documented, so I have to
move my undocumented functions to a non-user-level. It's right?
To move my functions to a
2010 Sep 28
2
Table with different digit number
Hi!
I have a table representing both absolute and relative frequency, for
example (code to get example data under the signature):
Italy Germany
absolute 100 105
relative 40.51 41.18
How can I print a different number of decimal digits? I try to transform to
as.character, but cells result aligned to left and I don't like this
solution. At the
2010 Nov 02
5
density() function: differences with S-PLUS
Hello!
Someone know what are the difference between R and S-PLUS in the density()
function?
For example, I would like to reply this simple S-PLUS code in R, but I don't
understand which parameter I should modify to get the same results.
S-PLUS CODE:
density(1:1000, width = 4)
R-CODE:
density(1:1000, bw = 4, window = "g", n = 50, cut = 0.75)
I obtain the same x values, but
2010 Mar 25
1
Read SAS data
Hi!
I need to import in R some SAS dataset (sas7bdat). I found two functions to
do it:
"read.ssd" from the package "foreign" and "sas.get" from "Hmisc".
df = read.ssd(libname = path2data, sectionnames = "sasSmallDataset",
tmpXport = path2data, tmpProgLoc = path2data, sascmd = path2sas)
sas.get(libraryName = path2data, member =
2011 Oct 18
1
avoid s3 methods
Hello everybody.
My issue arise when I build a package with my functions. This package is for
personal purposes only and it will not submitted to CRAN.
Anyway, this may be an opportunity for myself to clear the S3 methods
concept. I read the R manual and some books about R programming but they are
usually S4 oriented.
I call a function plot.days(). When I check the package I obtain some
2010 Jul 29
1
Different decimal places in a matrix
Hi!
I have a ftable object in which some row contains integers and some other
contains a percentage that I would like to show with two digits after the
dot.
I tried something like ftblP[index,] = as.character(round(ftblP[index, ],
2)) where the index vector contains the number of the rows containing a
percentage. My workaround works but it shows all numbers aligned to left,
while I prefer that
2011 Nov 22
1
Compile R package under Windows
Hi.
I need to compile an R package under Windows, to get a zip file.
I can't used the web services, because it is avalaible only for the current
version of R while I need of a package compiled with R 2.13.1.
The package contain C code that requires the GSL C library.
In your experience, what is the best way to compile an R library? I read
the R manuals, now I need some tricks with
2010 Nov 03
1
smooth: differences between R and S-PLUS
Hi!
I am studying differences between R and S-PLUS smooth() functions. I know
from the help that they worked differently, so I ask:
- exist a package that permit to have the same results?
- alternatively, someone know how can I obtain the same results in R, using
a self made script?
I know that S-PLUS use the 4(3RSR)2H running median smoothing and I try to
implement it with the code below. I
2009 Oct 25
3
NULL elements in lists ... a nightmare
I can define a list containing NULL elements:
> myList <- list("aaa",NULL,TRUE)
> names(myList) <- c("first","second","third")
> myList
$first
[1] "aaa"
$second
NULL
$third
[1] TRUE
> length(myList)
[1] 3
However, if I assign NULL to any of the list element then such
element is deleted from the list:
> myList$second <-
2011 May 25
3
Accessing elements of a list
I have a list that is made of lists of varying length. I wish to create a
new vector that contains the last element of each list. So far I have used
sapply to determine the length of each list, but I'm stymied at the part
where I index the list to make a new vector containing only the last item
of each list
mylist =
2011 Sep 29
1
multiplying list with vector
hello everybody,
i have got a question about lists:
i have got the following commands:
mylist <- list("v1"=c(1,2,2,1),"v2"=c(2,2,2,1),"v3"=c(1,1,1,1))
myvector <- c(100,10000,1000000)
now i would like to multiply each element of the list with the corresponding
element of the vector, that is to say:
v1*100
v2*10000
v3*1000000
i only could think of lapply
2013 Feb 12
3
grabbing from elements of a list without a loop
Hello!
# I have a list with several data frames:
mylist<-list(data.frame(a=1:2,b=2:3),
data.frame(a=3:4,b=5:6),data.frame(a=7:8,b=9:10))
(mylist)
# I want to grab only one specific column from each list element
neededcolumns<-c(1,2,0) # number of the column I need from each element of
the list
# Below, I am doing it using a loop:
newlist<-NULL
for(i in 1:length(mylist) ) {
2013 Apr 29
3
rbinding some elements from a list and obtain another list
Hi everybody,
I have a list, where every element of this list is a data frame.
An example:
Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)
I want to rbind some elements of this list.
As an example:
Output<-list(AB=data.frame, CD=data.frame)
Where
AB=rbind(A,B)
CD=rbind(C,D)
I’ve tried:
f<-function(x){
for (i in
2010 Apr 05
1
Deleting many list elements in one time
Hi guys, here is a simple thing I want to do but it doesn't work:
I have a vector of the element indexes that I want to delete called index
so when I write myList[[index]] <- NULL to delete these elements here is
what I get:
Error in myList[[index]] <- NULL :
more elements supplied than there are to replace
Isn't it possible to delete multiple elements?
-----
Anna Lippel
--
2012 Dec 26
1
Change class of elements in list
Dear R users,
I have a list of objects of type "im"
> mylist$sp1
$sp2
$sp3
and I want to convert them to a list of objects of class "SpatialGridDataFrame"
This works for a single object of class "im":
a <- mylist$sp1
b <- as(a, "SpatialGridDataFrame")
Then I want to write each element in the new list as a TIFF file, with the name of the elements
2006 Feb 17
1
extracting a element with a name attribute from a list
Hi R users
I like to extract (or collect) a numeric element with a name from a list.
Is there any way to extract just a numeric element without the name attached
to the element.
For example,
>mylist
Mantel-Haenszel chi-squared test with continuity correction
data: table(mydata[, x])
Mantel-Haenszel X-squared = 8.3832, df = 1, p-value = 0.003787
alternative hypothesis: true
2005 Mar 16
8
Summing up matrices in a list
Dear all,
I think that my question is very simple but I failed to solve it.
I have a list which elements are matrices like this:
>mylist
[[1]]
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
[[2]]
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 8 10 12
I'd like to create a matrix M<-mylist[[1]]+mylist[[2]]
[,1] [,2] [,3]
[1,] 8 12 16
[2,] 10 14 18
2015 May 04
2
Define replacement functions
Hello
I tried to define replacement functions for the class "mylist". When I test them in an active R session, they work -- however, when I put them into a package, they don't. Why and how to fix?
make_my_list <- function( x, y ) {
return(structure(list(x, y, class="mylist")))
}
mylist <- make_my_list(1:4, letters[3:7])
mylist
mylist[['x']] <- 4:6
2011 Jan 15
3
get list element names within lapply / sapply call
Hi all,
I would like to iterate through a list with named elements and access the
names within an lapply / sapply call. One way to do this is iterate through
the names and index the list with the name. Is there a way to iterate
through the list elements themselves and access the element names within in
the function? For example,
mylist <-
2007 Oct 20
1
Getting at what a named object represents in a function...
Hi,
I'm pretty new to R.
I have an object (say a list) and I I have a function that I call on
various columns in that list (excuse terminology if it's wrong/ambiguous).
Imagine its like this (actual values are unimportant) and called mylist:
>mylist
A B
1 5
2 5
3 6 4 8
5 0
I have a function:
foo = function(param){
#modify list A or B values depending on