Keep getting ERROR: with function tabledap - r

I keep getting a returned "Error:" with my code but have no idea why when the same code works fine with a similar dataset.
Changed the observation variable, changed the time restrictions, searched for similar problems online
library(rerddap)
CalPoly = info("HABs-CalPoly", url= "http://erddap.sccoos.org/erddap/")
CalPoly_Data = tabledap(CalPoly,
fields = c('Ceratium','Cochlodinium', 'Dinophysis_spp', 'Gymnodinium_spp','time'),
'time>=2008-08-15T00:00:00Z', 'time<=2019-05-26T05:35:00Z')
Should return a data table but I just keep getting "Error:"
This similar code does work though and I have no idea why
CalCOFI = info('siocalcofiHydroCasts')
calcofi.df <- tabledap(CalCOFI,
fields = c('cst_cnt', 'date', 'year', 'month', 'julian_date', 'julian_day', 'rpt_line', 'rpt_sta', 'cruz_num', 'intchl', 'intc14', 'time'),
'time>=1984-01-01T00:00:00Z', 'time<=2014-04-17T05:35:00Z')

Resolved the issue!
I initially set the url correctly for the info argument, I didn't realize I had to set the url again for the tabledap argument. I did not realized it the Default is: https://upwell.pfeg.noaa.gov/ erddap/
Five hours later but at least it is resolved!
The code now works:
CalPoly_Data = tabledap(CalPoly, fields = c('Temp','time'),'time>=2008-08-15T07:00:00Z', 'time<=2019-05-26T07:00:00Z', url = "http://erddap.sccoos.org/erddap/")

Related

Cant get a math.random to work in two different places

function INV:DeleteInventoryItem( ply, pos, item)
local rarity = INV.PLAYERS[ply:SteamID64()][pos].quality
---print(rarity)
local value = "credits"
if(rarity == "Common")then
local amount = math.floor(math.random(1, 30))
table.remove( INV.PLAYERS[ply:SteamID64()], pos)
local var = ply:ChatPrint("You got ".. amount .." credits from deconstructing!")
ply:INVAddCredits( amount )
self.SAVE:SendInventory( ply )
local updatevalue = INV.PLAYERS[ply:SteamID64()].inventorydata.credits
UpdateDatabase(value, ply:SteamID(), updatevalue)
end
end
The problem I am having is that I cannot get the same value from the amount variable, so it says that you got a certain amount when it actually gave you a different amount.
I am really confused on how I can make it the same amount... Any help would be appreciated!
Thanks for all the help you guys have been, I since have fixed the issue and it was something wrong with the adding of the inventory credits.
-Thanks D12

Using Filters in R google_analytics

Im trying to do the following
google_analytics(my_id,
date_range = c("2018-08-25", "2019-12-31"),
metrics = c("ga:pageviews"
,"ga:uniquePageviews"
)
,segments = seg_obj
,dimensions = c("date"
#,"ga:channelGrouping"
#,"ga:deviceCategory";
,"ga:pagePath"
#,"ga:segment"
)
, anti_sample = TRUE
,filters = "ga::pagePath=#x",max = 100000)
But it returns an error saying
API returned: Invalid value 'ga::pagePath-#x' for filters parameter.
Also tried using 2 equal signs and also with filtersExpression but same resulting in error.
Tried to follow another question asked at link:
GoogleAnalyticsR api - FilterExpression
Any idea why this is happening and how i can resolve this?
Stupid error. I was using ga::pagePath when it should be ga:pagePath

Error in Rfacebook getPost - Argument has length 0

