[R] Help to download data from multiple URLs with API key

2020-04-20 Thread Bhaskar Mitra
Hello Everyone, I am trying to download data from multiple websites using API key. The code to download from one URL is given below. I have a list of multiple URLs' where the suffix URL 'c' keeps changing. I would appreciate any help on how i can modify the code below that will allow me to rea

Re: [R] NA command in a 'for' loop

2020-04-20 Thread Rui Barradas
Hello, Thanks for the data. But since the replacements still do not work, please post the output of dput(head(d, 10)) in order for us to have an *exact* copy of the data structure. I had asked for 20 or 30 rows but given your post 10 are enough. With a way to exactly reproduce what you have,

Re: [R] NA command in a 'for' loop

2020-04-20 Thread Bert Gunter
Please follow Rui's advice and use dput to provide a small reproducible example. You ask folks here to to help but won't make the effort to enable them to do so, at least not without wasting a lot of time trying to guess what's going on. And post in plain text, not HTML. That is just common courtes

Re: [R] NA command in a 'for' loop

2020-04-20 Thread Jim Lemon
Hi Helen, I can follow you this far: # just read in the data from your example d<-read.csv(text="2.90546E+11,threat,1,2,1,2,1,death,stove,NA,NA,205,0,394 2.90546E+11,threat,2,2,2,1,1,emaciated,shortened,NA,NA,205,0,502 2.90546E+11,threat,3,1,1,1,2,mutilate,consider,NA,NA,205,1,468 2.90546E+11,thre

Re: [R] NA command in a 'for' loop

2020-04-20 Thread Helen Sawaya
Thank you all for your input. This is an example of one data file (I have 74 data files): 2.90546E+11, threat,1, 2, 1, 2, 1,death,stove, NA, NA, 205,0, 394 2.90546E+11, threat,2, 2, 2, 1, 1,emaciated,shortened, NA, NA

Re: [R] NA command in a 'for' loop

2020-04-20 Thread Jim Lemon
Hi Helen, Your problem may lie in using row.names=TRUE. I was puzzled when an extra column kept popping up in the output files. For reading in and replacing zeros with NAs, this seems to work: for(mockdata in 1:3) { mdf<-data.frame(sample(2:20,10),sample(2:20,10),sample(0:1,10,TRUE)) write.table

Re: [R] Multi response GAM

2020-04-20 Thread Richard O'Keefe
You might want to start by re-expressing the "amounts" variables to total amount * (relative fish 1, relative fish 2, invertebrates) and then using the Isometric Log-ratio transformation to convert the compositional part to orthonormal coordinates. https://stats.stackexchange.com/questions/259208

Re: [R] NA command in a 'for' loop

2020-04-20 Thread Rui Barradas
Hello, I believe the only way we have to see what is happening is for you to post the output of dput(head(d, 20)) # or 30 or, with d2 a subset of d that includes zeros, dput(head(d2, 20)) Hope this helps, Rui Barradas Às 17:48 de 20/04/20, Helen Sawaya escreveu: I have one column tha

Re: [R] NA command in a 'for' loop

2020-04-20 Thread Helen Sawaya
I have one column that represents correct response versus error (correct is coded as 1 and error is coded as 0). Nowhere else in the dataset are there values of 0. The vector is treated as an integer. From: Michael Dewey Sent: Monday, April 20, 2020 7:35 PM To: H

Re: [R] NA command in a 'for' loop

2020-04-20 Thread Michael Dewey
Just a thought Helen but is x being treated as a real and what you think are zero and are printed as zero are in fact some very small number? If so you need to alter your test appropriately. Michael On 20/04/2020 17:25, Helen Sawaya wrote: Thank you for your reply. I tried d[] <- lapply(d, f

Re: [R] NA command in a 'for' loop

2020-04-20 Thread Helen Sawaya
Thank you for your reply. I tried d[] <- lapply(d, function(x) {is.na(x) <- x == 0; x}) ​but I am still getting zeros instead of NAs in my output.. I wonder if the problem is that some of my data files don't have any zeros (participants made no errors).. From: Ru