-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
add_resource(replace = TRUE)
fails silently if resource does not exist
#259
Comments
replace=TRUE
prevent the addition of a new resource
You didn't assign your first library(frictionless)
package <- example_package()
# Create a data frame
df <- data.frame(
multimedia_id = c(
"aed5fa71-3ed4-4284-a6ba-3550d1a4de8d",
"da81a501-8236-4cbd-aa95-4bc4b10a05df"
),
x = c(718, 748),
y = c(860, 900)
)
package <- add_resource(package, "positions", data = df)
add_resource(package, "positions", data = df, replace = TRUE)
#> A Data Package with 4 resources:
#> • deployments
#> • observations
#> • media
#> • positions
#> Use `unclass()` to print the Data Package as a list. Created on 2024-08-28 with reprex v2.1.0 However - and I'm not sure that this is what you wanted to point out - if you replace a resource that is not there, then nothing happens. It's probably better if:
I prefer the latter. |
replace=TRUE
prevent the addition of a new resourceadd_resource(replace = TRUE)
fails silently if resource does not exist
Yes, that's what I wanted to show (it works without Ok, I personally prefer the traditional |
Changed my mind, I agree that |
What about the case where you might want to literally add data to an exsiting resources (i.e., with a |
@Rafnuss No, data manipulation should be done outside of # 1. Read
df <- read_resource(x, "my_data")
# 2. Manipulate df
filter(), mutate(), bind_rows()
# 3. Attach
x <- add_resource("my_data", updated_df, replace = TRUE) That gives users full flexibility on how to manipulate the data (with e.g. dplyr). A simple schema will be created (again) when (re)adding the resource or - if they want more control - they can provide a schema to |
Ok, makes sense. I guess the functionality that I was thinking about is more precisely what bind_row does (no modification of the data) just adding data. Maybe another function |
Hi,
Is this desired? I would expect that
replace=TRUE
should not prevent the addition of a new (non-yet-exisiting) resource.I didn't look at the function, so not sure why this is happening.
The text was updated successfully, but these errors were encountered: