Displaying 20 results from an estimated 7000 matches similar to: "removing observations"
2017 Dec 04
3
Dynamic reference, right-hand side of function
Hi!
Thanks for the replies!
I understand people more accustomed to R doesn't like looping much, and that thinking about loops is something I do since I worked with Stata a lot. The syntax from Peter Dalgaard was really clever, and I learned a lot from it, even though it didn't solve my problem (I guess it wasn't very well explained). My problem was basically that I have a data matrix
2017 Dec 04
3
Dynamic reference, right-hand side of function
Hi R-users!
Being new to R, and a fairly advanced Stata-user, I guess part of my problem is that my mindset (and probably my language as well) is wrong. Anyway, I have what I guess is a rather simple problem, that I now without success spent days trying to solve.
I have a bunch of datasets imported from Stata that is labelled aa_2000 aa_2001 aa_2002, etc. Each dataset is imported as a matrix, and
2017 Dec 04
0
Dynamic reference, right-hand side of function
The generic rule is that R is not a macro language, so looping of names of things gets awkward. It is usually easier to use compound objects like lists and iterate over them. E.g.
datanames <- paste0("aa_", 2000:2007)
datalist <- lapply(datanames, get)
names(datalist) <- datanames
col1 <- lapply(datalist, "[[", 1)
colnum <- lapply(col1, as.numeric)
(The 2nd
2017 Dec 04
2
Dynamic reference, right-hand side of function
:-)
I don't insist on anything, I'm just struggling to learn a new language and partly a new way of thinking, and I really appreciate the corrections. I hope I someday will be able to handle lists in R as easy as I handle loops in Stata...
Thanks again!
Love
-----Ursprungligt meddelande-----
Fr?n: peter dalgaard [mailto:pdalgd at gmail.com]
Skickat: den 4 december 2017 23:09
Till:
2017 Dec 04
0
Dynamic reference, right-hand side of function
Um, if you insist on doing it that way, at least use
assign(varname, as.vector(get(varname)))
-pd
> On 4 Dec 2017, at 22:46 , Love Bohman <love.bohman at sociology.su.se> wrote:
>
> Hi!
> Thanks for the replies!
> I understand people more accustomed to R doesn't like looping much, and that thinking about loops is something I do since I worked with Stata a lot. The
2017 Dec 05
3
Dynamic reference, right-hand side of function
Hi again!
I know you don't find loops evil (well, at least not diabolic :-) ). (After many hours googling I have realized that thinking about loops rather than lists is a newbie thing we Stata-users do, I just jokingly pointed it out). Anyway, I'm really happy that you try to teach me some R-manners. Since I still get questions about what the h**k I mean by my strange question, I sort it
2017 Dec 04
0
Dynamic reference, right-hand side of function
Loops are not evil, and no-one in this thread said they are. But I
believe your failure to provide a reproducible example is creating
confusion, since you may be using words that mean one thing to you and
something else to the readers here.
################################
# A reproducible example includes a tiny set of sample data
# Since we cannot reproducibly refer to filenames (your
2017 Dec 05
0
Dynamic reference, right-hand side of function
By the way, R 'vectors' are not the equivalents of mathematical 'vectors'.
In R, a vector is something that can have arbitrary length and which has
no 'attributes', other than perhaps element names. Vectors can be numeric,
character,
complex, lists, etc. Functions, names, and NULL are not vectors. In my
opinion,
the typical data scientist will rarely find the R vector
2012 Feb 21
3
Plot Many Data to same plot
Dear all,
I have a function that for a variable number of inputs plots them to the same plot
I am doing this quite simply by
plot(seq(from=start, to=stop, length.out=np), datalist[[1]]$dataset
xlim=c(start, stop), ylim=c(0, 1), type="l")
2008 Dec 16
2
Problem assigning "NA" as a level name in a list
I want to generate a list (called "dataList" below) where each of its
levels is named. These names are assigned to nameList, which contains
all possible permutations of size two taking letters from a larger
alphabet, e.g., "aa",...,"Fd",..,"Z1",... One of these permutations is
the character string "NA". It seems that when I try to name one
2007 Dec 20
1
auto named savings (pngs & data-frames)
Hello, i only got a small problem.
i try to create automatic new dataframes, or png?s. the main problem i
got is:
how can i create automatic a new name for a file (read out by simply
"for") -
i tried to use "(paste...) but theres an errormessage, about a wrong
declination. R told it is as.character, but need as.Real.
Should i use another method than "paste"?
i tried as
2012 May 22
1
confused with indexing
Dear all,
I have a code that looks like the following (I am sorry that this is not a reproducible example)
indexSkipped<-NULL
....code Skipped that might alter indexSkipped
if (length(indexSkipped)==0)
spatial_structure<-spatial_structures_from_measurements(DataList[[i]]$Lon,DataList[[i]]$Lat,meanVector)
else
2013 Feb 03
2
Compare each element of a list to a vector
Hello R-helpers,
I have a vector
x<-c(1,2,3)
and a list that contains vectors
datalist<-list(c(1,2,3),c(2,3,4),c(3,4,5),c(4,5,6))
and I would like to identify those list elements that are identical to x.
I tried
> datalist %in% x
[1] FALSE FALSE FALSE FALSE
but I am obviously using %in% incorrectly. I also tried messing around with
lapply but I can't figure out how to specify
2004 Sep 14
1
Re: datalist
Hi,
The following is a cut/paste from http://developer.r-project.org/200update.txt:
...
3) When a package is installed, all the data sets are loaded to see
what they produce. If this is undesirable (because they are
enormous, or depend on other packages that need to be installed
later, ...), add a `datalist' file to the data subdirectory as
described in `Writing R
2008 Aug 27
3
Calculating total observations based on combinations of variable values
Hello:
As someone making the move from STATA to R, I'm finding it difficult at times to perform basic tasks in R, so forgive me if I've missed an obvious and easily obtained solution to my problem. I've searched the help guides and the archives and have not been able to find a solution that works.
I have a data frame with thousands of observations that looks something like this:
2010 Jul 30
3
simple table/matrix problem
Hi
Given three vectors
x <- c(fish=3, dogs=5, bats=2)
y <- c(dogs=1, hogs=3)
z <- c(bats=3, dogs=5)
How do I create a multi-way table like the following?
> out
x y z
bats 2 0 3
dogs 5 1 5
fish 3 0 0
hogs 0 3 0
('out' is a matrix).
See how the first line shows 'x' has 2 bats, 'y' has zero bats, and 'z'
has 3 bats
and so on for each
2004 Apr 08
1
Why are Split and Tapply so slow with named vectors, why is a for loop faster than mapply
First, here's the problem I'm working on so you understand the context. I
have a data frame of travel activity characteristics with 70,000+ records.
These activities are identified by unique chain numbers. (Activities are
part of trip chains.) There are 17,500 chains.
I use the chain numbers as factors to split various data fields into lists
of chain characteristics with each element of
2006 Sep 11
3
Extracting overdispersion estimates from lmer amd glm objects
Dear list,
I am needing to extract the estimate of overdispersion (deviance / residual degrees of freedom or c-hat) from multiple model objects - so they can then be used to compare the extent of overdispersion among alternative models as well as calculate qausi-AIC values. I have been unable to do this, despite consulting a number of manuals and searching the R-help. I am imaging that in
2005 Feb 26
1
PrintUIEntry for NT4?
For Win2K, I've been using RunDLL32 printui.dll,printuientry to do a bunch
of different printer related stuff (most notably, mapping printers and
setting the default).
Looks like NT4 doesn't have the same stuff. Is there anything classier I
can use than NET USE under NT4 (without downloading something like
Kixstart)?
Thanks for your help.
---- _ _ _ _ ___ _ _ _
|Y#| | | |\/| |
2000 May 16
3
some (basic?) development questions...
Pardon my ignorance, as I just started playing with Ogg stuff a few days
ago, but I'd appreciate some help if someone has time...
I was trying to write a very basic comment editor for Ogg Vorbis files. I
think I mostly have it working, but it seems to output slightly broken
streams.
Here's a basic overview of what I'm doing; could someone tell me if I've
got the right basic