Displaying 20 results from an estimated 1000 matches similar to: "dplyr - add/expand rows"
2017 Nov 28
0
dplyr - add/expand rows
On 11/26/2017 08:42 PM, jim holtman wrote:
> try this:
>
> ##########################################
>
> library(dplyr)
>
> input <- tribble(
> ~station, ~from, ~to, ~record,
> "07EA001" , 1960 , 1960 , "QMS",
> "07EA001" , 1961 , 1970 , "QMC",
> "07EA001" , 1971 , 1971 ,
2017 Nov 29
0
dplyr - add/expand rows
Hi,
A benchmarking study with an additional (data.table-based) solution.
Enjoy! ;)
Cheers,
Denes
--------------------------
## packages ##########################
library(dplyr)
library(data.table)
library(IRanges)
library(microbenchmark)
## prepare example dataset ###########
## use Bert's example, with 2000 stations instead of 2
d_df <- data.frame( station =
2017 Nov 28
1
dplyr - add/expand rows
Bert wrote
... Bill's solution seems to be for only one station.
No, it works for any number of stations.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sun, Nov 26, 2017 at 11:10 AM, Bert Gunter <bgunter.4567 at gmail.com>
wrote:
> To David W.'s point about lack of a suitable reprex ("reproducible
> example"), Bill's solution seems to be for only one
2017 Nov 27
2
dplyr - add/expand rows
try this:
##########################################
library(dplyr)
input <- tribble(
~station, ~from, ~to, ~record,
"07EA001" , 1960 , 1960 , "QMS",
"07EA001" , 1961 , 1970 , "QMC",
"07EA001" , 1971 , 1971 , "QMM",
"07EA001" , 1972 , 1976 , "QMC",
"07EA001" , 1977 ,
2017 Nov 26
3
dplyr - add/expand rows
dplyr may have something for this, but in base R I think the following does
what you want. I've shortened the name of your data set to 'd'.
i <- rep(seq_len(nrow(d)), d$YEAR_TO-d$YEAR_FROM+1)
j <- sequence(d$YEAR_TO-d$YEAR_FROM+1)
transform(d[i,], YEAR=YEAR_FROM+j-1, YEAR_FROM=NULL, YEAR_TO=NULL)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sat, Nov 25, 2017 at 11:18 AM,
2017 Nov 26
0
dplyr - add/expand rows
To David W.'s point about lack of a suitable reprex ("reproducible
example"), Bill's solution seems to be for only one station.
Here is a reprex and modification that I think does what was requested for
multiple stations, again using base R and data frames, not dplyr and
tibbles.
First the reprex with **two** stations:
> d <- data.frame( station =
2017 Nov 25
0
dplyr - add/expand rows
I have a returned tibble of station operational record similar to the following:
> data.collection
# A tibble: 5 x 4
STATION_NUMBER YEAR_FROM YEAR_TO RECORD
<chr> <int> <int> <chr>
1 07EA001 1960 1960 QMS
2 07EA001 1961 1970 QMC
3 07EA001 1971 1971 QMM
4 07EA001 1972 1976 QMC
5
2017 Nov 28
2
dplyr - add/expand rows
Or with the Bioconductor IRanges package:
df <- with(input, DataFrame(station, year=IRanges(from, to), record))
expand(df, "year")
DataFrame with 24 rows and 3 columns
station year record
<character> <integer> <character>
1 07EA001 1960 QMS
2 07EA001 1961 QMC
3 07EA001 1962 QMC
4
2017 Nov 29
0
dplyr - add/expand rows
Hi Martin,
On 11/29/2017 10:46 PM, Martin Morgan wrote:
> On 11/29/2017 04:15 PM, T?th D?nes wrote:
>> Hi,
>>
>> A benchmarking study with an additional (data.table-based) solution.
>
> I don't think speed is the right benchmark (I do agree that correctness
> is!).
Well, agree, and sorry for the wording. It was really just an exercise
and not a full
2017 Nov 29
2
dplyr - add/expand rows
On 11/29/2017 04:15 PM, T?th D?nes wrote:
> Hi,
>
> A benchmarking study with an additional (data.table-based) solution.
I don't think speed is the right benchmark (I do agree that correctness
is!).
For the R-help list, maybe something about least specialized R knowledge
required would be appropriate? I'd say there were some 'hard' solutions
-- Michael (deep
2018 Jan 19
1
Web scraping different levels of a website
Hey Ilio,
I revisited the previous code i posted to you and fixed some things.
This should let you collect as many studies as you like, controlled by
the num_studies arg.
If you try the below url in your browser you can see that it returns a
"simpler" version of the link you posted. To get to this you need to
hit F12 to open Developer Tools --> go to Network tab and click on the
2024 Apr 18
1
Tidyverse/dplyr solution for filling values of a tibble/dataframe from a column with a nested list.
Hi experts.
I have a tibble? with a column containing a nested list (<list<list<double>>>? data type to be specific).
Looks something like the following (but in R/Arrow? format):
ID
Nestedvals
001
[[1]](1,0.1)[[2]](2,0.2)[[3]](3,0.3)[[4]](4,0.4)[[5]](5,0.5)
002
[[1]](1,0.1)[[2]](2,0.2)[[3]](3,0.3)[[4]](4,0.4)
003
[[1]](1,0.1)[[2]](2,0.2)[[3]](3,0.3)
004
[[1]](1,0.1)[[2]](2,0.2)
1999 Dec 16
0
Win9x printer automatic installation
Hi everyone,
I've had automatic printer driver installation running fairly nicely
for a while now, but getting the drivers for your newest printer to
automatically install completely is a pain in the neck.
Basically, everything works except for adding a new section to
win.ini, and a registry entry for the printer. All the driver
files get copied over, and the printer appears as one would
2001 Apr 30
2
margin problems?
hi, All. I'm using R 1.2.2 on a linux box.
I have very long labels on my y axis, and when I try to print them
out, they always come out clipped so I can't see them. How do I
change the margin for the y axis? I've tried mai and mar, but they
don't seem to do anything...
process.names <- c("Makeprod-data", "Makeprod-QMM", "Search",
2001 Apr 11
2
smbpasswd 2.0.7-3 matters (with smbpasswd & smb.conf...)
My message is first in english (hope you'll
understand it), et en fran?ais pour ceux qui le
causent.
--- ENGLISH ---
Hi everybody,
I've got a matter with my Samba server supplied by
Debien 2.2r0. testparm returns there's no problem in
smb.conf. It's in 'security = DOMAIN' mode.
I've got 3 boxes : SERVEUR$, POSTE1$ and POSTE2$, and
6 users, all correctly added to
2000 Jan 18
1
Problem connecting to samba shares
Hi all,
I have installed samba on my IRIX 6.5 system and configured the smb.conf
file but I get the following error each time I try to make a connection to
the samba share: "You must supply a password to make this connection,
Resource: \\topcondb\ipc$". I have added the Samba server to the NT domain
and I have also created a user account that is common to the NT domain and
the Topcondb
1999 Jun 13
1
Subnet Browsing, Halfway There
I have a network which consists of two subnets, each with a linux server
providing Samba services. With the configuration listed below, I have
successfully achieved Subnet B being able to browse Subnet A but, Subnet
A cannot browse Subnet B (sharename not found). Is it a Samba
configuration issue or is it DNS? (I have it fixed if I put an
/etc/lmhosts file on Linux Server A that has the host
2013 Apr 22
2
Applying head to wall to figure out permissions issues.
I have a permissions issue on a Samba DC running 3.5.6. UserA does not have
permissions to write to file opened by UserB. Specifically, a file created
by UserA gets 764 permissions and UserB can't write to the file until
permissions are changed either on the server to +w for other or UserA
changes the permissions on the file from Windows for Everyone to have write
permissions.
I have tried nt
2006 Jul 14
1
mgcv::gam error message
Hi
Could anyone please tell me what to do to resolve this error message?
I tried to run a gam with the mgcv package and got the following error:
"Error in qr.qty(qrc, sm$S[[1]]): NA/NaN/Inf in foreign function call (arg
5)"
(I have 116 covariates, I'm using the "cr" basis to speed things up, the
binomial family and, where necessary, have set the required k to lower than
2018 May 30
2
Filtering using multiple rows in dplyr
Hi Folks,
I have just started using dplyr and could use some help getting unstuck. It could well be that dplyr is not the package to be using, but let me just pose the question and seek your advice.
Here is my basic data frame.
head(h)
subject ageGrp ear hearingGrp sex freq L2 Ldp Phidp NF SNR
1 HALAF032 A L A F 2 0 -23.54459 55.56005 -43.08282