Whenever i'm trying to get a post with a lot of comments from Facebook with Rfacebook's getPost-function, i get the following error:
Error in while (n.l < n.likes & length(content$data) > 0 & !is.null(url <- content$paging$`next`)) { :
Argument has length 0
The code i'm trying to run looks like this:
post <- getPost(post = "Post-ID", token = token, n = 200)
I've also tried playing around with the different arguments of the function but nothing so far has worked... Anyone has an idea what could have caused this error? Any help is greatly appreciated!
Here's the link to the documentation of the getPost function: https://www.rdocumentation.org/packages/Rfacebook/versions/0.6.15/topics/getPost
I have a way that attacks your problem from a slightly different angle.
Instead of tackling the post ID you could, extract it from the 'Page' angle, and also this is an easier way of getting the Post ID
Step1:
see what 'Page' the post is on then you can extract the 'post' but making sure to use time parameters - for example:
"If you want to extract a post form the Nike FB page that has a massive amount of comments - which happened to fall on June, 6th 2016"
nike_posts <- getPage("nike", token = fboauth, n=100000, since = '2016/06/05', until = '2016/06/07')
Step 2:
You will then have a data frame of posts - lets say example 7 observations for that time (they possibly post multiple times a day)
If the post you are looking for is observation #3, then extract the comments by:
Comments <- getPost(nike_posts$id[3], token = fboauth, n = 10000, comments = TRUE, likes = FALSE, n.likes = 1, n.comments = 100000)
to convert this output to a DataFrame
library(plyr)
Comments <- ldply(Comments, data.frame)

Get ObjectID in mongolite R library

I can successfully retrieve data from my mongoDB instance but need to re-use the objectID for a depending query.
The following code seems to get my entire object but NOT the id. What am I missing?
# Perform a query and retrieve data
mongoOBj <- m$find('{"em": "test#test.com"}')
I realise this is an old question and OP has probably figured it out by now, but I think the answer should be
mongoOBj <- m$find(query = '{"em": "test#test.com"}', field = '{}')
instead of
mongoOBj <- m$find(query = '{"em": "test#test.com"}', field = '{"_id": 1}')
In the second case, the result will be a data frame containing ONLY the IDs. The first line will result in a data frame containing the queried data, including the IDs.
By default, field = '{"_id": 0}', meaning _id is not part of the output.
If you look at the documentation you see that the find method takes a field argument, where you specify the fields you want:
find(query = ’{}’, fields = ’{"_id" : 0}’, sort = ’{}’, skip = 0, limit = 0, handler = NULL, pagesize = NULL)
So in your case it will be something like
mongoOBj <- m$find(query = '{"em": "test#test.com"}', field = '{"_id": 1}')
FYI So the easiest way to get all fields is to do the query with field="{}". That will overwrite the default in the mongolite:: package find() arguments list.
It was driving me nuts for a little while too.

Cant get ExtededDataGrid in Flex to filter with ComboBox on multiple columns

LATEST UPDATE: Issue answered here. Some one else at stackoverflow had a similar issue and it was resolved. Solution provided for convenience. This is the line of code I was missing:
comboHeaderColumn.useLabelFunctionForFilterCompare = true;
that line is followed by these:
comboHeaderColumn.filterComboBoxBuildFromGrid = true;
comboHeaderColumn.labelFunction = formatState;
where formatState is a local method that formats the data for the combobox.
UPDATE: I've now got the combobox's loading with the correct data, but when I select a value nothing happens. The combo boxes load only data that is in the column, and when you select a value in the combobox, it's supposed to filter the rows on that value. It doesn't.
Thanks for looking. I'm having trouble getting multiple filters to work in Flex in Flash Builder 4 using the ExtendedDataGrid and ComboBox's. Here is an image of part of the grid:
The User Name and City filter properly if you type text into the box's above the column header and the Request Date lets you select date ranges if you click on the Custom bar, but the Request Reason and State ComboBoxes do not list anything. I've created them using comboHeaderColumn.filterComboBoxBuildFromGrid = true; but all it does is put "[object Object]" as the only other selection under All.
I've used this article but it will only allow you to use a single filter for the entire grid.
My finished grid will have about 20 columns and from 20,000 to 450,000 rows of data so the filters are really important and I'll need more than one.
The code is very straight forward and loops through all the returned data and if the column is identified as a filter column it does this:
comboHeaderColumn.filterComboBoxDataProvider = codeValuePairs;
comboHeaderColumn.filterComboBoxLabelField = "Value";
comboHeaderColumn.filterControl = "ComboBox";
comboHeaderColumn.filterOperation = FilterExpression.FILTER_OPERATION_TYPE_EQUALS;
comboHeaderColumn.headerText = ac.Header;
comboHeaderColumn.dataField = ac.Name;
if( ac.Header == "State" || ac.Header == "Request Reason" )
{
comboHeaderColumn.filterComboBoxBuildFromGrid = true;
}
ProfileDataColumns.push(comboHeaderColumn);
This creates 2 entries in the combo box: All and [object Object]
What am I missing??? Anyway, after half a day searching I decided to reach out.
Any suggestions or direction to an article would be very much appreciated.
Thanks.

Resources