Re: [R] Help in modifying code to extract data from url

2021-06-08 Thread Bhaskar Mitra
Thanks everyone for the feedbacks. This is really helpful.

bhaskar

On Sat, May 22, 2021 at 11:56 AM David Winsemius 
wrote:

> Several authors hav addressed this problem with names that resemble
> "rbindfill". In my machine I find four instances:
>
> ??rbindfill
>
> Help pages:
> ffbase::ffdfrbind.fillrbind for ffdf where missing columns are
> added if not available in one of the ffdf objects
> plyr::rbind.fillCombine data.frames by row, filling in missing
> columns.
> plyr::rbind.fill.matrixBind matrices by row, and fill missing
> columns with NA.
> rockchalk::rbindFillStack together data frames
>
>
> --
>
> David.
>
> On 5/20/21 2:19 AM, Jim Lemon wrote:
> > Hi Bhaskar,
> > If you are using read.table or similar, see the "fill=" argument.
> >
> > Jim
> >
> > On Thu, May 20, 2021 at 9:54 AM Bhaskar Mitra 
> wrote:
> >> Hello Everyone,
> >>
> >> I am trying to extract data from a url. The codes work well when the
> >> data structure is as follows:
> >>
> >> X Y
> >> 1 2
> >> 1 5
> >> 1 6
> >> 1 7
> >> 3 4
> >>
> >> However, the code fails when the data structure has no number
> >> under the 2nd column (shown below).I get the following error:
> >>
> >> "Error in data.frame(..., check.names = FALSE) :
> >>arguments imply differing number of rows: 242, 241"
> >>
> >>
> >> X Y
> >> 1 2
> >> 1
> >> 1
> >> 1 7
> >> 3 4
> >>
> >> Can anyone please help me in how I can modify the codes ( shown below)
> to
> >> adjust for the above mentioned condition
> >> in the data structure.
> >>
> >> library(rjson)
> >>
> >> url <- "abcd.com"
> >> json_data <- fromJSON(file= url)
> >> d3 <- lapply(json_data[[2]], function(x) c(x["data"]))
> >> d3 <- do.call(rbind, d3)
> >> X_Dataframe = as.data.frame(unlist(d3[[1]]))
> >> b <- do.call("cbind", split(X_Dataframe, rep(c(1, 2), length.out =
> >> nrow(X_Dataframe
> >>
> >>
> >> regards,
> >> bhaskar
> >>
> >>  [[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help in modifying code to extract data from url

2021-05-22 Thread David Winsemius
Several authors hav addressed this problem with names that resemble 
"rbindfill". In my machine I find four instances:


??rbindfill

Help pages:
ffbase::ffdfrbind.fill        rbind for ffdf where missing columns are 
added if not available in one of the ffdf objects
plyr::rbind.fill        Combine data.frames by row, filling in missing 
columns.
plyr::rbind.fill.matrix        Bind matrices by row, and fill missing 
columns with NA.

rockchalk::rbindFill        Stack together data frames


--

David.

On 5/20/21 2:19 AM, Jim Lemon wrote:

Hi Bhaskar,
If you are using read.table or similar, see the "fill=" argument.

Jim

On Thu, May 20, 2021 at 9:54 AM Bhaskar Mitra  wrote:

Hello Everyone,

I am trying to extract data from a url. The codes work well when the
data structure is as follows:

X Y
1 2
1 5
1 6
1 7
3 4

However, the code fails when the data structure has no number
under the 2nd column (shown below).I get the following error:

"Error in data.frame(..., check.names = FALSE) :
   arguments imply differing number of rows: 242, 241"


X Y
1 2
1
1
1 7
3 4

Can anyone please help me in how I can modify the codes ( shown below) to
adjust for the above mentioned condition
in the data structure.

library(rjson)

url <- "abcd.com"
json_data <- fromJSON(file= url)
d3 <- lapply(json_data[[2]], function(x) c(x["data"]))
d3 <- do.call(rbind, d3)
X_Dataframe = as.data.frame(unlist(d3[[1]]))
b <- do.call("cbind", split(X_Dataframe, rep(c(1, 2), length.out =
nrow(X_Dataframe


regards,
bhaskar

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help in modifying code to extract data from url

2021-05-22 Thread Richard O'Keefe
The source being a URL is not important.
The important things are
 - what the structure of the JSON data is
 - what the MEANING of the JSON data is
 - what that meaning says about what SHOULD appear in the data
   from in these cases.
Arguably this isn't even an R question at all.  It's a question about your
data.
Since you have replaced the actual URL with a dummy (example.com is the
traditional
never-to-be-in-use host name), we cannot even guess these things by looking
at the
data ourselves.


On Thu, 20 May 2021 at 11:54, Bhaskar Mitra 
wrote:

> Hello Everyone,
>
> I am trying to extract data from a url. The codes work well when the
> data structure is as follows:
>
> X Y
> 1 2
> 1 5
> 1 6
> 1 7
> 3 4
>
> However, the code fails when the data structure has no number
> under the 2nd column (shown below).I get the following error:
>
> "Error in data.frame(..., check.names = FALSE) :
>   arguments imply differing number of rows: 242, 241"
>
>
> X Y
> 1 2
> 1
> 1
> 1 7
> 3 4
>
> Can anyone please help me in how I can modify the codes ( shown below) to
> adjust for the above mentioned condition
> in the data structure.
>
> library(rjson)
>
> url <- "abcd.com"
> json_data <- fromJSON(file= url)
> d3 <- lapply(json_data[[2]], function(x) c(x["data"]))
> d3 <- do.call(rbind, d3)
> X_Dataframe = as.data.frame(unlist(d3[[1]]))
> b <- do.call("cbind", split(X_Dataframe, rep(c(1, 2), length.out =
> nrow(X_Dataframe
>
>
> regards,
> bhaskar
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help in modifying code to extract data from url

2021-05-20 Thread Jim Lemon
Hi Bhaskar,
If you are using read.table or similar, see the "fill=" argument.

Jim

On Thu, May 20, 2021 at 9:54 AM Bhaskar Mitra  wrote:
>
> Hello Everyone,
>
> I am trying to extract data from a url. The codes work well when the
> data structure is as follows:
>
> X Y
> 1 2
> 1 5
> 1 6
> 1 7
> 3 4
>
> However, the code fails when the data structure has no number
> under the 2nd column (shown below).I get the following error:
>
> "Error in data.frame(..., check.names = FALSE) :
>   arguments imply differing number of rows: 242, 241"
>
>
> X Y
> 1 2
> 1
> 1
> 1 7
> 3 4
>
> Can anyone please help me in how I can modify the codes ( shown below) to
> adjust for the above mentioned condition
> in the data structure.
>
> library(rjson)
>
> url <- "abcd.com"
> json_data <- fromJSON(file= url)
> d3 <- lapply(json_data[[2]], function(x) c(x["data"]))
> d3 <- do.call(rbind, d3)
> X_Dataframe = as.data.frame(unlist(d3[[1]]))
> b <- do.call("cbind", split(X_Dataframe, rep(c(1, 2), length.out =
> nrow(X_Dataframe
>
>
> regards,
> bhaskar
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help in modifying code to extract data from url

2021-05-19 Thread Bhaskar Mitra
Hello Everyone,

I am trying to extract data from a url. The codes work well when the
data structure is as follows:

X Y
1 2
1 5
1 6
1 7
3 4

However, the code fails when the data structure has no number
under the 2nd column (shown below).I get the following error:

"Error in data.frame(..., check.names = FALSE) :
  arguments imply differing number of rows: 242, 241"


X Y
1 2
1
1
1 7
3 4

Can anyone please help me in how I can modify the codes ( shown below) to
adjust for the above mentioned condition
in the data structure.

library(rjson)

url <- "abcd.com"
json_data <- fromJSON(file= url)
d3 <- lapply(json_data[[2]], function(x) c(x["data"]))
d3 <- do.call(rbind, d3)
X_Dataframe = as.data.frame(unlist(d3[[1]]))
b <- do.call("cbind", split(X_Dataframe, rep(c(1, 2), length.out =
nrow(X_Dataframe


regards,
bhaskar

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.